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

how to address a symbol that was added dynamically in ANCC HTML5?

LEGEND ,
Jul 25, 2018 Jul 25, 2018

I have several symbols added dynamically into a blank symbol. I swap them on click events from buttons in a menu however I do not seem to be able to manipulate them after they have been added to the stage. I suppose it has to do with the fact the I need an instance name to use them.

Is the link name the same as an instance name? Probably not because I get  the following error.

this.blank.colonialSymbol is undefined

So is there a way to add an instance name to these symbols so I can use them porperly?

var colonial = new lib.colonialSymbol();

//************** LOAD BUTTON ACTIONS *************************

this.addBtn.addEventListener("click", loadSymbol.bind(this));

function loadSymbol(){   

    this.blank.addChild(colonial);

    this.blank.colinialSymbol.gotoAndStop("author1"); // symbol timeline - gives undefined

    this.gotoAnStop('start'); // main timeline

}

1.0K
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 , Jul 25, 2018 Jul 25, 2018

Hi.

Use colonial.gotoAndStop("author1");

Translate
LEGEND ,
Jul 25, 2018 Jul 25, 2018

Well, in your code you misspelled colonialSymbol as "colinialSymbol". But you should be able to use "colonial" to control it, since that points to the newly created object.

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
LEGEND ,
Jul 25, 2018 Jul 25, 2018

Nope. I made a typo here but it was correct in the actual FLA.

So per your advice and to make sure, I changed it to colonial (which I had tried before BTW and I got the same error)

this.blank.colonial.gotoAndStop("author1");

in the console:

this.blank.colonial is undefined

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
LEGEND ,
Jul 25, 2018 Jul 25, 2018

Yes, this.blank.colonial is undefined because you never created any such thing. What you do create is local variable colonial in the first line. Try using that.

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
LEGEND ,
Jul 25, 2018 Jul 25, 2018

Makes sense! Thanks.

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 ,
Jul 25, 2018 Jul 25, 2018

Hi.

Use colonial.gotoAndStop("author1");

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
LEGEND ,
Jul 25, 2018 Jul 25, 2018

Muita obrigada! This was it. I am forever grateful for your input!

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 ,
Jul 25, 2018 Jul 25, 2018

De nada! I do appreciate your Brazilian Portuguese.

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
LEGEND ,
Jul 25, 2018 Jul 25, 2018

Love Brazil! Named my first daughter after my best Brazilian friend. Saudade dela!

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
LEGEND ,
Jul 25, 2018 Jul 25, 2018

I have another question.

Is it better to load instances from the library and use them as needed than putting everything on the main timeline? I know in design it is easier because you can make your main timeline transitions there once only rather than having a bunch of symbols and transitions.

But what about memory, file size, etc...

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
LEGEND ,
Jul 25, 2018 Jul 25, 2018

JoãoCésar  wrote

Hi.

Use colonial.gotoAndStop("author1");

Yes, that's exactly what I said, twice.

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
LEGEND ,
Jul 25, 2018 Jul 25, 2018

Except I did not get it because I just thought you were talking about the misspelling! Thanks anyway.

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
LEGEND ,
Jul 25, 2018 Jul 25, 2018

That's why it's generally a good idea to read all the sentences, not just the first one.

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
LEGEND ,
Jul 25, 2018 Jul 25, 2018
LATEST

Sorry I am French and I read all of it and still understood you were speaking of the typo. But thanks for answering the question. I am grateful to you as well.

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