A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Problems with AS3

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    16

    Problems with AS3

    Hi, I have a question,

    I'm using AS3 to load an swf inside a swf using this code.

    var my_Loader:Loader = new Loader();
    var my_url:URLRequest=new URLRequest("example.swf");

    my_Loader.contentLoaderInfo.addEventListener(Event .COMPLETE, finishLoading);
    my_Loader.contentLoaderInfo.addEventListener(IOErr orEvent.IO_ERROR, errorHandler);

    my_Loader.load(my_url);


    function finishLoading(loadEvent:Event) {
    addChild(loadEvent.currentTarget.content);
    }

    function errorHandler(errorEvent:Event):void {
    trace("file missing");
    }


    Now everything work great but what I want is once the "example.swf" is loaded the user can click a button inside the "example.swf" and this swf close so I can navigate in the first swf.

    I tried adding

    import flash.display.StageScaleMode;

    stage.scaleMode = StageScaleMode.NO_SCALE;

    stop();

    btn_sol.addEventListener(MouseEvent.MOUSE_DOWN, sol01);

    function sol01(e:MouseEvent){

    ExternalInterface.call("closeBrowserWindow");

    }


    and also fscommand("quit");


    but it didnt work...

    any ideas?

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Posts
    106
    If I understand your application, and how you are adding the example swf... then you would not want to use external interface and close the browser window. You would just want to remove the Loader from the display list inside of flash.

    You would do this by calling removeChild(my_Loader);

    if you are writing the code from inside the example.swf you would need something like this
    function that tells your button to close{
    if(parent is Loader){
    MovieClip(this.parent.parent).removeChild(this);
    }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center