Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Instance Name Question

Participant ,
Jun 09, 2011 Jun 09, 2011

I have a movieclip that is added to the stage in the authoring environment. I gave it an instance name of myInstance.

When I trace the instance name, it gives me Instance12.


Why is that? How can I change the instance name that dropTarget.name returns without removing all my instances from the stage, instantiating them with actionscript, and renaming them then (with 250 instances that have to be in exact pixel locations that would be a huge inconvience bordering on the impossible, especially if I ever have to move even one of them.)

If the dropTarget is another movieclip assigned to a class, is there any way to use dropTarget to access a parameter from within that class? (i.e., dropTarget.myVariable the same way you might use myObject.myVariable)?

Does that make sense?

Thanks!!

TOPICS
ActionScript
690
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 09, 2011 Jun 09, 2011

lol.

you're welcome.

(and, thank you for being so conscientious about marking helpful/correct answers.)

Translate
Community Expert ,
Jun 09, 2011 Jun 09, 2011

instance names assigned in the properties panel cannot be changed by you and won't be changed by flash.

what you're seeing is the dropTarget is not what you think it is.  the dropTarget is not myInstance but something that you failed to name and that flash named for you, instance12.

if the dropTarget were a member of Class1 which had a public variable (eg, var1), you could use:

Class1(whatever.dropTarget).var1

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 09, 2011 Jun 09, 2011

I tried this:

            trace (GeoPuzzle(this.dropTarget).abbrev);

But I got this error:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Shape@d25c061 to com.freerangeeggheads.puzzleography.GeoPuzzle.
    at com.freerangeeggheads.puzzleography::GeoPiece/geoPieceEnd()[/Users/Amber/Documents/Apps/Puzzleography/Project/com/freerangeeggheads/puzzleography/GeoPiece.as:51]

When I trace this.dropTarget.parent.name I get the actual instance name of the movie clip on the stage.


Is there a tutorial or something that will explain this heirarchy to me? I don't even know what to google, and navigating Adobe's documenation is like trying to nail jello to a tree. 😕

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 09, 2011 Jun 09, 2011

Also, how do I assign something an instance name? I thought it was in the properties panel, but I've named everything that way, and tracing the parent name of the dropTarget gives me the proper instance name, which means the movie clip on the stage has created a child (??) that flash has named for me. Wow, I'm confused.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 09, 2011 Jun 09, 2011

your dropTarget is a shape.  it's the shape on your movieclip's timeline:  use the dropTarget.parent.

   trace (GeoPuzzle(this.dropTarget.parent).abbrev);  // i'm not sure "this" is correct.  it might be, though.

for objects not placed on-stage you can assign/change the name by using:

whateverobject.name="somename";

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 09, 2011 Jun 09, 2011

Oh, I see!

Edited: I'm an idiot, that totally worked.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 09, 2011 Jun 09, 2011

Hm. Well, I can't remark that proper answer as the correct answer, I accidentally marked it "helpful." If you reply to this I'll mark that correct so the answer shows up.


THANK YOU!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 09, 2011 Jun 09, 2011
LATEST

lol.

you're welcome.

(and, thank you for being so conscientious about marking helpful/correct answers.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines