A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Help need about unloading main movie

  1. #1
    Member
    Join Date
    Nov 2007
    Posts
    83

    Help need about unloading main movie

    There are hundreds of threads on the web about unloading movie but none of them work. For example, the code below gives this error: TypeError: Error #2007:

    Code:
    var alert:Boolean=true;
    if (loaderInfo.url!="someurl") {
    	removeSwf();
    }
    var swfHolder:Loader = new Loader();
    function loadSwf(target:String):void {
    	addChild(swfHolder);
    	swfHolder.load(new URLRequest(target));
    }
    function removeSwf():void {
    	removeChild(swfHolder);
    }

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    I'm guessing 2007 is a null reference error? Because you're calling removeSwf() before loadSwf()? And it's trying to remove the loader before it's been added so it doesn't have a .parent? perhaps?

  3. #3
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Both of these should work. If you want to load a different object the former object is replaced with the new, no need to remove. If you just want to unload then use
    swfHolder.unload();
    This was buggy in earlier Flash players but is now working.


    Example 1:
    var swfHolder:Loader = new Loader();
    function loadSwf (target:String):void
    {
    if(swfHolder!=null)
    {
    removeChild(swfHolder);
    }
    addChild (swfHolder);
    swfHolder.load (new URLRequest(target));
    }

    Example 2:
    var swfHolder:Loader = new Loader();
    addChild (swfHolder);
    function loadSwf (target:String):void
    {
    swfHolder.load (new URLRequest(target));
    }
    - The right of the People to create Flash movies shall not be infringed. -

  4. #4
    Member
    Join Date
    Nov 2007
    Posts
    83
    Thanks for replies. cancerinform your both codes don't give error but they don't unload the movie even when I add swfHolder.unload()

    neznein9, I put removeSwf() in the end but this time another error occures: ArgumentError: Error #2025:

  5. #5
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Your problem lies with how you apply this code in your movie and unload will work only with upgraded Flashplayers.
    - The right of the People to create Flash movies shall not be infringed. -

Tags for this Thread

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