Dynamically Create Dialogs?
I am trying to figure out a way to dynamically create a dialog box... essentially I would like a dialog with a row for each item in an array...
However, I am kind of stuck with the Lua syntax for doing this.. any ideas?
my skeleton dialog is something like this -- this successfully creates a dialog with one row, but I can't figure out how to loop this so it would build multiple rows based on the number of iterations in the loop...
local f = LrView.osFactory()
local myRow = f:row {
spacing = f:label_spacing(),
f:edit_field {
fill_horizonal = 1,
width_in_chars = 25,
value = 'test',
f:push_button {
width = 50,
title = 'Up',
enabled = true,
f:push_button {
width = 50,
title = 'Down',
enabled = true,
-- set up the column ---------------------------------
local contents = f:column {
spacing = f:control_spacing(),
fill = 1,
myRow
Thanks for the reply. This seems to work.. sort of... doing it this was displays the correct number of rows, however, they are not spaced very nicely. I am guessing this is due to lack of the spacing = f:control_spacing(), fill = 1, lines that were originally in the f:column. However, I can't figure out where to put those now that I am doing f:column(myRows). What am I missing here?
-m
local f = LrView.osFactory()
local myRows = {}
-- set up a rows -------------------------------------
for i=0, 6 do
myRows[i] = f:row {
spacing = f:label_spacing(),
f:edit_field {
fill_horizonal = 1,
width_in_chars = 25,
value = 'ceremony',
f:push_button {
width = 50,
title = 'Up',
enabled = true,
f:push_button {
width = 50,
title = 'Down',
enabled = true,
end
-- set up the column ---------------------------------
local contents = f:column( myRows )
-- show the dialog box
local result = LrDialogs.presentModalDialog(
title = "Categories",
contents = contents,
Similar Messages
-
Dynamicly created dialog controls
I am looking for a way to make a resizable dialog panel that is configured at runtime based on the number of units that may be tested at once. I have attached code that is a solution that I do not like as I have to create the most possible sub panel’s controls a head of time. This example has 12 but we may need up to 80. I am looking for a way to create as many sub panels as needed dynamically.
To look at the sample code unzip to a folder and run "Harris Dialog Test VI Sample.vi" the number of panels must be less than 12 and be sure to use the stop button to end as that vi closes all the other vi running. Any help would be appreciated.
Terrill
Attachments:
Sample Dialog.zip 99 KBAh Ah !
It look like you found the only FP Object that can not be created by this method.
But again, there is another way
This one used a scripting primitive that was exposed in LV 7.0.
See the attached code
Note: NI does NOT support scripting at that time, so if you have any issue whatsoever with it, you are on your own.
PJM
Got EasyXML?
JKI.VIPM.EasyXML.OpenG.LAVA.Builder.blog
Attachments:
Subpanel Dynamic Instanciation.llb 48 KB -
Dynamically Create (and reference) Dialog Window Groups
I'm trying to setup a dialog window that can be easily added to via a CSV file. The only problem I've run into is; I'm not quite sure how to create the groups dynamically. Basically, the script setups up a bunch of texture features and then gives the option to save and/or strip that feature. Below is the basic idea of what I'm trying to do, but the groups are not able to be created in the way that they are shown:
featArray = [];
featArray[0] = new Array("Feature Display Name","feature sub-group",'texture',"feature action",'feature type');
featArray[1] = new Array("Feature2 Display Name","feature2 sub-group",'texture',"feature2 action",'feature2 type'); //etc.
for(var z in featArray) {
if(featArray[z][2] == 'texture') {
w.p1.sp1.add('statictext',undefined,featArray[z][0]);
w.p1.sp1.g[z] = w.p1.sp1.add('group');
w.p1.sp1.g[z].orientation = 'row';
w.p1.sp1.g[z].add('checkbox',undefined,'Save');
w.p1.sp1.g[z].add('checkbox',undefined,'Strip');
w.p1.sp1.g[z].children[0].id = featArray[z][0].toLowerCase() + "-save";
w.p1.sp1.g[z].children[1].id = featArray[z][0].toLowerCase() + "-strip";
If you change the g[z] to g1, it will create each field correctly (visually), but there is no way to properly reference the check boxes to see which are checked. Any ideas how, or even if, it is possible to dynamically create a different group for each line of the featArray? And if so, how to then reference the check boxes in those groups later on? Thanks in advance for any help!You just use the array ie:
featArray = [];
featArray[0] = new Array("Feature Display Name","feature sub-group",'texture','feature group','feature type');
featArray[1] = new Array("Feature Display Name2","feature sub-group2",'texture','feature group2','feature type2'); //etc.
var w = new Window('dialog','test');
w.p1= w.add("panel", undefined, undefined, {borderStyle:"black"});
var x = new Array();
var count =0;
for(var z in featArray) {
if(featArray[z][2] == 'texture') {
w.p1.add('statictext',undefined,featArray[z][0]);
w.p1.g = w.p1.add('group');
w.p1.g.orientation = 'row';
x[count] = w.p1.g.add('checkbox',undefined,'Save');
count++;
x[count] = w.p1.g.add('checkbox',undefined,'Strip');
count++
x[0].onClick=function(){
alert("Checkbox 0 clicked");
x[1].onClick=function(){
alert("Checkbox 1 clicked");
x[2].onClick=function(){
alert("Checkbox 2 clicked");
x[3].onClick=function(){
alert("Checkbox 3 clicked");
w.test = w.add('button',undefined,'Press to Test');
w.add('button',undefined,'Cancel');
w.test.onClick=function(){
for(var w =0;w<x.length;w++){
alert("Checkbox " + w + " value = " +x[w].value);
w.center();
w.show(); -
I need to know when the user has changed the value of a slider or a Boolean control that was dynamically created (not part of a dialog). Is there any way to do that without polling? I would have expected these controls to post a WM_NOTIFY message to the parent window in response to user events, but that does not seem to happen. Am I missing something?
Win32 controls do typically post WM_NOTIFY messages to the parent window for user events. The Measurement Studio UI controls are actually ActiveX controls, though, and events are handled differently for ActiveX controls.
If you have a resource ID for you control, the easiest way would be to create your control in the OnInitDialog method and handle the event the same way you would if you had added the control to the dialog at design-time:
Add a declaration for the event handler in the AFX_MSG block in the dialog header file.
Make sure the AFX_MSG block in the header file includes DECLARE_EVENTSINK_MAP()
Include an ON_EVENT entry for the event in the dialog source's BEGIN_EVENT_SINK_MAP block.
Include a DDX_Control entry
in the dialog source's AFX_DATA_MAP block.
Otherwise, you'll have to dynamically sink the event at runtime after you've created the control. Microsoft's Knowledge Base has a couple of good articles that demonstrate how to do this:
SAMPLE: AtlEvnt.exe Creates ATL Sinks Using IDispEventImpl (Q194179)
AtlSink Uses ATL to Create a Dispinterface Sink (Q181277)
- Elton -
Dynamically create dynpro?
Hi,
is there a way to dynamically create a dynpro or a dialog in ABAP? I mean I've got a structure with some fields in it, perhaps DDIC stored, and I would like to get a dynpro created with those fields in a horizontal order.
Is this possible using ABAP Objects or classic ABAP?Ok guys,
thanks for responding, however I think you did miss the point of my question, so I will try to rephrase it:
The DDIC structure I want to build a selection screen of:
TYPES:
BEGIN OF zsdsm_persist_mail_attachment,
mail_immediately TYPE char01,
sms_immediately TYPE char01,
END OF zsdsm_persist_mail_attachment
This structure is just an example ! The final application should be capable of taking any DDIC structure and build up a dynpro from its components.
So, this structure above, for example, should result in a dynpro like:
PARAMETERS:
p1 TYPE zsdsm_persist_mail_attachment-mail_immediately,
p2 TYPE zsdsm_persist_mail_attachment-sms_immediately
That's all! -
Problem with embeding the same view in dynamically created view container
Hello Experts,
I am getiing a dump when i try to embed the same view inside the dynamically created view container of
dynamically created tabs of a tabstrip
The requirement go like this, i have 2 views in which i have have to embed the 2nd view to view1 where i have an empty
tabstrip without tabs. During runtime i create tabs as well as view containers accordingly and then try to embed view2 in tabs.
I have put the below mentioned code in HANDLEIN,
DATA: lref_vcntlr TYPE REF TO if_wd_view_controller,
lref_comp TYPE REF TO if_wd_component_usage,
lv_embed_pos TYPE string.
lref_vcntlr = wd_this->wd_get_api( ).
lv_embed_pos = 'FILE_PERS_EDIT/VC_GENERAL'.
TRY.
CALL METHOD lref_vcntlr->do_dynamic_navigation
EXPORTING
source_window_name = 'FILE_PERSISTENCE_WND' " Window
source_vusage_name = 'FILE_PERS_EDIT_USAGE_1' " Source View usage
source_plug_name = 'TO_EDIT_LAYOUT' " Outbound plug
target_view_name = 'PERS_EDIT_LAYOUT' " Second view to be embedded
target_plug_name = 'IN' " Second view inboun plug
target_embedding_position = lv_embed_pos
RECEIVING
component_usage = lref_comp.
CATCH cx_wd_runtime_repository .
ENDTRY.
wd_this->fire_to_edit_layout_plg( ).
This works fine for the first time.
However onaction tab select i change the embeding position( 'FILE_PERS_EDIT/view container name of different tab') of the view2 an try to embed view2 in a different tab.
At this point i get a dump stating View2 already present in the window 'FILE_PERSISTENCE_WND' of component.
I think, the view2 embediing has to be removed before i add the view2 in a different tab
Kindly let me know how to remove view2 embedding from tab1 before i add a view2 to a different tab or is there any other
means to handle this problem?
Thanks & Best Regards,
Srini.Hello Srini,
I found a solution to your problem, because I had a similar task.
In WDDOINIT I changed the method do_dynamic_navigation to if_wd_navigation_services_new~prepare_dynamic_navigation:
DATA:
l_view_controller_api TYPE REF TO if_wd_view_controller.
l_view_controller_api = wd_this->wd_get_api( ).
TRY.
CALL METHOD l_view_controller_api->if_wd_navigation_services_new~prepare_dynamic_navigation
EXPORTING
source_window_name = 'WDW_MAIN'
source_vusage_name = 'VW_SUB_USAGE_1'
source_plug_name = 'TO_VW_CONTENT'
target_component_name = 'ZTEST_DYNAMIC'
target_view_name = 'VW_CONTENT'
target_plug_name = 'DEFAULT'
target_embedding_position = 'VW_MAIN/VC_TAB.VW_SUB/TAB1_VC'
RECEIVING
repository_handle = wd_this->g_rep_handle.
CATCH cx_wd_runtime_repository .
ENDTRY.
wd_this->fire_to_vw_content_plg( param1 = 'TAB1' ).
In the action I first deleted the navigation targets, then navigated to the empty-view and last I called my target view:
DATA:
lv_position TYPE string,
l_view_controller_api TYPE REF TO if_wd_view_controller,
lr_view_usage TYPE REF TO if_wd_rr_view_usage,
lr_view_***_t TYPE wdrr_vca_objects,
lr_view_*** LIKE LINE OF lr_view_***_t.
l_view_controller_api = wd_this->wd_get_api( ).
lr_view_usage = wd_this->g_view->get_view_usage( ).
lr_view_usage->delete_all_navigation_targets( plug_name = 'TO_VW_CONTENT' ).
CLEAR lv_position.
CONCATENATE 'VW_MAIN/VC_TAB.VW_SUB/' old_tab '_VC' INTO lv_position.
TRY.
l_view_controller_api->if_wd_navigation_services_new~do_dynamic_navigation(
source_window_name = 'WDW_MAIN'
source_vusage_name = 'VW_SUB_USAGE_1'
source_plug_name = 'TO_EMPTYVIEW'
target_component_name = 'ZTEST_DYNAMIC'
target_view_name = 'EMPTYVIEW'
target_plug_name = 'DEFAULT'
target_embedding_position = lv_position ).
CATCH cx_wd_runtime_repository.
ENDTRY.
CLEAR lv_position.
CONCATENATE 'VW_MAIN/VC_TAB.VW_SUB/' tab '_VC' INTO lv_position.
TRY.
wd_this->g_rep_handle = l_view_controller_api->if_wd_navigation_services_new~prepare_dynamic_navigation(
source_window_name = 'WDW_MAIN'
source_vusage_name = 'VW_SUB_USAGE_1'
source_plug_name = 'TO_VW_CONTENT'
target_component_name = 'ZTEST_DYNAMIC'
target_view_name = 'VW_CONTENT'
target_plug_name = 'DEFAULT'
target_embedding_position = lv_position ).
CATCH cx_wd_runtime_repository.
ENDTRY.
wd_this->fire_to_vw_content_plg( param1 = tab ).
Ann.: I my example, I had 3 views: VW_MAIN which embedds VW_SUB. VW_SUB has the tabs in it and VW_SUB embedds VW_CONTENT.
BR,
Roland -
Hello,
I want to create a document with cascading 'popups'. Not the built-in text-only popup, but an annotation containing an appearance stream that defines text and images. I'm currently using widget annotations based on a pushbutton field.
Each page in my document has many citations that refer to other pages in the document. When a user hovers over the citation, I want a 'popup' to appear containing a depiction of the destination. However, as the destination will itself have citations, I also want the 'popup' to contain citations that the user can hover over, triggering another popup, etc. In this way, a user could navigate throughout the document without leaving the page or even clicking the mouse.
Obviously, with even a modest number of citations per page, pre-calculating and statically defining all of these widgets causes a combinatorial explosion, making the document sluggish and very large.
Instead, I'd like to statically define appearance streams once per document, and then dynamically create annotations and assign the appropriate appearance stream using JS as the user navigates.
So far I've created a named AP in the names dictionary, but I haven't been able to use it to dynamically set an appearance stream of a dynamically created widget annotation.
Also, I've called Doc.getIcon(), passing in the named AP, which returns an Icon object. However, after field.buttonSetIcon() and passing in the named AP, the button does not display the icon.
Is there a way to use a statically defined appearance stream in a dynamically created annotation?
Thank you,
DaveHi George, I've gotten named APs to work, and I expect hidden buttons will follow. Thank you very much!
Quick follow-up - I will have many documents embedded within the same pdf file, and some of these documents will contain identical popups. However, I don't want to store identical icons in each document on account of file size.
Instead, I'd like to store one instance of each icon for all documents in the file.
Can I store all of the icons in a single document, and then access them by calling <DocName>.getField().getIcon() from any document in the file?
Thank you again,
Dave -
How to get the co-ordinates of a dynamically created input field
Hello Frn's
i have created a dynamic text view . but this text view is not appearing at proper position . I want palce it infront of a dynamically created input field . how can i do this ?
as i am thinking ...i should first of all get info about the co-ordinates of dynamaclly creatd input field . and with respect to these co-ordinates ...set the position of text View .
Please suggest your thoughts .
Thanks and Regards
Priyank DixitHi,
There is no provision in WD for getting screen coordinates and then placing the UI element.
You to add the UI element to layout editor and based on the layout type it will add the UI element to respective position.
I would advice not to create dynamic UI elements( instead you can create them statically and then play with visibility status through context binding ). This will be more effective way and less error prone. This is also recommended practice.
still,For dynamic creation you can refer to following wiki:
http://wiki.sdn.sap.com/wiki/display/WDABAP/CreatingUIElementsDynamicallyinAbapWebdynpro+Application
regards
Manas Dua -
How dynamically create connection pool and Datasource
Hi
How I can dynamically create a connection pool and Data source in Oracle 10g Application server. In our J2EE application the user will be login with db user name, password and database name. I want to create connection pool and data source on the fly while login the user with database name. I our application we have access approximate 80 Databases. so my approach is given bellow
1) Planning to create 80 connection pools and 80 Data sources so when user logs in while selecting the db name i will call the appropriate data source and create the DB connection. Is there any limitation to create number of data sources in oracle app server?
2) Create DB connection with out using connection pool and data source. But i am not prefer this approach coz we need to handle some transaction in our application.
Kindly throw some light on managing connection pool programmatically or in application run time.
I would really appreciate if any one can provide any links or any inormation on this issue.
Thanks in advance.Kindly let me know is there any drawbacks to create 80 Data Sources to connect 80 database in Oracle 10G App server and each data sources should have one connection pool. so i need to create 80 connection pool. Please let me know is this right approach or any work around to create Data source on fly for each request for corresponding database.
-
Assigning a 'dynamically created sequence' value to a variable
in my procedure i am creating a sequence on the fly, i am preparing the name with some passed parameters like below
v_seq_name := 'seq_'||loadid||v_table_name;
execute immediate 'CREATE SEQUENCE '||v_seq_name||' MINVALUE 1 MAXVALUE 999999999999999999999999999 START WITH 1 increment by 1 cache 20';
and now after doing some operations i need to assign the current value of sequence to a number variable i tried following but not working
1) v_curr_value : = v_seq_name.currval ;
2) select v_seq_name||'.nextval' into v_curr_value from dual;
can you please suggest me how i can get the value in plsql block.DIVI wrote:
in my procedure i am creating a sequence on the fly, i am preparing the name with some passed parameters like below
v_seq_name := 'seq_'||loadid||v_table_name;
execute immediate 'CREATE SEQUENCE '||v_seq_name||' MINVALUE 1 MAXVALUE 999999999999999999999999999 START WITH 1 increment by 1 cache 20';
and now after doing some operations i need to assign the current value of sequence to a number variable i tried following but not working
1) v_curr_value : = v_seq_name.currval ;
2) select v_seq_name||'.nextval' into v_curr_value from dual;
can you please suggest me how i can get the value in plsql block.Well, you haven't given the error you are getting but I guess the procedure isn't compiling? You need to execute immediate any reference to the sequence.
Having said that, your architecture is probably wrong if you are dynamically creating things in a procedure.
Why do you need to create them dynamically? -
Dynamically creating a Record Group based on Previously entered Record Grou
Forms [32 Bit] Version 10.1.2.3.0 (Production)
Hi,
I know how to dynamically create a record group based on a query and putting the code in When new form instance.
My query is. I have a form which has multiple Record Groups and the user wants to dynamically create subsequent groups based on previous groups.
For example
I have a record group with selects a Location,
when the user selects the Location from a list of values
the 2nd record group called 'Cost Centres' will have to filter out only those with the locations selected above.
How can I populate the 2nd record group at run-time when I do not know what site the user will select?
If I simply populate in when new form instance as in location and just select everything, the list of values populates.
CC field is a LIST ITEM and the list style is a POP LIST, it is not required.
I have put the code in the Location field in the when-list-changed trigger.
I am getting this error:
frm-41337: cannot populate the list from the record group
here is the code:
DECLARE
v_recsql Varchar2(1000); -- The SQL for creating the Record Group.
v_recgrp RecordGroup; -- Record Group
v_status Number; -- Return Value of Populate_Group function.
c_where VARCHAR2(1000);
BEGIN
IF :location = '1' THEN
c_where := ' substr(cost_centre,1,2) in (''01'',''02'')';
ELSIF :location = '2' THEN
c_where := ' substr(cost_centre,1,2) in (''02'',''03'')';
ELSIF :location = '3' THEN
c_where := ' substr(cost_centre,1,2) in (''01'',''11'',''07'')';
ELSE
c_where := ' 1=1'; --EVERYTHING
END IF;
v_recsql := 'SELECT cost_centre, description FROM cost_centres where '||c_where;
-- Create the Record Group
v_recgrp := CREATE_GROUP_FROM_QUERY('v_recgrp', v_recsql);
IF NOT ID_NULL(v_recgrp)
THEN -- No Error, record group has been successfully created.
-- Populate Record Group
v_status := POPULATE_GROUP('v_recgrp');
IF v_status = 0
THEN -- No Error. Record Group has been Populated.
POPULATE_LIST('block.CC', 'v_recgrp');
END IF; -- IF v_status = 0
-- Delete the Record Group as it is no longer needed.
DELETE_GROUP('v_recgrp');
END IF; -- IF NOT ID_NULL(v_recgrp)
END;thanks for your assistance.Hi,
Once record status gets change for block you can not populate/repopulate the list item. Keep those list items as non-database item with different names and create different items as database orignal items. Than assign the values in WHEN-LIST-CHANGE trigger to the actual database items.
-Ammad -
Uploading data from excel file to a dynamically created internal table
Hi,
I have a requirement where i have to upload data from an excel file into a database table. I would be able to determine the structure of the table only at runtime based on the user input.. so i have created an internal table dynamically.
Could you please tell me if its possible to upload data from an excel file to the dynamically created internal table using any function modules?
I thought of doing this by declaring a generic internal table of one field and then uploading the *.csv file into it and then splitting it based on "," and then assigning it to the field symbol referencing the internal table.. but my file length exceeds 132 characters and i'm only able to get data of lenght 132 char's in my internal table ( generic one).
Could anyone please show me a way around this.
Thanks in advance,
HarshaSure, check this out.
report zrich_0002.
type-pools: slis.
field-symbols: <dyn_table> type standard table,
<dyn_wa>,
<dyn_field>.
data: it_fldcat type lvc_t_fcat,
wa_it_fldcat type lvc_s_fcat.
type-pools : abap.
data: new_table type ref to data,
new_line type ref to data.
data: iflat type table of string.
data: xflat type string.
data: irec type table of string with header line.
data: tabix type sy-tabix.
data: file type string.
selection-screen begin of block b1 with frame title text .
parameters: p_file type rlgrap-filename default 'c:Test.csv'.
parameters: p_flds type i.
selection-screen end of block b1.
start-of-selection.
* Add X number of fields to the dynamic itab cataelog
do p_flds times.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = sy-index.
wa_it_fldcat-datatype = 'C'.
wa_it_fldcat-inttype = 'C'.
wa_it_fldcat-intlen = 10.
append wa_it_fldcat to it_fldcat .
enddo.
* Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = new_table.
assign new_table->* to <dyn_table>.
* Create dynamic work area and assign to FS
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.
file = p_file.
call method cl_gui_frontend_services=>gui_upload
exporting
filename = file
changing
data_tab = iflat
exceptions
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
others = 17.
loop at iflat into xflat.
clear irec. refresh irec.
split xflat at ',' into table irec.
loop at irec.
tabix = sy-tabix.
assign component tabix of structure <dyn_wa> to <dyn_field>.
<dyn_field> = irec.
endloop.
append <dyn_wa> to <dyn_table>.
endloop.
* Write out data from table.
loop at <dyn_table> into <dyn_wa>.
do.
assign component sy-index of structure <dyn_wa> to <dyn_field>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <dyn_field>.
else.
write: <dyn_field>.
endif.
enddo.
endloop.
Regards,
Rich Heilman -
How to set a value to a dynamically created node/attribute?
Hi,
I dynamically created attributes using the following method,
IWDNodeInfo cbOptions = wdContext.getNodeInfo().addChild("cbOpt"+count, null, true, true, false, false, false, true, null, null, null);
cbOptions.addAttribute("opt"+critEle.getQuest_Critid(), "ddic:com.sap.dictionary.string");
How do i assign a value to it now, since the node/attribute cannot be accessed via wdcontext?
On a side note, it seems really troublesome if i need to use a checkbox grp(s) dynamically. I actually need to dynamically create a seperate node + attribute for each checkbox grp i have. Is there any better way to do this?
Thanx in advanceHi
Steps:
1) Create the action click is done statically (you cannot create action dyanmically)
2) binding the action click to checkbox dynamically
code
public static void wdDoModifyView(IPrivateDynamicProgrammingView wdThis, IPrivateDynamicProgrammingView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
//@@begin wdDoModifyView
if(firstTime){
IWDTransparentContainer con=(IWDTransparentContainer)view.getElement("RootUIElementContainer");
IWDCheckBox checkBox=(IWDCheckBox)view.createElement(IWDCheckBox.class,"ck");
IWDAction act=wdThis.wdCreateAction(IPrivateDynamicProgrammingView.WDActionEventHandler.CLICK,"");
checkBox.setOnToggle(act);
con.addChild(checkBox);
//@@end
Thanks and Regards,
Arun -
How do I reference a dynamically created MovieClip from another MovieClip?
Hi,
I'd be grateful for any pointers to the following problem:
I'm having trouble referencing dynamically created MovieClips (links in a side panel on a Flash website, created from an XML file) from the current MovieClip (the currently selected link).
I wish to freeze the the link/MovieClip in its mouseOver state once it has been clicked - this part works. When a new link/MovieClip is clicked on, I wish to release the previously clicked-on link from its mouseOver state, which is what I've so far been unable to do.
My problem seems to be referencing the previous link/MoveClip. I've used the trace statement trace(MovieClip(this).name) to determine that the MovieClips are named item0, item1, item2 and so on. However, I've been unable thus far to reference the previous clip thus far. I've tried to trace the route to the MovieClip from the stage, and also tried MovieClip(parent).item0.gotoAndStop and lots of other different permutations, but to no avail. It's the fact they seem to be in a container called 'panel' which is defeating me.
Here's a live version I've uploaded, which might explain the problem better. Click on "UBER UNS" in the top menu bar to get to the page in question. It's the links on the left-hand side (Historie, Unser Team, etc.) which are the problem. You'll see that once they've been clicked on they remain in their mouseOver state.
This is the code in question on the fla file, which is a file I did not create myself. The parts in black work fine; it's the red parts where the problem lies:
import flash.display.MovieClip;
panel.buttonMode = true;
var lang:uint = 1;
var url_Link:String=MovieClip(root).program.websiteXML .language[lang].pages.titlePage[MovieClip(root).program.linkPage].texts.pageList.txt[numT XT].@link;
var urlPage:Number=Number(MovieClip(root).program.webs iteXML.language[lang].pages.titlePage[MovieClip(root).program.linkPage].texts.pageList.tx t[numTXT].@linkPage);
var request:URLRequest;
var linkIndex:uint;
var lastClickedLink:MovieClip; //This is supposed to store the last link that has been clicked - it doesn't work
panel.addEventListener(MouseEvent.CLICK, clicLink);
panel.addEventListener(MouseEvent.ROLL_OVER, mouseOverLink);
panel.addEventListener(MouseEvent.ROLL_OUT, mouseOutLink);
function mouseOverLink(event:MouseEvent):void {
MovieClip(this).gotoAndPlay('s1');
function mouseOutLink(event:MouseEvent):void {
if(numTXT !== (linkIndex - 1)/5){ //freezes mouseOver state if this is the link for the current page
MovieClip(this).gotoAndPlay('s2');
function clicLink(event:MouseEvent):void {
var linkpage:uint = MovieClip(root).program.linkPage;
if (url_Link) {
request = new URLRequest(url_Link);
navigateToURL(request);
} else {
linkIndex = numTXT * 5 + 1;
if(linkpage == 1){
MovieClip(root).chPages.cont.page_about_mc.page3Tu rner_mc.gotoAndStop([linkIndex]);
} else if (linkpage == 2){
MovieClip(root).chPages.cont.page3_mc.page3Turner_ mc.gotoAndStop([linkIndex]);
lastClickedLink.gotoAndPlay('s2'); // this is supposed to release the previous clicked-on link from it's mouseOver state - doesn't work
lastClickedLink = MovieClip(this).name; //this is supposed to set the new link as the last link clicked after the old one has been released from it's mouseOver state - doesn't work
If anyone can help, that would be great.What you might be after for that line is to use:
lastClickedLink = MovieClip(event.currentTarget);
For what you show, the name property of an object is a String, so I would expect you to be getting an error regarding trying to get a String to act like a MovieClip when you try to tell it to gotoAndPlay('s2'). -
Dynamically create and remove TEXT items in forms
Hi Guys,
Is there a way to dynamically create and remove TEXT items in form. For example I have the EMP and DEPT table and when
I select the EMP table name from the LOV, rows of the EMP table with column name and data should get displayed on the screen and likewise a similar action for DEPT table and
so on. I have about 90 tables from where data could be required to view and edit. They all have varying number of columns.
Any suggestions ?
Thanks
KMD
nullUse OLE concept of developer and map Excel as an object
Nadeem
null
Maybe you are looking for
-
How do I send a message with Mail that has a logo in it that I want to show in the body of the message, not as an attachment?
-
I copied ACH format 005 and made some changes to comply with the new guidelines. I am having trouble uploading the file into the Bank because of a field in the segment portion of the format. The field I am referring to is the "Customer payment number
-
Effect of sold to party in sales order
Hi, What is the effect of sold to party in sales order.I have faced this question in one interview. Suppose we are creating the sales order with customer '11' and material 'abc',but before saving the sales order document we changed the customer and n
-
CD drive always opens on start up
Hi I have a G4 Sawtooth OS 9.2.1. With an M7803 Mac keyboard. Works fine, except that the CD drive ALWAYS opens when I boot up, and I have to close it manually. Happens with or without extensions on/off ?
-
IPhone SDK: Setting Alarms?
Hi, I'm writing an app for iPhones that requires: 1) Automatically launching itself at scheduled times 2) Setting 'alarms' in the system that would either do the above or show an alert of some sort at the given time However I can't find anything in t