convert swf to exe, make flash application, flash to exe, make flash screensaver, swf to exe, swf to mp3
 
Products: SWFKit Pro, SWFKit, SWFKit Express | SWFKit Online | SWFSnd | SWFImg | SWFGen | 123FlashChat | MingX
  Home > Products > SWF Kit Series > Tutorials > Data exchanging between Action Script and FFish Script
Overview Features Comparison Samples Download Buy Now Tutorials Documentation
 

4. Data exchanging between Action Script and FFish Script

We often need to exchange data between Action Script and FFish Script. In the section "Add more functions to your application" we discussed a sample about saving game scores. The "flashplayer" and "score" text fields are in Flash, how can we get their values? And How can we transfer data from Action Script to FFish Script or from FFish Script to Action Script?

SWFKit provides 3 ways.

The "setVariable" method and the "getVariable" method

The most direct way to exchange data between AS and FS is to use these two methods. In fact, in all other two ways these two methods will be called at last implicitly. The methods are provided by the Macromedia Flash Player ActiveX Object and SWFKit wraps them in the FlashPlayer object.

In the game score sample, to get the value of the "playername" and "score" variables in Action Script

var playerName = FlashPlayer.getVariable("_root.playername");
var score = parseInt(FlashPlayer.getVariable("_root.score"));

To fire the trigger, we need to set the "fArg" property of the trigger component

FlashPlayer.setVariable("_root.trigger.fArg", allscores.toString());

The "updateData" method

You can read the SWFKit online documentation to get more details for this method.

Still in the game score sample, to get the value of the "playername" and "score" variables using this method, firstly we need to bind the variables in FFish Script

FlashPlayer.bindData("_root.playerName", "_root.score");

To get the values of the variables

FlashPlayer.updateData();
trace(FlashPlayer._root.playerName);
trace(FlashPlayer._root.score);

"getArray", "putArray", "getObject", "putObject"

These four methods provide an easier way to exchange arrays and objects between the Action Script and FFish Script. The methods provide a way to transfer arrays or objects by only one call. However, you must declare the arrays or objects in Action Script explicitly before data exchanging.

 

Link to us

Contact us

Feel free to link to us!
We appreciate it!

support@swfkit.com
sales@swfkit.com
info@swfkit.com

Bookmark our site Tell a friend, Win a CD Flash Chat in China