Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rating: Thread Rating: 5 votes, 5.00 average. Display Modes
Old 08-02-2006, 09:27 PM   #1
csdstudio
Registered User
 
Join Date: Jun 2005
Posts: 145
Default What happened to duplicateMovieClip()

So now that duplicateMovieClip is gone, how can we duplicate a Sprite? It would seem that this great feature is gone with the wind.
csdstudio is offline   Reply With Quote
Old 08-02-2006, 09:37 PM   #2
senocular
six eyes
 
senocular's Avatar
 
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,784
Send a message via ICQ to senocular Send a message via AIM to senocular Send a message via MSN to senocular Send a message via Yahoo to senocular
Default

Basically, you just create a new instance of the sprite using its class (whether it be Sprite or a subclass) and copy over transformation information (just assign transform property to the transform of the original object). That pretty much gives you a direct duplication outside of code placed on the object in the IDE (which was retained in AS1/AS2 but no longer applies to AS3) and dynamic drawings. Dynamic drawings is a little more tricky since that would have to be done over from scratch, but thats about the only thing that has changed (not counting the transform reassignment, but thats minimal)
__________________
(6)
senocular is offline   Reply With Quote
Old 08-03-2006, 04:13 AM   #3
csdstudio
Registered User
 
Join Date: Jun 2005
Posts: 145
Default

Quote:
Originally Posted by senocular
Basically, you just create a new instance of the sprite using its class (whether it be Sprite or a subclass) and copy over transformation information (just assign transform property to the transform of the original object). That pretty much gives you a direct duplication outside of code placed on the object in the IDE (which was retained in AS1/AS2 but no longer applies to AS3) and dynamic drawings. Dynamic drawings is a little more tricky since that would have to be done over from scratch, but thats about the only thing that has changed (not counting the transform reassignment, but thats minimal)
That could work great, but only if the Sprite belongs to a class and not just a MovieClip created in the IDE. What are dynamic drawings?
csdstudio is offline   Reply With Quote
Old 08-03-2006, 02:17 PM   #4
senocular
six eyes
 
senocular's Avatar
 
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,784
Send a message via ICQ to senocular Send a message via AIM to senocular Send a message via MSN to senocular Send a message via Yahoo to senocular
Default

MovieClips in the IDE have their own classes as well

By dynamic drawings I mean anything done to an object's graphics property, such as beginFill, lineTo, curveTo, etc.
__________________
(6)
senocular is offline   Reply With Quote
Old 08-04-2006, 11:25 PM   #5
csdstudio
Registered User
 
Join Date: Jun 2005
Posts: 145
Default

Quote:
Originally Posted by senocular
MovieClips in the IDE have their own classes as well

By dynamic drawings I mean anything done to an object's graphics property, such as beginFill, lineTo, curveTo, etc.
Gotcha, that's where the duplicate movieclip method will be missed.
csdstudio is offline   Reply With Quote
Old 08-04-2006, 11:46 PM   #6
senocular
six eyes
 
senocular's Avatar
 
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,784
Send a message via ICQ to senocular Send a message via AIM to senocular Send a message via MSN to senocular Send a message via Yahoo to senocular
Default

Quote:
Originally Posted by csdstudio
Gotcha, that's where the duplicate movieclip method will be missed.
Sadly I don't think there's a way to easily carry that over from one movie clip to the next
__________________
(6)
senocular is offline   Reply With Quote
Old 08-05-2006, 03:41 PM   #7
Tink
Addict
 
Tink's Avatar
 
Join Date: Nov 2001
Location: London
Posts: 2,128
Default

Not sure if you'll find it useful, but i put this little thiing together http://www.tink.ws/blog/as-30-clonin...hics/#more-175.
Tink is offline   Reply With Quote
Old 08-05-2006, 04:07 PM   #8
astgtciv
Resu Deretsiger
 
astgtciv's Avatar
 
Join Date: Jul 2005
Location: St-Petersburg, Russia
Posts: 2,330
Default

Wow, Tink! Nice! How elaborate...
For invokeStep, couldn't you just do

ActionScript Code:
private function invokeStep( step:Object ):void {  var vo:CloneableGraphicsVO = CloneableGraphicsVO( step );  var method:Function = _graphics[ vo.method ];  method.apply(_graphics, vo.arguements); }
__________________
overstream.net: add subtitles to online videos (youtube, vimeo, blip.tv...).
astgtciv is offline   Reply With Quote
Old 08-05-2006, 04:29 PM   #9
senocular
six eyes
 
senocular's Avatar
 
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,784
Send a message via ICQ to senocular Send a message via AIM to senocular Send a message via MSN to senocular Send a message via Yahoo to senocular
Default

I've gone through this process before, and though that kind of solution works for some cases, the problem is the clonablegraphics class lacks the typing that allows it to be used in place of graphics instances in situations where graphics instances are expected. So, for instance, if there is some drawStar(graphics:Graphics):void method out there, clonable graphics fails. Similarly it wont work on operations which may accept a sprite but then use it's graphics property.

It would have been nice if there was an interface that could be used for graphics objects (especially since there is no base class that relates to graphics usage - not all display objects have graphics but a few of its subclasses do), but that does not seem to be available despite there being one for IBitmapDrawable.

Additionally, these problems prevent the graphics property from being overridden in sprites/shapes should you decide to go that route, essentially that falling apart, again, because of typing.

So this approach is great in controlled environments, but really isn't robust enough to work in all cases - just something to be aware of I guess.
__________________
(6)
senocular is offline   Reply With Quote
Old 08-05-2006, 07:29 PM   #10
astgtciv
Resu Deretsiger
 
astgtciv's Avatar
 
Join Date: Jul 2005
Location: St-Petersburg, Russia
Posts: 2,330
Default

Could a sprite-cloning technique along the lines of taking a snapshot of the state of the graphics object with BitmapData, and then drawing on top of that work (and then overriding clear() to destroy the bitmapaData)? Hmm... the graphics object is the furthest in the depth stack, though, so we'd have trouble inserting something under it. Plus, a bitmapData snapshot image is not the same as the original vector graphics of the graphics object, which will probably become noticeable when the object is scaled... (I guess that was the message in "Sprite: Image Is Nothing" )
__________________
overstream.net: add subtitles to online videos (youtube, vimeo, blip.tv...).
astgtciv 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Drop Down Menu Using duplicateMovieClip() site_designer ActionScript 2.0 1 04-26-2005 03:54 AM
How can i apply GradientFill to duplicateMovieClip ponnusamy ActionScript 2.0 1 04-22-2005 09:13 AM
duplicateMovieClip not duplicating yorkeylady ActionScript 2.0 3 04-23-2004 09:18 AM
duplicateMovieClip not working after remove. holstead ActionScript 2.0 3 04-17-2004 04:32 PM
loadmovie and duplicatemovieclip prob dragonsteve ActionScript 1.0 (and below) 1 10-06-2002 08:15 AM


All times are GMT. The time now is 07:49 AM.


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