Call function from Flex to Flash
How to call a flash function from flex?
- Load the AS3 swf file using an instance of SWFLoader.
- Call the function like this:
mySWFLoader.content.functionName();
How to listen for flash events from flex?
- // In your Flex app
/* called when your SWFLoader finishes loading the SWF */
private function onMySWFLoaded( p_event:Event ) :void
{
mySWFLoader.content.addEventListener( “clicked”, onSWFClick );
}/* callback for the clicked event */
private function onSWFClick( event:Event ) :void
{
mx.controls.Alert.show( ‘Click event raised!’ );
} - // In Flash Movie
/* called when the button in your flash movie is clicked */
private function onButtonClick( p_event:Event ) :void
{
dispatchEvent( new Event( “clicked” );
}
How to call a flex function from flash at a specific frame?
Embed(source=“../assets/swf/myFlashComponent.swf”, symbol=“Preloader”)]
private var FlashPreloaderSymbol:Class;
private var clip:MovieClip;
clip = new FlashPreloaderSymbol();
addChild(clip);
private function onFlexInitComplete( event:FlexEvent ):void
{
clip.addFrameScript(47, callMyFunction);
}
Categories: Adobe Flash, Adobe Flex & AIR, Design call, communication, comunication, Flash, flex, function
hi.. i have flash cs3 swf and i loaded that swf in flex through swfloader..
i wrote event for clicking in swf its working good… but i cannot call particular symbol of the swf in flex ..its show the following error while using symbol in loader….
“unable to resolve ‘/babyadop.swf’ for transcoding”
This is because you are not allowed to address/access stage variables.