lundi 26 septembre 2016

Resize and load External SWF in full screen using AS3 in AIR

I'm noob at programing and I'm working with Flash Pro to develop an APP for android, and I have a problem to resize an external SWF to be displayed in full screen in left. First thing in my *.Fla project I have a button in "Scene 1" that can run a "Scene 2" using this code:

    stop()
    play_btn.addEventListener(MouseEvent.CLICK, play_SWF);
    function play_SWF(event:MouseEvent):void
    {
    gotoAndPlay(1,"Scene 2");   
    }

The "Scene 2" should resize and display the external SWF in full screen and this is the code I'm trying:

    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.display.Loader;
    stop()
    var swfLoader = new Loader();
    var urlReq: URLRequest = new URLRequest("myfile.swf");
    stage.displayState = StageDisplayState.FULL_SCREEN;
    stage.align = StageAlign.LEFT;
    swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoadComplete);
    swfLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, swfLoadError);
    swfLoader.load(urlReq);
    function swfLoadComplete(evt: Event): void {
    var loader: Loader = Loader(evt.target.loader);
    add hold(loader.content);
    swfLoader.width = stage.stageWidth;
    swfLoader.height = stage.stageHeight;
    swfLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, swfLoadComplete);
    }
    function swfLoadError(evt: IOErrorEvent): void {
    trace("Unable to load swf ");
  swfLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, swfLoadError);
    }

The problem is that the external flash file displayed small in the top left of stage. Please can someone help :/

Aucun commentaire:

Enregistrer un commentaire