There are a few tutorials out there on how to build a complete website in AS3. However, these only deal with mostly loading either a static image, or loading an swf file without manipulating it’s timeline. I’ve found a couple that show how to unload previous swf’s and load new ones depending on the button being clicked.
However, none of these tutorials show how to control the timeline of an embedded swf.
Here’s what I’m trying to do:
[LIST]
[]i created three buttons and a container movieclip on a main.swf
[]each button calls an external swf
[]when a button is clicked, an external swf gets loaded into the container movieclip on the main timeline
[]the loaded swf plays an “intro” animation on it’s own timeline, then stops at a certain frame
[]when another button is clicked, the loaded swf plays an “outro” animation on it’s own timeline until it encounters a “stop” frame
[]once the “outro” animation is finished playing, the current loaded swf gets unloaded, and the new swf that was called by the button that was clicked gets loaded instead
[*]with each new button click, the cycle repeats anew…
[/LIST]
Below is my code so far…
var Xpos:Number = 146;
var Ypos:Number = 80;
var swf:MovieClip;
var loader:Loader = new Loader();
var defaultSWF:URLRequest = new URLRequest(“swf_files/home.swf”);
loader.load(defaultSWF);
loader.x = Xpos;
loader.y = Ypos;
addChild(loader); //adds loader to display list
// create a Universal Button Function
function btnClick(e:MouseEvent):void {
var timeline = MovieClip(loader.content);
timeline.gotoAndPlay(“outro”);
removeChild(loader);
var newSWFRequest:URLRequest = new URLRequest(“swf_files/” + e.target.name + “.swf”);
loader.load(newSWFRequest);
loader.x = Xpos;
loader.y = Ypos;
addChild(loader);
}
//Button Listeners
home.addEventListener(MouseEvent.CLICK, btnClick);
profile.addEventListener(MouseEvent.CLICK, btnClick);
contact.addEventListener(MouseEvent.CLICK, btnClick);
If there’s anyone out there who’s figured this out, PLEASE let me know…I’ve spent too many hours trying to figure this out and I’ve got management breathing down my neck…Thanks in advance for any help anyone can afford…