next up previous contents
Next: Properties Up: FFish Script Objects Reference Previous: onMessage   Contents


FlashPlayer Object

Description

Provides access to the Macromedia Flash Player. This object encapsulates all methods of the Macromedia Flash Player ActiveX object. Furthermore, This object provides a way to exchange data between the FFish Script and the Macromedia Flash ActionScript.

available: SWFKit Express, SWFKit, SWFKit Pro


Syntax

new FlashPlayer

Parameter

None


Returns

Returns a new instance of the FlashPlayer object. It¡¯s a static object that can be used without construction.


Remarks

The object provides an easy way to exchange data between the FFish Script and the Macromedia Flash Action Script. The picture 2.2 describes the mechanism of the Data Exchanging.

Figure 2.2: Data exchanging
Image image002.

First, the bindData method binds the Action Script variables to the FlashPlayer object. The FlashPlayer Object maintains a property list, which contains properties with the same names as the bound Action Script variables. The FlashPlayer object transfers data between the bound Action Script variables and the corresponding properties.

Second, the updateData method performs the exchanging. A call to the updateData method with a true argument transfers data from Action script to the FlashPlayer object. While a call to the updateData method with a false argument transfers data from the FlashPlayer object to Action Script. The updateData method transfers data all at once.

The unbindData method unbinds Action Script variables. The unbindAll method unbinds all bound Action Script variables. The two methods make the FlashPlayer object to remove the corresponding properties.

The FlashPlayer object only binds numbers, Booleans or strings. The bindData method only accepts variables specified in the dot syntax. Furthermore, remember to specify the full path of the variables. With the data exchange mechanism, you can access an Action script variable as if it is a property of the FlashPlayer object. The FlashPlayer object automatically converts the data types. The property name is exactly the same as the variable name you bind. For example, if you bind a variable named "_root.x", you must access it with expression "FlashPlayer._root.x". The expression "FlashPlayer.x" does not work, though "_root.x" and "x" specifies the same variable in Action Script.


Example

var pla = new FlashPlayer;
pla.bindData("_root.x", "_root.y",
    "_root.w", "_root.h",
    "_root.play_area.text", "_root.play_area.i");
pla.bindData("_root.play_area.name", "data");
pla.updateData(true);
trace(pla._root.x);
trace(pla._root.y);
trace(pla._root.w);
trace(pla._root.h);
trace(pla._root.play_area.name);
trace(pla._root.play_area.text);
trace(pla._root.play_area.i);
trace(pla.data);




Subsections
next up previous contents
Next: Properties Up: FFish Script Objects Reference Previous: onMessage   Contents
Copyright ©2000-2010 Shanghai TopCMM Software Technologies. All Rights Reserved.