FORUMS: list search recent posts

errors occur when unloading external swf....

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
dean chapman
errors occur when unloading external swf....
on May 22, 2010 at 10:38:27 pm

Hi guys,

I have a Main.swf which has some buttons, each loading a swf.
I have one button with an instance name of b2, which when you push it loads a swf named b2.swf.
b2.swf just has a simple movie clip (with an instance name of "vice") on stage, with some tweener animation.
When i click b2 (on the Main.swf) it loads the b2.swf just fine.....but when i click on a different button (which is supposed to unload b2.swf and load a different swf in it's place), i get this message in the output:

## [Tweener] Error: [object MovieClip] raised an error while executing the 'onComplete'handler.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at b2_fla::MainTimeline/mover()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at caurina.transitions::Tweener$/updateTweenByIndex()
at caurina.transitions::Tweener$/updateTweens()
at caurina.transitions::Tweener$/onEnterFrame()

I also tried linking a different button (b4) to another external swf containing Papervision3d objects/animation and i get a similar Error#1009. It seems like the swf's are not being completely unloaded when they are supposed to....i dunno....any suggestions? thanks!

Here's my code for the Main.swf

import flash.media.SoundMixer;


function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = Math.ceil(perc*100).toString();
}

function done(e:Event):void
{
percent.text = "";
addChild(loader);
}


b1.myText.text = "cool";
// Btn1 Over function
function b1Over(event:MouseEvent):void {
b1.gotoAndPlay("over"); // go into btn1 movieclip and play the over frame label
b1.myText.text = "cool";
}
// Btn1 Out function
function b1Out(event:MouseEvent):void {
b1.gotoAndPlay("out"); // go into btn1 movieclip and play the out frame label
b1.myText.text = "cool";
}

// Btn1 listeners
b1.addEventListener(MouseEvent.ROLL_OVER, b1Over);
b1.addEventListener(MouseEvent.ROLL_OUT, b1Out);

b2.myText.text = "rad";
// Btn1 Over function
function b2Over(event:MouseEvent):void {
b2.gotoAndPlay("over"); // go into btn1 movieclip and play the over frame label
b2.myText.text = "rad";
}
// Btn1 Out function
function b2Out(event:MouseEvent):void {
b2.gotoAndPlay("out"); // go into btn1 movieclip and play the out frame label
b2.myText.text = "rad";
}

// Btn1 listeners
b2.addEventListener(MouseEvent.ROLL_OVER, b2Over);
b2.addEventListener(MouseEvent.ROLL_OUT, b2Out);

b3.myText.text = "awesome";
// Btn1 Over function
function b3Over(event:MouseEvent):void {
b3.gotoAndPlay("over"); // go into btn1 movieclip and play the over frame label
b3.myText.text = "awesome";
}
// Btn1 Out function
function b3Out(event:MouseEvent):void {
b3.gotoAndPlay("out"); // go into btn1 movieclip and play the out frame label
b3.myText.text = "awesome";
}

// Btn1 listeners
b3.addEventListener(MouseEvent.ROLL_OVER, b3Over);
b3.addEventListener(MouseEvent.ROLL_OUT, b3Out);

b4.myText.text = "tubular";
// Btn1 Over function
function b4Over(event:MouseEvent):void {
b4.gotoAndPlay("over"); // go into btn1 movieclip and play the over frame label
b4.myText.text = "tubular";
}
// Btn1 Out function
function b4Out(event:MouseEvent):void {
b4.gotoAndPlay("out"); // go into btn1 movieclip and play the out frame label
b4.myText.text = "tubular";
}

// Btn1 listeners
b4.addEventListener(MouseEvent.ROLL_OVER, b4Over);
b4.addEventListener(MouseEvent.ROLL_OUT, b4Out);

// DevelopPHP loaders
var Xpos:Number = 110;
var Ypos:Number = 180;
var swf:MovieClip;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
var defaultSWF:URLRequest = new URLRequest("b1.swf");

loader.load(defaultSWF);
loader.x = Xpos;
loader.y = Ypos;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Btns Universal function
function btnClick(event:MouseEvent):void {

SoundMixer.stopAll();
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, loop);
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, done);

try{
removeChild(loader);
}
catch(e:Error){
//
}

try{
loader.close();
}
catch(e:Error){
//
}

try{
loader.unload();
}
catch(e:Error){
//
}

loader = null;

var newSWFRequest:URLRequest = new URLRequest(event.currentTarget.name + ".swf");

loader = new Loader();

loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);

loader.load(newSWFRequest);
loader.x = Xpos;
loader.y = Ypos;

}



// Btn listeners
b1.addEventListener(MouseEvent.CLICK, btnClick);
b2.addEventListener(MouseEvent.CLICK, btnClick);
b3.addEventListener(MouseEvent.CLICK, btnClick);
b4.addEventListener(MouseEvent.CLICK, btnClick);

////////
and this is my code for the b2.swf:


stop();
import caurina.transitions.*;

function mover()
{
Tweener.addTween(vice, {x:Math.random()*stage.stageWidth,
y:Math.random()*stage.stageHeight,
time:1, rotation:Math.random()*500, onComplete:mover,
transition:"easeOutElastic"})
}
mover();


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]