A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Shortcut to assigning instance names?

  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    13

    Shortcut to assigning instance names?

    I have a 4x4 set of square buttons that I need to give instance names to. They will be named 'btn_1' thru 'btn_16'. Is there any shortcut to assigning the names or do I have to go through 16 times clicking on the button and clicking down to the 'instance name' text box?

  2. #2
    Member
    Join Date
    Aug 2010
    Posts
    33
    I don't think there is an easy way to do this; if you're absolutely in need of 16 different instances, then you will need to rename each object.

  3. #3
    Senior Member
    Join Date
    Jul 2008
    Posts
    391
    If you have those 16 buttons already added on the stage, I'll assume the parent of the buttons is the stage, you can do
    PHP Code:
    for (var 016i++) {
        var 
    btt:* = stage.getChildAt (i);
        var 
    string:String "btn_" i;
        
    btt.name string;

    That'll only work if the first 16 children of your stage are the buttons. But you can set their instance names using the .name property in AS3.

Tags for this Thread

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