|
Using the Flex 2 SWC |
|
Zinc 2.5 (Build 2.5.0.17 and higher) is the first SWF2EXE that provides full Flash Player 9, Flex 2 and ActionScript 3 support in one package! To use ActionScript 3 with {mdm}Script 2.0 in your Flex Projects you must follow the instructions below:
1. Make the project as per usual in Flex
2. Right click on the project in the Navigator ( the top left pane )
3. Select properties from the drop down menu
4. A properties wizard kind of dialog will be displayed. In the left pane, click ActionScript Build Path
5. In the right pane, a tabbed view will be presented. Click the right tab, Library path
6. A window with currently bound swcs will be shown. Click Add SWC...
7. Browse to the mdm swc ( mdm.swc ), in BASE-INSTALL-DIR/swc/mdm.swc
8. Click OK to add the swc to the project
9. Click OK to close the properties dialog
10. Add "import mdm.*;" to the source files that need access to the mdm runtime
11. Write code and call {mdm}Script 2.0 objects as you would with Flash 8
Initializing {mdm}Script 2.0 in Flex 2 Projects
Flex coders need to add the code mdm.Application.init(this) as their first line in an initialization function for use with Zinc Windows & Mac OSX. For example:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="initApp()">
function initApp()
{
mdm.Application.init(this);
}
This is required to ensure the {mdm}Script 2.0 object is correctly initialized.
Note
For regular AS3 Projects (ie. Projects which use Flex via Command Line) a callback is also required to be passed as a second parameter. This will be called when the application has initialized. For example:
public class HelloWorldTestZinc extends Sprite
{
public function HelloWorldTestZinc(){
mdm.Application.init(this,OnInit);
}
public function OnInit():void
{
mdm.Dialogs.prompt("Hello from AS3!")
}
}
To get started with Flex2/AS3 Development, please visit http://www.multidmedia.com/support/developers/articles