-
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);
}
-
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?
-
Senior Member
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. -
-
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:
-
Senior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|