A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [RESOLVED] [AS2] Assigning a property name to a variable

  1. #1
    [Horse Thief] gotoAndCrash's Avatar
    Join Date
    May 2007
    Location
    NW, USA
    Posts
    576

    resolved [RESOLVED] [AS2] Assigning a property name to a variable

    Greetings All,
    I'm trying to figure out how to assign a property name to a variable, for example :
    Let's say I have a box Movie Clip on my stage. I want to set a Boolean, & if that Boolean is true I want to affect the _width of the box, & if it's false I want to affect the _height.
    Assuming I can set the property to a variable named MyVar, then I could say:

    if (MyBoolean == true) {
    MyVar = _width;
    }
    else {
    MyVar = _height;
    }
    box.MyVar = 400; // Depending on the Boolean value this line will either affect the width or the height of box.

    See what I'm getting at? What's the variable type for assigning it a Property Name as a value?

    Thanks, FKers
    1 Infinite Loop, Cupertino is a portal of Hell.

  2. #2
    [Horse Thief] gotoAndCrash's Avatar
    Join Date
    May 2007
    Location
    NW, USA
    Posts
    576
    Well, played around & figured out a way to do it:

    var w:String = '_width';
    box[w] = 400;
    1 Infinite Loop, Cupertino is a portal of Hell.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center