I have a project I've been working on that, when properly coded, has a "main menu" with 4 "doors" (buttons). When the corresponding buttons to these "doors" are clicked, it should go to and play an external .swf file. If that doesn't make sense, think of a DVD menu. You click play movie, it plays the movie. When the movie is over, there's two buttons on that swf file to either play the movie over or go back the main menu, which is an external .swf file (Remember, we go to the movie from the menu, which is a seperate file). So far, the buttons work. The menu works. However, from the movie, at the conclusion, when I click the button to go back to the main menu, it displays the movie clip and the buttons, but none of the buttons work. I'm starting to think it has to do with the fact the main menu was written in AS3 and the movie was made in AS2. If anyone can assist me in being to able to keep both files and still navigate between the two, being able to bring up the menu from the movie and be able to play the movie again, and so on and so on, that'd be GREAT. I'm somewhat of a noob to Flash, but I learn quickly and I'm open to any suggestions. Here's the code for main menu, which I guess acts as the parent file, and the movie. If I get this to work, I essentially would duplicate the same actions for the other 4 doors, once I complete the environments for them. Thanks
Main.Fla/Swf (written in AS3)
(This is the action on the first frame, that has all the buttons. For this question, I'm just trying to properly code for 'Door4', which is the "door" to the movie.)
import flash.display.Loader;
stop();
var myLoader1:Loader=new Loader ();
Door4.addEventListener(MouseEvent.CLICK, jayzSwf);
function jayzSwf(myevent1:MouseEvent):void
{
var myURL1:URLRequest = new URLRequest("jayzspeaks.swf");
myLoader1.load(myURL1);
addChild(myLoader1);
myLoader1.x = 0;
myLoader1.y = 0;
}
Movie.Fla/Swf (written in AS2)
(This is action on the button that returns to the menu)
on (release) {
this.createEmptyMovieClip("container",this.getNextHighestDepth() );
container.loadMovie("main.swf");
}
AS2 and AS3 do not play together nicely, they're 2 different virtual machines. Here's some code that can make the bridge a little easier but overall is there a chance the AS2 can just be rewritten to AS3?
At least you're going in the correct (mis)direction. You have AS3 loading AS2. So that's not a huge hurdle.
I believe all you really need to do is send your Main.swf a signal that the content it loaded (e.g. jayzspeaks.swf) is done and you want to get rid of it.
The code I pointed you to asks you to (upon download and import then) instantiate it in both AS2 and AS3. They give a very simple easy to understand line of code.
// as2, load this in jayzspeaks.swf
var myBridge:SWFBridgeAS2 = new SWFBridgeAS2("connectionID", clientObj);
// as3, load this in main.swf
var myBridge:SWFBridgeAS3 = new SWFBridgeAS3("connectionID", clientObj);
Make sure the connectionID matches between them. Set it to whatever you want.
When you're done with your as2 loaded content you'd send a signal (over localconnection) back to the AS3 Main like they say:
myBridge.send("someFunctionToUnloadContent");
myBridge.close();
You'd need to make the as3 function "someFunctionToUnloadContent()" (example purposes only name) and it should unload the jayzspeaks.swf that was loaded in the loader.
Make sure you get that close in there so you don't drill up a bunch of localconnection objects just like the simple source code says.
What I just said above. The as2 should go in your as2 file in a frame script to initialize it right away. Same with as3. When you want to unload the AS2 you do the .send() command from the AS2 file to tell the AS3 file you're done. Make sure the function you specify in .send() exists in AS3. In my example I named it "someFunctionToUnloadContent()". That function in the as3 Main should know that "whatever" is currently loaded needs to get unloaded.
North America
Europe, Middle East and Africa
Asia Pacific