View Full Version : Embed AS2 clip in AS3 movie?
dakotahgirl
January 5th, 2010, 12:33 PM
Hi, I am not adept in AS3 and barely know any AS2, but is it possible to embed an AS2 movieclip within an AS3 movie? If so, how is it done? And what if the frame rates are different? I mainly use timeline and and an effects package from Jumpeye Components to produce weekly movies as I don't have a lot of time for Flash development--which produces pretty fast, and that's why I have limited knowledge at this time in AS. Thank you so much.
:}
cbeech
January 5th, 2010, 03:44 PM
I'm afraid not - you *can* 'load' a AS2 swf into an AS3 swf - but you will not be able to extract or contact any of the assets or classes running within the AS2 instance.
dakotahgirl
January 5th, 2010, 03:49 PM
Thank you for your response. =) I don't want to access anything in it, I just want it to play. Is that possible? How do I do it? Thank you.
Ziggwies
January 5th, 2010, 04:13 PM
AS2 swf files can be loaded into AS3 swf files, but I'm not sure if you can interact with the contents inside. There might be a work around using "local connection" however I haven't tried it yet.
Quick way to load swf file...
var ldr:Loader = new Loader();
ldr.load(new URLRequest("as2_filename.swf"));
addChild(ldr);
dakotahgirl
January 5th, 2010, 04:19 PM
Thank you so much! I will give this a try and see, and I'll let you know. So that's all I put in a frame where I want it to begin playing? Let's say I place the movie clip in a scene by itself; the movie has several scenes, I like to separate things that way and it serves the correct purpose. How do you tell it to go to the next scene after the movie has played?
Also, my AS3 movies are 36fpm, and this AS2 movie is 60fpm. Big problem? Frames rates need to be the same?
cbeech
January 5th, 2010, 04:35 PM
hmmm interesting (framerates) - in most cases loaded movies will take on the framerate of the parent or Loader - but when loading an AVM1 instance i'm not certain that it will - it *may* remain running under the framerate that is was published at given that it will be running under a different virtual processor - interesting, to see if it does :)
like Ziggwiez mentions one cannot make 'contact' between the two instances - unless you use LocalConnection (i'm not certain this will work within the same scope of a loaded instance, usually this is used for communication between two swf files residing within the same DOM, but it may) - so setting up event handlers or dispatchers will be difficult if operating between to two instances.
unless you are referring to scenes running within the AS3 file? but you will still have no way of knowing 'when' the AS2 movie is complete, unless the above will work with LocalConnection - it will take some doing, even just to try it out - i might suggest converting the AS2 file to AS3 - if there is no code in the AS2 version (or very little to change) it should be a simple matter to change the publish settings and produce a new AS3 swf
dakotahgirl
January 5th, 2010, 05:21 PM
Thank you, cbeech. I just heard from the person who wrote the AS2 movie symbol I bought/used, and he's created an AS3 version. However, I bet all I would have to do is have a scene (yes, in the AS3 file) and set the amount of frames in the scene needed to let the clip play in its entirety, right?
At least I'm not interested in communicating with the AS2 objects. Because of the globe file I bought, that's why I had to make it AS2. So I used AS2 script in the file, also, for some effects. Now I will see if I can implement the AS3 globe version and figure out how to change the code I wrote to AS3 to see what happens (oh joy). I think I would rather leave this one alone, though, and use the AS3 globe version for the future. So I still want to try the embedding.
If it takes on the framerate of the master AS3 movie, that wouldn't be so bad, it's only for viewing inside the agency on a large digital display screen by staff and visitors. My original project was to create a short loop about a product which would play on a large screen while all the guests for the presentation would be taking their seats. That was this morning, and I was told it was a smashing success (whew).
But now I will try the embedding as I'd like to use the file locally, as I said. It will probably be tomorrow before I have results. I will write back with problems or questions.
You two have been very helpful to me, thank you. The file I created, you may view at http://www.acjic.alabama.gov/movies/connect_intro.htm.
=)
wvxvw
January 5th, 2010, 06:26 PM
If AS2 movies don't contain any scripts, then you can simply convert them to AS3 movies... that's not to much of parsing... I even think I saw the ready made solution for that. I'll search for it and post back if I'll find it.
Anyways, you can embed any binary data in SWF9 format, so, if using SDK simply do something like:
[Embed(source="myAS2.swf", contentType="application/octet-stream")]
public class Foo extends ByteArray {
...
var bar:ByteArray = new Foo();
var fooBar:Loader = new Loader();
fooBar.loadBytes(bar);
Also, you can use SWFMill / SamHaXe for embedding.
dakotahgirl
January 5th, 2010, 06:39 PM
Thank you for this information, which gives me more to work on, and that's great. Yes, though, there is scripting in the AS2 movie. I would need to check on what the same commands are in AS3. Nothing complicated, just the Tweener alpha and _x movement commands, and some unloadMovie commands. Oh! And the duplicateMovie command.
I will check into your information, too. And I will write back, thank you again! Everyone has been so very helpful. It will be tomorrow, now, before I get to it, I've had it for the day! =)
wvxvw
January 5th, 2010, 06:47 PM
http://code.google.com/p/as3-classes/source/browse/trunk/org/lzyy/util/ForcibleLoader.as?r=6
OK, that's the library, it seems to be a bit of work in the progress, but, the author says it worked some times :D
dakotahgirl
January 6th, 2010, 11:08 AM
but, the author says it worked some times :D
Hahaha "some times." :angel:
Okay, it's a new day, and now time for me to get to work on trying some of these things.
dakotahgirl
January 6th, 2010, 12:20 PM
I’ve never seen so many “server is too busy” messages than I have on this site! LOL
wvxvw, you are beyond my knowledge of AS....wow. I found another post in the forum about converting, just out of curiosity. Senocular stated there's an online utility (because I don't run PHP) to convert classes at http://www.5etdemi.com/convert/index.php.
Do I understand correctly that if I pasted the AS2 code:
------------------------------------
import caurina.transitions.Tweener;
usmap_mc._alpha = 100;
Tweener.addTween(usmap_mc, {_alpha:0, time:2.5});
and got the below, is that syntactically correct for AS3?
package {
import caurina.transitions.Tweener;
usmap_mc.alpha = 100;
Tweener.addTween(usmap_mc, {alpha:0, time:2.5});
}
-----------------------------------------
OR, pasted in this code:
-----------------------------------------
import caurina.transitions.Tweener;
var i = 1;
i = i + 1;
duplicateMovieClip (_root.map1_mc, "map2_mc", i);
Tweener.addTween(map2_mc, {_x:-900, time:13, transition:"easeInOutSine"});
And got this (I tried a loop, but I could only get the first duplicate map to show, so I did a "creative" solution):
package {
import caurina.transitions.Tweener;
import flash.display.MovieClip;
var i = 1;
i = i + 1;
duplicateMovieClip (_root.map1_mc, "map2_mc", i);
Tweener.addTween(map2_mc, {x:-900, time:13, transition:"easeInOutSine"});
}
------------------------------------------------------
If so, I can switch out the AS2 globe for the AS3 globe, and then take my few scripts and run them through the online utility, and change my file to AS3. And that would solve my problem, if such is correct, right?:look:
wvxvw
January 6th, 2010, 01:04 PM
Well, I don't think you may convert AS2 to AS3 that easily... But, if those AS2 SWFs already exist... I'd go with the [Embed] option, I think it is also available in Flash CS4.
Well, if it's not an option then I think that downloading the SDK + some free AS editor would be the way to go.
dakotahgirl
January 7th, 2010, 06:10 PM
Well, I don't think you may convert AS2 to AS3 that easily...
No, you can't, I was wrong, it was some converter for classes. I don't understand about packages, where do I put them, in separate files? I can't figure out so far yet how to just do this simple little command in AS3:
duplicateMovieClip (_root.map1_mc, "map2_mc",2i);
A tip of the day addressed the matter, but I am not understanding it. I'm trying to just convert the movie from AS2 to AS3 and not embed, now, since I have the AS3 version of the clip which was forcing me to do AS2 in the first place. The tip of the day I'm referencing is at:
http://www.kirupa.com/forum/showthread.php?p=1939827
Can anyone send me in the right direction? Oh, and what AS editor is recommended (I normally script ColdFusion and am a graphic design artist)?Thank you.
wvxvw
January 8th, 2010, 07:59 AM
Well, duplicateMovieClip() doesn't exist in AS3, and there isn't a way to completely replicate it in AS3. In some simple cases you can just create a new clip, or, if it was a separate SWF, load it one more time. But if the clip had created children based on some runtime conditions, then, unless you have designed a cloning function that would go and check the changes it needs to do to the clone, then, there isn't a way to do that.
Example:
var clip:MovieClip = new SomeLibrarySymbol();
var clipCopy:MovieClip = new SomeLibrarySymbol();
or
var clone:MovieClip;
var loader:Loader = new Loader();
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.loadBytes(someLoadedSWF.loaderInfo.bytes);
function completeHandler(event:Event):void
{
clone = loader.content as MovieClip;
}
dakotahgirl
January 8th, 2010, 12:53 PM
Yeah, you spoke some English I could understand this time! :rabbit: I was trying to read about clone, as I also read there is no duplicate movieClip function in AS3 (why??). It is not a separate swf, it is just a symbol defined as a movieclip. But I could put the Tweener _x movement in the symbol, and just make it a new clip, right? Or a separate swf? (I need 3 world maps moving left across the stage synced just right). Again, the URL to see the movie I'm talking about is:
http://www.acjic.alabama.gov/movies/connect_intro.htm
Which method is simpler and easier for me to understand? And thank YOU! You are being very helpful and patient with me, and I appreciate it very much. I have no one to talk to here at my agency, as I'm the only graphic designer and Flash movie maker LOL, and I don't have any connections I know in other state agencies who work in the area except one, and I would need to strike up a friendship with him if he's willing (we're rival competitors, basically). So your assistance is so much appreciated, I would be glad to buy you a beer or 6 if you were here! :tini:
wvxvw
January 8th, 2010, 03:27 PM
Thanks for good intentions :)
The server at www.acjic.alabama.gov is taking too long to respond.
... FF says it's not there.
And, well, if that's a symbol in the library and you're using Flash IDE, then, open symbol properties from the library panel, select export for ActionScript, give it some class name. You'll see it will be derived from flash.display.MovieClip (if that was the symbol's type), however, you may change that to flash.display.Sprite, if the clip has only one frame.
After you close the dialog box, it'll prompt you to agree to automatically generate the class you just assigned to this symbol (some times you would want to use your own class instead of the generated one). Flash generates those classes at compile time, so, you cannot see what was created, but, essentially it's just a dummy class that extends some of the classes that are allowed to link to the asset symbols.
Now, say you called the class MyClass and extended it from MovieClip, you can do this:
var mc:MovieClip = new MyClass();
this.addChild(mc);
mx = new MyClass();
this.addChild(mc);
You have created the same clip twice and added it to the stage twice. In this particular case it will do the same as
var mc:MovieClip = this.attachMovie("MyClass", "mc", this.getNextHighestDepth());
Object.registerClass("mc", MyClass);
mc = duplicateMovieClip(mc);
Well, could be my AS2 is a bit rusty :)
dakotahgirl
January 12th, 2010, 12:38 PM
wvxvw,
Oh my intentions are true! =)
You may want to give the url another try, I have no knowledge of the server being down, it must have been something outside our network.
Now, I believe I'm understanding you. Yes, the movie clip symbol has only one frame. What is the technical difference between Sprite and MovieClip, if I may ask a dumb question?
I will try your approach and see if I'm successful....so when I create a second and third instance (oh yeah, how do I do a loop in AS3 to create 2 or 3 copies?), do I need to give them beginning _x and _y coordinates? I might start to get myself confused again here....I'm also dealing with 2 computers giving me problems; an IDE drive went out on one, so I'm copying files to another location before the whole thing dies, and having to copy files from the second machine to the same location so a new OS can be placed on it (Vista STINKS, IMHO), then run Window 7s and have a virtual XP machine on it, too, and I'll be back down to 1 computer. So it's hard to keep my concentration on just one thing right now.
Again, thank you so much.:}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.