View Full Version : sprite and movieclip
donio
08-16-2009, 12:24 PM
if i want to receive as a parameter either a sprite or a movieclip, how should i define it in a class?
like this?
public class NoobStyle {
private var container:DisplayObject;
public function NoobStyle (
container:DisplayObject;
senocular
08-16-2009, 01:48 PM
if you want to receive a parameter, that means a function - what you've shown is a class with a class variable... but I think more to the point of your question is that it should be typed as Sprite since MovieClips are both of the type MovieClip and Sprite so when something is typed as a Sprite, both Sprites and MovieClips can be used.
function myFunction(container:Sprite): ...
ggalan
08-16-2009, 04:46 PM
dont you mean movieclip?
MovieClips are both of the type MovieClip and Sprite
UncleNinja
08-16-2009, 05:28 PM
so when something is typed as a Sprite, both Sprites and MovieClips can be used.
That's cool. I didn't know that. thank ye! :)
donio
08-17-2009, 06:12 AM
I meant how should I declare a instance variable if I want to receive either a sprite or a movieClip?
like this?
private var container:DisplayObject;
kingundkong
08-17-2009, 06:39 AM
No, type it to Sprite, as senocular (http://www.actionscript.org/forums/member.php3?u=8886) said: if you type it to Sprite it can be both, MovieClip or Sprite, because a MovieClip is also a Sprite.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.