Flex SWFLoader结合Canvas加载swf文件

摘要

Flex SWFLoader结合Canvas加载swf文件

public class PagesUtil
{
    public function PagesUtil()
    {
    }
    public  static var menuId:String;
    [Bindable]
    public static var canvas:Canvas;
    [Bindable]
    private var swf:SWFLoader;
    public function getUrl(urls:String):void{
        swf=new SWFLoader();
        var lc:LoaderContext = new LoaderContext();
        lc.applicationDomain = ApplicationDomain.currentDomain;
        swf.loaderContext = lc;
        swf.unloadAndStop(true);
        swf.scaleContent= true;
        swf.percentWidth = 100;
        swf.percentHeight = 100;
        swf.addEventListener(IOErrorEvent.IO_ERROR, IoError);
        swf.source=urls;
        canvas.addChild(swf);
    }
       
    public static function closeCV():void{
        canvas.removeAllChildren();
    }
       
    private function IoError(event:IOErrorEvent):void{
        var str:String = "page_404.swf";
        getUrl(str);
    }
       
    public function getMenuId():String{
        return menuId;
    }
}


IT家园
IT家园

网友最新评论 (0)