-
Convert AS3 to AS2
I have a working movie file that I built using AS3. Problem is that I want to call an external swf file written in AS2. Particularly it is a quiz file created using the templates in flash cs3. Since the quiz is AS2 and my main file is AS3 I've been having problems loading the quiz file externally in the main fla file. So what would be the easiest way to make it work? Convert my AS3 file to AS2 and then load the file externally and hope that it will work? Or is there an easier way for what I want to do? The ideal would be to have my quiz file in my main FLA file on the click of a button.
Any help is appreciated.
Thanks in advance,
Theo
-
OOP is one letter from OOPS
Not sure about easy, but the way most people communicate between AS 3 and AS 2 movies is through a localConnection.
-
Maybe you could instruct me on how to use localConnection? I just started using flash couple of weeks ago and I'm not familiar with Actionscript yet. Most of my coding was pasted and modified.
Thanks again.
-
Here's a link to Grant Skinner's swfBridge class - it's designed for exactly this problem.
-
Thanks for the link, I will see it as soon as I get home.
- Theo
-
Can I follow the method described in the website locally? I get an error as soon as I paste the code into my files.
-
Just to make it clearer, I don't want to load any functions. Just literally load the as2 file on top of everything on the as3 project on click of a button and be able to unload it again with the click of a button.
Hope that makes sense.
-
If you don't ever need to communicate with the as2 swf you can just use this...example:
PHP Code:
import com.calypso88.SWF;
var mySWF:SWF = new SWF('http://calypso88.com/tester.swf');
but1.addEventListener(MouseEvent.CLICK, addSWF);
but2.addEventListener(MouseEvent.CLICK, remSWF);
function addSWF(e:MouseEvent):void{
addChild(mySWF);
}
function remSWF(e:MouseEvent):void{
removeChild(mySWF);
}
-
OK I found this code and made it work with one problem. When the frame is called by the button the as2 swf loads up properly and you can start taking the quiz. After the second question though it stops loading for some strange reason. Here is the code I used.
I inserted this in the AS3 file:
PHP Code:
// ActionScript 3 file, AS3Loader.fla
// local connection instance to communicate to AVM1 movie
var AVM_lc:LocalConnection = new LocalConnection();
// loader loads AVM1 movie
var loader:Loader = new Loader();
loader.load(new URLRequest("quiz.swf"));
addChild(loader);
// when AVM1 movie is clicked, call stopPlayback
loader.addEventListener(MouseEvent.CLICK, stopPlayback);
function stopPlayback(event:MouseEvent):void {
// send stopAnimation event to "AVM2toAVM1" connection
AVM_lc.send("AVM2toAVM1", "stopAnimation");
}
and this into the AS2 file:
PHP Code:
// ActionScript 2 file, AS2animation.fla
// one movie clip animation named animation_mc on the timeline
// local connection instance to receive events
var AVM_lc:LocalConnection = new LocalConnection();
// stopAnimation event handler
AVM_lc.stopAnimation = function(){
animation_mc.stop();
}
// listen for events for "AVM2toAVM1"
AVM_lc.connect("AVM2toAVM1");
Any ideas why this problem?
-
wow
Exactly what I was looking for!
Thanks!
-
Does the code work for you perfectly? What are you doing with it exactly? I can't get this solved, it's so weird. The file loads and then after first quiz question I cannon click on the "next" arrow anymore which makes my quiz unable to move to the next question.
These are my files. Check them out if you like:
http://www.hiphop.com.cy/decayer/elearning/quiz.fla
http://www.hiphop.com.cy/decayer/elearning/lab-2.fla
-
-
I'm having the same problem: I have several AS2 games that I want to be able to call from an AS3 swf.
I tried calypso88, and I get the following error:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::AVM1Movie@307649e9 to flash.display.MovieClip.
at MethodInfo-62()
and even though the loaded .swf file started executing, it stopped almost immediately (it went into an infinite loop). This, of course, does not happen when I run the loaded swf by itself or when I call it from an AS2 swf.
What am I doing wrong?
Mariana
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|