Flex:调用嵌入式swf函数仍然失败,求助!

时间:2009-12-23 03:22:54

标签: flex actionscript

我将swf文件嵌入到父swf文件中,而我在swf文件中的代码想要调用嵌入式swf文件中的函数。它总是失败,下面是代码。错误符合:

var player:testflv1 =(loader.content as SystemManager).application as testflv1;

无法编译,因为testflv1未被识别为已知类型。

父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)"/>
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)"/>

嵌入式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"/>

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"/>

1 个答案:

答案 0 :(得分:1)

swfloader通常用于在Flex应用内加载和播放Flash电影。如果要在运行时加载其他功能,最好使用模块;它们专门针对您的目标而设计。