2008/10/27

how to pass variables from loading swf to loaded swf?

parent/loading swf:
package{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
public class LoadingSWF extends Sprite{
private var loader:Loader = new Loader();

public function LoadingSWF (){
loader.contentLoaderInfo.addEventListener( Event.INIT, onLoaderInit );
loader.load( new URLRequest( "ExampleB.swf" ) );
}

private function onLoaderInit( event:Event ):void
{
Object( loader.content ).init( "passing" );
}
}
}
/*=======================================*/
child/loaded swf:
package{
import flash.display.Sprite;
public class LoadedSWF extends Sprite{
public function LoadedSWF (){
}
public function init( value:String):void{
trace(value);
}
}
}

2008/10/05

How to See Your AS Code in Flex

Anatomy MXML tag:
//================================================================//
example codes:< id="'btn'" label="Click Me" cornerradius="20" onclick="'....'">
//================================================================//
Tags are Classes: 
import mx.controls.Button; btn:Button=new Button(); addChild(btn);
Attributes are properties:
btn.label='Click Me';
Attributes are styles:
btn.setStyle("cornerRadius", 14);
Attributes are Event Listeners
btn.addEventListener('onclick',someFunction);
//================================================================//

MXML is great for laying out structure, and ActionScript is built for interactivity. In this sample, you see that MXML markup is actually turned into ActionScript by the Flex compiler. Like ColdFusion Meta-Language(CFML) is html-based language transfer java background.

your MXML tag could transfer *.as files in your Flex project by following steps.

First, you open dialog by project>properties.
Second, choose additional compiler arguments under Flex Compiler. then add -keep or  -keep-generated-actionscript parameter at compiler parameters (spearte parameter by space). save the setting.
you could see all *.as used in your project right now in your src/generated folder in Flex Navigator panel.