A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: adding instance names through scripts??

  1. #1
    The next Squaresoft
    Join Date
    Sep 2004
    Location
    Zanarkand
    Posts
    215

    adding instance names through scripts??

    hi

    umm is it possible to add or change instance names by using scripts?

    like if i had an MC named "thing", i could change it "thingamajigger1"
    if it hits something...(hitTest...)

    any1 have any opinions?
    "Are those gummy worms? Can I have some?"

    "Nevermind, I just saw one move by itself..."

  2. #2
    EXtreme Programmer
    Join Date
    Jul 2005
    Posts
    40

    I have good news for you

    It is possible. Using your example and the "_name" property here is an example:
    if (thing.hitTest(otherThing)) {
    thing._name = "thingamajigger1";
    trace(thingamajigger1._name); //Outputs: thingamajigger1
    }
    I tested it and it works but if your version of flash can't use this you can reference the movieclip. For example:
    if (thing.hitTest(otherThing)) {
    thingamajigger1 = thing;
    trace(thingamajigger1); //Outputs: _level0.thing
    }
    I have tested that too. It works because when you make a variable equal an object (or movieclip) it doesn't copy its methods variables properties etc. to the variable. It puts a reference on the variable so the compiler looks at it like thing instead of thingamajigger1.

    I hope I helped,
    zach_297
    I have Macromedia Flash 8.
    How about you?

  3. #3
    The next Squaresoft
    Join Date
    Sep 2004
    Location
    Zanarkand
    Posts
    215
    ohhh, so what version is the one with the _name?

    anyway thanks dude, big help!!
    "Are those gummy worms? Can I have some?"

    "Nevermind, I just saw one move by itself..."

  4. #4
    EXtreme Programmer
    Join Date
    Jul 2005
    Posts
    40
    I think _name is in Flash 4 and newer.
    I have Macromedia Flash 8.
    How about you?

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