AS3Wrapper
AS3Wrapper imports Flash libraries into Javascript.
- Full Flash API
- Construct Flash objects directly in Javascript
- Pass objects, functions and primitives to methods directly
- Module system, with Papervision3d
- Works with IE 5.5, 6 and 7 and Firefox 2.0
Simple Example
Javascript code with AS3Wrapper
with(playerInstance)
with(flash.display)
with(flash.net){
var image = new Loader();
image.load(new URLRequest(url));
addChild(image);
}
Equivalent ActionScript 3.0 code
import flash.display.*;
import flash.net.*;
... {
var image:Loader = new Loader();
image.load(new URLRequest(url));
addChild(image);
}
Live Examples
Downloads
AS3Wrapper with examples: AS3Wrapper.zip (300 kB)
Additional fonts are also available.
Coding Differences
There are a few programming differences you have to adhere to:
Types: Leave them out.
Getters and Setters: Use
object.getName()in place ofobject.name.Imports: In place of ActionScript
importstatements, you should usewithblocks. For example, you can usewith(flash.display){new Sprite();}to create a new Flash object from the classflash.display.Sprite.Multiple Virtual Machines: A web page can contain multiple instances of the Flash player. Therefore, when you write Javascript that you want to execute for the player named
player, be sure to enclose it in awith(player) {}block. This ensures that any newly constructed objects are created in the correct virtual machine.
Running Locally
The Flash player won't let you run javascript in a page that's being hosted on the local file system. To get around this for development, you can:
View local file using a web server on localhost and http, or
Set your local AS3Wrapper.swf to be trusted by following these instructions.
