My account
Shopping cart
Knowledge base
Support


ActionScript Bridge



actionscript bridge flash components

Download

The full version of this product can be downloaded free of charge by clicking the above button.

What can be done using ASB?

A. Use flash AS2.0 flash components in AS3.0 projects.
B. Use older AS2.0 widgets, flash files inside newer AS3.0 projects.
C. Use AS2.0 methods, functions or classes inside AS3.0 projects, call them and get returns back.
Technically: Load Macromedia/Adobe Flash AS2.0 projects (swf) inside Adobe Flash AS3.0 projects using ASB and communicate between them. Call functions, fire up events and get return variables using our ASB API.

The story of ASB

With the launch of the new Flash CS3 and ActionScript 3.0, Adobe created a gap, in terms of compatibility, between applications created using ActionScript 2.0 and ActionScript 3.0. This means that a Flash clip created using ActionScript 3.0 can load and play a clip created using ActionScript 2.0, but it will not have access to anything (variables, functions, objects) inside the AS2 clip.

ActionScriptBridge is a project that aims to fill the gap between AS2 and AS3. It gives the possibility for two Flash movies, one created using AS2 and the other using AS3, to communicate with one another (at least regarding function calls). This means that the AS3 clip will be able to call functions found in the AS2 clip loaded in it, and the AS2 clip will be able to call functions found in its’ parent, the AS3 clip. All this, by using two components: ASBContainer, for Flash CS3 and AS3, and ASBTerminal, for Flash MX 2004 or later and AS2.

Creative Commons License
The ASB is now version 0.9 beta, and it is free for use, share and distribute under the Creative Commons Attribution-No Derivative Works 3.0 License

What is the ASB API?

The ASB API consists of easy to use methods and 2 flash components:
1. ASBTerminal (the drag and drop ASB terminal/connector for AS2.0, enables any AS2.0 swf files for AS3.0 integration and communication).
2. ASBContainer (the loader/container that is used in AS3.0 projects to include ASB enabled AS2.0 files, using the source parameter)

The included installer will install the components for Flash CS3 both AS2 and AS3 components.

ASBTerminal - AS2.0 flash component

This component, used by AS2 clips, provides a mean to call functions inside an AS3 clip.

Methods
public function run(arg):Void – Requests the execution of a function found in an AS3 clip.
Parameters:
arg – A string representing the function to be called or an object containing the function name, the object it is attached to (client) and a list of arguments to pass as parameters.

Example
instanceName.run("myFunction(1, 2, 3)");
or
instanceName.run( { client:"", functionName:"myFunction", args:[1, 2, 3] } );


Events

status – Event triggered when the component tries to connect to an ASBContainer instance. The event object contains the level parameter with specifies weather the connection succeeded ("status") or failed ("error").
ASBReturn – Event triggered when a function called from the AS3 clip returns a parameter. The event object contains the parameters value, the value returned by the function, and functionName, the function that returned the value.

Example
var listener:Object = new Object();
listener.status = function(evtObj:Object):Void {
if (evtObj.level == "status") trace("Connection succeeded…");
if (evtObj.level == "error") trace("Connection failed…");
}
listener.ASBReturn = function(evtObj:Object):Void {
trace("The AS3 function "+evtObj.functionName+" returned "+evtObj.value);
}
instanceName.addEventListener("status", listener);
instanceName.addEventListener("ASBReturn", listener);


Notes
If the parameter passed to the run method is of type Object and the functionName is missing, the component will display the following error message in the output panel: ERROR: you must send at least the functionName property trough the object.

ASBContainer - AS3.0 flash component

This component, used by AS3 clips, provides a mean to call functions inside an AS2 clip.

Properties

source:String – The url to the .swf file created using AS2.

Methods
public function run(arg):Void – Requests the execution of a function found in an AS2 clip.
Parameters:
arg – A string representing the function to be called or an object containing the function name, the object it is attached to (client) and a list of arguments to pass as parameters.

Example
instanceName.run("_root.myFunction(1, 2, 3)");
or
instanceName.run( { client:"_root", functionName:"myFunction", args:[1, 2, 3] } );


Events

init – ASBEvent.INIT – Event triggered after the external AS2 clip has been loaded.
connect – ASBEvent.CONNECT – Event triggered after the ASTerminal instance has been initialized and connected with ASBContainer instance. After this event has been triggered, ASBTerminal and ASBContainer instances can call function to execute from each other.
status – ASBEvent.STATUS – Event triggered when the component tries to connect to an ASBTerminal instance. The event object contains the level parameter with specifies weather the connection succeeded ("status") or failed ("error").
asb_return – ASBEvent.ASB_RETURN – Event triggered when a function called from the AS2 clip returns a parameter. The event object contains the parameters value, the value returned by the function, and functionName, the function that returned the value.

Example:

import ASBEvent;
instanceName.addEventListener(ASBEvent.INIT, initHandler);
instanceName.addEventListener(ASBEvent.CONNECT, connectHandler);
instanceName.addEventListener(ASBEvent.STATUS, statusHandler);
instanceName.addEventListener(ASBEvent.ASB_RETURN, returnHandler);
function initHandler(evtObj:ASBEvent):void {
trace("The external AS2 file has been loaded.");
}
function connectHandler(evtObj:ASBEvent):void {
trace("The ASBTerminal instance has connected to me.");
}
function statusHandler(evtObj:ASBEvent):void {
if (evtObj.level == "status") trace("Connection succeeded…");
if (evtObj.level == "error") trace("Connection failed…");
}
function returnHandler(evtObj:Object):void {
trace("The AS2 function "+evtObj.functionName+" returned "+evtObj.value);
}


Notes
If you execute the run method, before the external AS2 clip is loaded, the component will display the following error message in the output panel: ERORR: The source is not loaded, yet.
If the parameter passed to the run method is of type Object and the functionName is missing, the component will display the following error message in the output panel: ERROR: you must send at least the functionName property trough the object.
If the AS3 clip is unable to transmit the connection id to the AS2 clip, the component will display the following error message in the output panel: ERROR: the connection id could not be sent to the AS2 file.

How to use ASB components?

After installing the components, you should drag in instance of them on the Stage, for each type of movie clip: ASBTerminal for the ActionScript 2.0 clip and ASBContainer for the ActionScript 3.0 clip. Give them an instance name and set the source parameter of the ASBContainer instance to the path and file name of the ActionScript 2.0 file. Next write the code you need for each file (following the examples given earlier) and test the results.

The pack contains the .mxp install file, the documentation file and the sample files.
Fully free component
Use AS2.0 flash components in AS3.0 projects