0
votes

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 MouseEvent.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?
}
2
If you use FlashDevelop and export the Symbol a stub class will automatically be generated for you with all the appropriate member names. Basically cutting out the getChildByName step. I tend to end up with things like, a symbol named com.company.project.AFunnyAnimation and then i create a class in my project called com.company.project.FunnyAnimation that inherits AFunnyAnimation (exposed via the export of a SWC). That way, inside FunnyAnimation Class I can access all the named members of AFunnyAnimation in normal member notation. This is really a question of workflow though.Jotham
I read that as "McDummyClosed" at first, like "McDonalds", rather than "moveclipDummyClosed" and it made me lol. It could be fun to classify variables by giving them ranks like "sirDouble" or "mrFloat". Anyway, it seems you need to keep track of your object instances by name as they're created, which you could do by adding them by name to a flash.utils.Dictionary object, and retrieving the instances by name from it later.Triynko

2 Answers

1
votes

getDefinitionByName() might work here. It looks about like what you want, but I've never used it personally.

0
votes

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.