|
|||
|
is it possible to pass an array object from FFish Script to flashplayer through FlashPlayer? i tested it... but in vain... would you please help?
for example: in FFish Script "Initialize" block: Code:
var arr = new Array("e", "f", "g", "h");
FlashPlayer.setVariable("array Var in flash", arr);
Code:
var myobj = new Object();
myobj.id = theId;
myobj.pw = thePW;
FlashPlayer.setVariable("var/object in flash", myobj);
Code:
var myobj = FlashPlayer.getVariable("some predefined object in flash");
waitin for your answer... ??? ??? ??? SWFBaz
__________________
SWFBaz Preview [October 2006] http://www.SWFBaz.com |
|
|||
|
dear daniel and topcmm,
plz ans quickly to my quests... coz i am keen to be in your contest as quick as possible.. coz after flash.. .your tool inspired me alot. that is why i love it. now-a-days i m developing an application using flash and SWFKit... plz do help me... i will also include a refference for both of you... coz you are outstanding... 8) regards
__________________
SWFBaz Preview [October 2006] http://www.SWFBaz.com |
|
|||
|
Thanks, we are glad to help you.
The Flash player methods "setVariable"; and "getVariable"; can only transfer numbers, strings or properties. You cannot transfer arrays or objects by one single call. It's the limit of the Macromedia Flash Player. 1. Transfer Arrays: When you use "getVariable" with a array, it does not return an array, but returns a string that joins all the elements in the array together with a separator ','. You can use the "split" method to split the string to an array: To transfer array from ActionScript to FfishScript: Code:
var str = FlashPlayer.getVariable("array Var in Flash");
var myArray = str.split(",");
In FfishScript: Code:
FlashPlayer.setVariable("Var in Flash", arr);
Code:
arr = "Var in Flash".split(",");
2. Transfer Objects: Code:
function transferObject()
{
* * *this.obj_prop_names = new Array();
* * *for (var i = 2; i < arguments.length; i++)
* * *{
* * * * * *this.obj_prop_names[i - 2] = arguments[i].toString();
* * *}
* * *
* * *this.local_obj_name = arguments[0].toString();
* * *this.flash_obj_name = arguments[1].toString();
* * *
* * *this.fs_to_as = function ()
* * *{
* * * * * *for (var i = 0; i < this.obj_prop_names.length; i++)
* * * * * *{
* * * * * * * * *FlashPlayer.setVariable(this.flash_obj_name + '.' + this.obj_prop_names[i],
* * * * * * * * * * * *eval(this.local_obj_name + '["' + this.obj_prop_names[i] + '"]'));
* * * * * *}
* * *}
* * *
* * *this.as_to_fs = function ()
* * *{
* * * * * *for (var i = 0; i < this.obj_prop_names.length; i++)
* * * * * *{
* * * * * * * * *var expr = this.local_obj_name + '["' + this.obj_prop_names[i] + '"]';
* * * * * * * * *expr += ' = FlashPlayer.getVariable("';
* * * * * * * * *expr += this.flash_obj_name + '.' + this.obj_prop_names[i] + '")';
* * * * * * * * *eval(expr);
* * * * * *} * * * * * *
* * *}
}
Syntax: * *transferObject(FFish_Obj_name, Flash_Obj_name, Flash_Obj_property_name_0, *Flash_Obj_property_name_1, ..., Flash_Obj_property_name_n); Prameters: FFish_Obj_name String. Represents the name of the object in FFish Script Flash_Obj_name String. Represents the name of the predefined object in ActionScript. Flash_Obj_property_name_0...Flash_Obj_property_nam e_n String. Represents the property names of the ActionScript object Example: Providing you want to transfer data between AS object "as_obj", which has two properties "id" and "pw", and FS object "fs_obj": Code:
var fs_obj = new Object;
fs_obj.id = 0;
fs_obj.pw = 1;
var tobj = new transferObject("fs_obj", "as_obj", "id", "pw");
tobj.as_to_fs();
tobj.fs_to_as();
|
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|