-
Targeting a loaded swf
Hi all
1. I'm loading an external swf onto my main swf.
2. Then I'm tweening an object which is separate to the loaded swf.
3. When the tween has completed I'm calling a function to make the loaded swf gotoAndPlay(2);
It all works apart from telling my loaded swf to play. I'm really stuck please help.
The code which I'm using is:
//
import caurina.transitions.Tweener;
//load swf
var externalSwf:Object;
this.myRequest=new URLRequest("orange.swf");
this.myLoader = new Loader();
this.myLoader.contentLoaderInfo.addEventListener(E vent.COMPLETE, grabContent);
this.myLoader.load(this.myRequest);
//tween object
function grabContent(event:Event):void {
externalSwf=event.target.content;
Tweener.addTween(banana, {x:-900, time:1, transition:"easeInCubic", onComplete:nextBuild});
}
//control loaded swf
function nextBuild() {
externalSwf.gotoAndPlay(2);
}
stop();
-
Are you getting an error?
-
Not getting any errors. I've used trace(); to confirm that each part is working. It's just not perfoming that last request.
-
So the nextBuild function is not executed or it is but the externalSwf.gotoAndPlay(2); is not executed?
-
externalSwf.gotoAndPlay(2); is not being executed. The function is working as I have a confirmed trace. I can send you the flash files if want to see in detail. Thanks
-
Post them here so others can have a look too.
-
Here are all the files
example
-
You need to add the Loader to the Displaylist:
var myRequest:URLRequest = new URLRequest("orange.swf");
var myLoader:Loader = new Loader();
myLoader.contentLoaderInfo.addEventListener (Event.COMPLETE, grabContent);
myLoader.load (this.myRequest);
addChild(myLoader);
-
Thanks for your help cancerinform
The working code is as follows, if anyone needs the files contact me and I will send them on.
//import for the tween
import caurina.transitions.Tweener;
//load the external swf
var externalSwf:Object;
var myRequest:URLRequest=new URLRequest("orange.swf");
var myLoader:Loader = new Loader();
myLoader.contentLoaderInfo.addEventListener(Event. COMPLETE, grabContent);
myLoader.load(this.myRequest);
addChild(myLoader);
//when the swf is loaded, the tween is initiated
function grabContent(event:Event):void {
trace("swf has been loaded");
externalSwf=event.target.content;
Tweener.addTween(banana, {x:-900, time:1, transition:"easeInCubic", onComplete:nextBuild});
}
//when the tween is complete, play the swf
function nextBuild() {
trace("the tween has completed and has initiated the nextBuild function");
externalSwf.gotoAndStop(2);
}
stop();