A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Quick Q about strings and objects

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    12

    Quick Q about strings and objects

    At one point in my code a string variable will contain the name of an object on the screen.

    Code:
    selectedUnit = (event.target.name);
    String variable will now hold the string "tower01" which is the name of an object on screen. I want to then use this to manipulate that object but the following doesn't work

    Code:
    selectedUnit.x = 100;
    I want to make the tower01 object's x co-ord to 100 but it seems I can't use a variable holding the object's name in place of the object's name.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    without seeing all of your code/file try just using event.target

  3. #3
    Junior Member
    Join Date
    Nov 2013
    Posts
    12
    That works thx

    I also found out using "this[selectedUnit].x=200;" works as well

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