|
|||
|
The attached sample shows how to do this by using a flash component named "Trigger".
The Trigger component has a "addHandler" method. In Action script Code:
trigger.addHandler(handlerFunc);
function handlerFunc(arg)
{
//do something
...
}
How to trigger the component to call the handler function? Just set the value of the "fArg" property of the component. E.g. in ffish script, Code:
FlashPlayer.setVariable("_root.trigger.fArg", "Hello world");
With the "Trigger" component, it's very easy to pass data from ffish script to action script. The steps of adding files into a list box 1. add a "trigger" component into the flash movie 2. add a handler function in action script Code:
function addFiles(arg)
{
***/*!ffish script will pass a string contains
*** file names separated by ',', so split it
*** to an array
*** */
***
***var files = arg.split(',');
***var i;
***
***/*! add the file names to the list box***
*** */
***
***for (i = 0; i < files.length; i++)
***{
******_root.myListBox.addItem(files[i]);
***}
}
trigger.addHandler(addFiles);
Code:
var arr = [];
arr[0] = "c:\\1.txt";
arr[1] = "c:\\1.jpg";
/*!The setVariable method can only pass a string to
action script, so we must convert the array to
string. Then the value passed to the handler
function "addFiles" in action script will be
"c:\1.txt,c:\1.jpg"
*/
FlashPlayer.setVariable("_root.trigger.fArg", arr.toString());
|
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|