Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-17-2009, 11:03 PM   #1
kdk
Registered User
 
Join Date: Nov 2009
Posts: 17
Default Calling one swf to replace another

I have a main.swf with 13 nav buttons. Each calls up a different swf via this code:

var req:URLRequest = new URLRequest("scene1.swf");
var loader:Loader = new Loader();

loader.load(req);
addChild(loader);

That works fine.

The problem is after each swf plays I need a back button to take you back to main.swf ("home" frame label). Anyone have AS3 code for this? Bless you!!
kdk is offline   Reply With Quote
Old 11-18-2009, 03:43 AM   #2
titanag
Member
 
Join Date: Oct 2009
Location: salem, oregon
Posts: 64
Default

Make a button on your stage.

ActionScript Code:
button.addEventListener(MouseEvent.CLICK, goHome, false, 0, true);//use weak references! function goHome(evt:MouseEvent) : void { //same code as loading you've got there, only going to main }

Last edited by titanag; 11-18-2009 at 03:43 AM. Reason: forgot as tags
titanag is offline   Reply With Quote
Old 11-18-2009, 04:16 AM   #3
kdk
Registered User
 
Join Date: Nov 2009
Posts: 17
Default Thanks titanag

It said "statement must appear within an on handler" in ref to this line:

button.addEventListener(MouseEvent.CLICK, goHome, false, 0, true);

And said "the class or interface 'mouse event' could not be loaded" in reference to this line:

function goHome(evt:MouseEvent) : void

I tried switching my settings to AS3 in case that was problem (my main is in AS3). And got this error:

WARNING: The component 'MediaPlayback' requires ActionScript 2.0.
WARNING: Actions on button or MovieClip instances are not supported in ActionScript 3.0. All scripts on object instances will be ignored.
kdk is offline   Reply With Quote
Old 11-18-2009, 04:18 AM   #4
titanag
Member
 
Join Date: Oct 2009
Location: salem, oregon
Posts: 64
Default

Ahh, well, that's a big problem there. AS2 and AS3 don't play nicely together. Stick with one or the other.

As for the "could not be loaded" - did you import the events package?
titanag is offline   Reply With Quote
Old 11-18-2009, 07:06 PM   #5
kdk
Registered User
 
Join Date: Nov 2009
Posts: 17
Default Did you import the events package?

I must not have because i have no idea what that means.

Is the code you gave me AS2 or 3? I can switch to either. The only code in the whole site is A) loading of external swf's, and B) This back button to take me back to main.swf.

Sorry I'm lame. I'm on lynda.com trying to learn...it's quite random teaching's though.
kdk is offline   Reply With Quote
Old 11-18-2009, 07:30 PM   #6
dimpiax
Senior Member
 
dimpiax's Avatar
 
Join Date: Mar 2008
Location: Ukraine, Kiev
Posts: 113
Send a message via Skype™ to dimpiax
Default

Remove loaded swf or stop all processes in it and hide it.
Result: you see main.swf
dimpiax is offline   Reply With Quote
Old 11-18-2009, 07:55 PM   #7
titanag
Member
 
Join Date: Oct 2009
Location: salem, oregon
Posts: 64
Default

if you wish to use libraries, you must first import the files (at the top of the class/package/file). In this case, you wish to use the MouseEvent library, so you must import it. Ex. import flash.events.*;

Oh and all of my code is in as3.
titanag is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:27 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.