0

So i've made an object called "potato", then started a loop to check if something in "_level0" has the name of "_level0.potato". What i think is that since the the things in _level0 are objects instead of strings, the object name can't be recognized as a string, so im guessing i need to find a way to convert the object name to a string or vice versa.

var potato:MovieClip = this.createEmptyMovieClip("potato", this.getNextHighestDepth());
for(objects in _level0){
trace(_level0[objects])
    if(_root[objects] == "_level0.potato"){
        trace("OMG, i found a potato on level0")
    }
}

1 Answer 1

1

Your suggestion that the objects are stored as a string is incorrect. If you try using typeof before your

trace(typeof _level0[objects])

you will see that its type is movieclip and your "_level0.potato" is string They will not be equal. But you can convert object reference to string using String(...) construct.

And about names. You're confusing names and references. MovieClip object like some others in ac2 have property called _name. In this property name of object is stored like string. But only name, not the full path to its destination. For your potato mc _name will be equal "potato" So you could do your search like this

var potato:MovieClip = this.createEmptyMovieClip("potato",this.getNextHighestDepth());
for(objects in _level0){
trace(_level0[objects])
    if(_root[objects]._name == "potato"){
        trace("OMG, i found a potato on level0")
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.