I am embedding a swf file into the parent swf file and my code in parent swf file want to call the function inside the embedded swf file. It always failed, below is the code. The error is in line:
var player:testflv1 = (loader.content as SystemManager).application as testflv1;
It can’t be compiled because the testflv1 is not recognized as the known type.
The code of the parent swf:
private function applicationComplete():void
{
// loader.load("http://localhost:8000/testflv1.swf");
return;
}
public function callfunction():void
{
trace("loadedCompleted.");
Alert.show('hello');
var player:testflv1 = (loader.content as SystemManager).application as testflv1;
// player.setSize(320, 240);
player.playVideo();
return;
}
protected function button1_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
callfunction();
}
]]>
</fx:Script>
<mx:SWFLoader id="loader" horizontalCenter="0" width="100%" height="362" source="http://localhost:8000/testflv1.swf"/>
<s:Button x="211" y="376" label="Button" click="button1_clickHandler(event)"/>
The code of the embedded swf:
private function applicationComplete():void
{
//var nc:NetConnection = new NetConnection();
//nc.connect(null);
//var ns:NetStream = new NetStream(nc);
//var vid:Video = new Video(320, 240);
//this.addChild(vid);
//vid.attachNetStream(ns);
//ns.play("http://www.mediacollege.com/video-gallery/testclips/20051210-w50s.flv");
svid.play();
return;
}
public function playVideo():void
{
svid.play();
return;
}
public function pauseVideo():void
{
svid.pause();
return;
}
]]>
</fx:Script>
<s:VideoPlayer id="svid" source="http://127.0.0.1:8000/jacko.flv" bottom="0" left="0" top="0" right="0"/>
swfloader is generally used to load and play a Flash movie inside a Flex app. If you want to load additional functionality at runtime you’re better off using Modules; they’re specifically designed for what you’re trying to do.