A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Using a variable for an instance name??

Threaded View

  1. #1
    Join Date
    Jul 2004
    New Haven, CT

    Question Using a variable for an instance name??

    Ok, I've been at this for 2 days now, and really need some assistance. It seems like it should be so simple!

    The part that doesn't work:

    	// or this:
    Where, "critter_pressed_new" is not a specific instance name, but rather a variable name.

    Please see the attached file and take a look if you are familiar with variables.

    If you want more info, here's the deal...

    I randomly launch some movie clips from the library with attachMovie (they are bedbugs). No problem there.

    On launch they get instance names. The first one gets "critter_launched_01", the second "critter_launched_02".

    There is a button in the root that needs to be able to make the critter go away (by going to a frame label of "poof", which has a red X on it for now).

    I have a little test button that is hard-coded for:
    	//this is what code needs to do from other button, but using var name:
    and it works fine. No problem there.

    But, I need to be able to have one button close only the most recent bug. So I created a variable in the root to keep track of the last one out:

    var critter_pressed_new = "test";
    Then within the critter mc I update it using this:
    _root.critter_pressed_new = targetPath(this);
    which now makes the variable of "critter_pressed_new" have the instance name of the movie clip in it (which, would be _level0.critter_launched_01 or 02).

    Then that button in the root should be able to take the value that is in the variable "critter_pressed_new" and use that as the instance name, to make that particular mc go away.

    Please help if you can offer any advice at all!! Thank you!
    Attached Files Attached Files

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