views:

72

answers:

1

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 ?

+1  A: 

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?

Eugene
I'm not sure what you mean by "Why not to apply this secretword to root element of your XMLUI?". You don't mean add a <secretword /> node to the XMLUI document manually, right ? Btw, secretword is just a placeholder, it's also used in 'Extending Flash MX 2004', the idea is that the swf generates a value that I need to get into jsfl. The simpler, the better
George Profenza
can I get know your primary goal?
Eugene
sure. I'm using a swf as a <flash /> XUL element. The gui provides a lot of controls to modify text(font,size,color,selectable,etc.). When the use is done setting the options, I need the pass those settings from the swf to jsfl (after the xul dialog was accepted). Does this make sense ?
George Profenza