other ways of getting instances besides getChildByName()
I have many MovieClips and each has a name like "mcDummyClosed" and then and instance name "slideDummyClosed". Another MovieClip has a link to e.g. slideDummyClosed which I then call DummyClosed. I add a Mouse开发者_开发技巧Event.CLICK event to DummyClosed.
Now without adding slideDummyClosed to the stage nor any other MovieClip can I with a string containing it's name get that instance?
I've tried using getChildByName() but that only seems to work if I've already added the MC to be found and added before. My code looks something like this:
public function lookHere(e:MouseEvent){
//this is the function called by e.g. DummyClosed
currentView.removeChildAt(0); //remove the MC that was here before
var slideName:String = 'slide' + e.target.name; //the name of the instance
currentView.addChild(??); //how do I add slideName (e.g. slideDummyClosed) here?
}
getDefinitionByName() might work here. It looks about like what you want, but I've never used it personally.
I take it you want to find a specific movieclip with just using the name of it taken from the "e.target.name" ?
I take it that you dont click the same target as you want to modify. One solution is to save all mc's in an array and then loop through it comparing their names and then returning the matching one.
精彩评论