Question

I want to set a variable from a flash file so that I can access if from JSFL in a Command.

I am using a element in JSFL's XMLUI: Here's the JSFL:

fl.getDocumentDOM().xmlPanel(fl.configURI + 'Commands/ATest.xml');
fl.trace(fl.xmlui.get('secretword'));//this traces undefined

The XMLUI:

<dialog buttons="accept,cancel">
  <textbox id="display_tb" size="24" />
  <flash id="trace_fl" width ="150" height="100" src="ATest.swf">
    <property id="secretword" />
  </flash>
  <button id="trace_btn" label="trace Flash" oncommand="fl.xmlui.set('display_tb','the secret word is ' + fl.xmlui.get('secretword'));" />
</dialog>

The actionscript inside ATest.swf:

MMExecute("fl.trace('Hello From Flash XMLUI');");
XMLUI.setProperty('secretword','duck');

Note that if I use

MMExecute("fl.xml.ui.set('secretword','duck')");

instead of

XMLUI.setProperty('secretword','duck');

I get an error.

The secretword is set properly in XMLUI:

  • I can use fl.xmlui.get('secretword') and set the value in the 'display_tb' textbox
  • I can print the value from actionscript (with fl.trace())

but I get undefined when I use trace fl.xmlui.get('secretword') in JSFL after opening the panel.

In a way it kind of makes sense, if the xmlui variables live as long as the xmlui dialog is display, and they become undefined as soon as the user click either accept or cancel. Can someone confirm is this is the case ?

Aworkaround would be saving the 'secretword' in a text file through JSFL from xmlui, although just passing values from a xmlui node to JSFL would be simpler. Is there a 'cleaner' way of doing this, other than writing a file to disk ?

Was it helpful?

Solution

In a way it kind of makes sense, if the xmlui variables live as long as the xmlui dialog is display, and they become undefined as soon as the user click either accept or cancel. Can someone confirm is this is the case ?

Yes, I think so too.

Aworkaround would be saving the 'secretword' in a text file through JSFL from xmlui, although just passing values from a xmlui node to JSFL would be simpler. Is there a 'cleaner' way of doing this, other than writing a file to disk ?

Why not to apply this secretword to root element of your XMLUI?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top