This content has been marked as final. Show 7 replies
what do you mean by "apear" [sic]?
there should be a new child movieclip of Vierkant so if you check its numChildren property, it's increased from the number of children created in the authoring environment.
but if you wouldn't expect to see anything on-stage, because square has no graphics.
if I read this right, you have drawn a square on stage, put it inside a movieclip, and associated that clip with the class "Vierkant". I this is what you've done, then the asset is already on the stage, so you should see it for sure, unless it's positioned off-stage.
If the above assumption is correct, in your class code, square = new MovieClip(); is a blank movieclip that you created. It's not the square that's in the FLA. The square that you're trying to have show up is the Vierkant class object itself, i.e. "this".
You are right Joseph, i tried to use a class to take an movieclip from my library and place it on the stage. Like AttachMovie in a.s. 2.0
I guest it's not possible using a class. You have to make a new object in the fla file. like var hello:Vierkant = new Vierkant();
hello.x = 50;
..it tought it would be possible using a class but it is maybe not the correct way.
you misunderstand. what you stated has nothing to do with square. read my message.
you need to use the new constructor (in your fla) to create an instance of Vierkant and then use the addChild method to add it to the display list.
As per what kglad and I have been saying, try this:
I understand the way it works as i mentioned before. You need to put this in the FLA file
var square:MovieClip = new Vierkant();
square._x =100 ;
Like the example of Joseph.
The only question that i had was if is was possible to addChild(square)
from the class itself.
And the answer seem to be No.
using square for the name of your new Vierkant was a poor choice because it's now causing confusion between the movieclip you were adding in your Vierkant init() method and a Vierkant instance.
1. you can add a movieclip from a class (that is a subclass of the displaylistcontainer class, like Vierkant)
2. a class can add an instance of itself to the display list