Thanks! I can't make my sprite into a bitmap, cause it needs to scale
big or small after duplication. Even if it wasn't the alpha preview and
I was just making simple graphic assets in Flash 8 to use in Flash
player 9, isn't there some way to duplicate a loaded AVM1Movie?
thanks!
ben
Muzak wrote:
Personally I wouldn't try mixing the Alpha Preview with Flex.
It's not feature complete and certain things will be quite different in FCS3.
For instance there's the "Flex Component Kit for FCS3" that makes Flex/Flash
integration ALOT easier:
http://labs.adobe.com/wiki/index.php/Flex_Component_Kit_for_Flash_CS3
AFAIK, there's no easy way to make copies of loaded swf's.
If they're nothing more than simple graphics, I'd say the easiest way to make
copies is to use the BitmapData class.
Here's an example (using mxml), where I'm loading a Flash 8 swf containing a
simple graphic (bitmap) on stage.
The swf is loaded into an Image component. Once loaded, the Image content
(AVM1Movie) is copied.
Then the new BitmapData is set as the source of another Image component.
You should be able to do the same in AS3 with the Loader class instead of an
Image component.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
private function swfCompleteHandler(evt:Event):void {
trace("Application ::: swfCompleteHandler");
trace(evt.currentTarget.content);
var t:Image = evt.currentTarget as Image
var c:AVM1Movie = t.content as AVM1Movie;
trace(" - content width: "+t.content.width);
trace(" - content height: "+t.content.height);
//
var bmd:BitmapData = new BitmapData(t.contentWidth, t.contentHeight);
// or
//var bmd:BitmapData = new BitmapData(c.width, c.height);
bmd.draw(c as IBitmapDrawable);
swfCopy_img.source = new Bitmap(bmd);
}
]]>
</mx:Script>
<mx:VBox>
<mx:Image source="f8_movie.swf" scaleContent="false"
complete="swfCompleteHandler(event)" />
<mx:Image id="swfCopy_img" />
</mx:VBox>
</mx:Application>
regards,
Muzak
----- Original Message -----
From: "ben gomez farrell" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" <[email protected]>
Sent: Friday, April 27, 2007 9:32 PM
Subject: [Flashcoders] Duplicating a movieclip/sprite in AS3
Hey everyone,
I can't seem to figure out how to duplicate a sprite in AS3. Thanks to various
tutorials online, I got so far as to take the
constructor of the sprite I want to duplicate and instantiate a new one.
var targetClass:Class = (stamp as Object).constructor;
mStamp = new targetClass() as Sprite;
This works in normal situations. However, the sprite I'm getting are SWF's
loaded at runtime. If I trace a normal asset's
constructor it will trace as [Object myasset], but no matter what I do, my
externally loaded SWF's constructors all trace as
[Object MovieClip] or [Object AVM1Movie].
So of course creating a new instance of the constructor will result in a blank,
fresh-made movieclip.
Basically my external SWFs are just some graphics on stage in one frame. I've
tried setting the document class, and publishing as
Flash 8, 9, Actionscript 2, Actionscript 3, and nothing changes. I'm not using
Flash CS3 yet, just the AS3 Alpha for making
assets and then compiling with Flex 2 SDK.
Anyone?
Thanks!
ben
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com