Copy link to clipboard
Copied
`I want to put in a displayobjectcontainer many movieclip derivatives called snailMovieClip and batMovieClip, which are all derivatives of movieclip class and they all additionally have a parameter called thisMonstersIDnumber added into the classes.. As this would go and answer the question for any type of movieclip derivative you may have in your game/production, Can you search for a displayobjectcontainer for any type of "dot variables" (i think theyre called properties) that you have from classes of movie clip added to that displayobjectcontainer? Here this is what i mean. "Can I find a snailMovieClip or batMovieClip using its monsterIDnumber by searching a displayobjectcontainer by monsterIDnumber?
//populating a displayobjectcontainer with movieclips of class snailMovieClip
var monsterIDnumberDesignator:Number=0;
for i:0 i++ i<=5
var newMonster: snailMovieClip = new snailMovieClip(monsterIDnumberDesignator)
monsterIDnumberDesignator++;
maindisplayframe.addChild(newMonster)
(...in snailMovieClip class)
package
{
var thisMonstersIDNumber:Number=0
public function snailMovieClip(this_Monsters_ID_Number)
{
thisMonstersIDNumber=this_Monsters_ID_Number;
}
}
//and NOW....
for j:Number=0; j++; j<=maindisplayframe.numChildren
trace maindisplayframe.getChildAt(j).thisMonstersIDNumber
??????????????????^^^^^^^^^^can I do this??
Copy link to clipboard
Copied
Hi.
The getChildAt method returns a DisplayObject and by default display objects don't have a property called monstersIDNumber.
So you have to tell the compiler that your object has that property by using casting. Like this:
for (var i:uint = 0; i < yourContainer.numChildren; i++)
trace((yourContainer.getChildAt(i) as snailMovieClip).monstersIDNumber);
I hope this helps.
Regards,
JC
Find more inspiration, events, and resources on the new Adobe Community
Explore Now