Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to address an object through a string?

Background:

In a shared Object in AS3, I saved the names (as Strings) of certain MovieClips that appear on stage time in my game.

Issue:

I'm trying to reverse this and the only way I found so far is a method like this:

function objectNameFromString(objectNameAsString): MovieClip {
    switch (objectNameAsString): {
    case "myobject":
        return myobject;
        break;
    }
}

The problem is that I have to make like 20 case statements to get this done which seems unneccesary =( is there anyway you can just reference a MovieClip from a String?

like image 368
D. F. Avatar asked Dec 29 '25 06:12

D. F.


1 Answers

I think what you're looking for is this:
getChildByName()

like image 61
Cay Avatar answered Dec 31 '25 20:12

Cay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!