ok so im bringing in a test external swf like so:
var loader:Loader = new Loader();
var url:URLRequest = new URLRequest("load2.swf");
loader.load(url);
addChild(loader);
Now im trying to envoke a goto and play like so:
var loaded:Object;
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleLoaded);
function handleLoaded(e:Event):void {
loaded = e.target.content;
}
load1.addEventListener(MouseEvent.CLICK, handleClick);
function handleClick(e:MouseEvent):void {
if (loaded) {
loaded.gotoAndPlay("outro");
}
//other content here.
}
this simple external test swf has 10 frames. @ frame 1 theres a “intro” label, @ frame 5 theres a “stop” action, and on frame 6, theres an “outro” label.
problem is that, when i click the button, it reloads the external swf and plays from frame 1.
any ideas/tips/hints etc id gladly appreciate.
thanks in advance.
Try casting
loadedas a MovieClip:Ok, so that didn’t fix it…
Without seeing more of the application it’s hard to say more, because the code provided works fine on it’s own. If this code is on a timeline, it might be worth putting a trace in alongside the load operation to see if the parent playhead is replaying.
A ha
I believe I’ve solved it. The issue is coming from the presence of the TLF text in load2.swf. I proved this by creating my own version of load2 without any TLF text, and this worked fine with your eerase.fla. When I added a TLF textfield to my load2, it started to show the behaviour you’re experiencing. So the fix is simply to not use TLF textfields in any loaded SWF. I have tested using classic textfields with no issue.
The reason this occurs is because TLF textfields require to load data, and so it creates an artificial preloader that loads in your content. When you issue a gotoAndPlay action, you are in fact talking to this preloader, not the timeline you created, and the consequence is that the preloader ‘loads’ another copy of your content. This is not an actual HTTP request as the content is all inside load2.swf, hence nothing appearing in Firebug’s Net panel. You can see more clearly what is being created by decompiling one of your SWF’s.