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

How do I address the main timeline from a nested symbol placed on main timeline?

LEGEND ,
May 02, 2018 May 02, 2018

Copy link to clipboard

Copied

What is the equivalent from Edge Animate?

sym.getComposition().getStage().stop('lableName);

My setup:

Main timeline has symbol named intro.

Intro has a button named startbtn

Main timeline has several stops with labels - intro, tutorial, problem, etc... which also have symbols with buttons and questions, etc...

I want to move the play head of the main timeline from the startBtn symbol inside the intro symbol while the intro symbol is on the main time.

Views

1.2K

Translate

Translate

Report

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 , May 02, 2018 May 02, 2018

Hi.

Try using exportRoot to refer to the main timeline.

Votes

Translate

Translate
Community Expert ,
May 02, 2018 May 02, 2018

Copy link to clipboard

Copied

Hi.

Try using exportRoot to refer to the main timeline.

Votes

Translate

Translate

Report

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 ,
May 02, 2018 May 02, 2018

Copy link to clipboard

Copied

Thanks, I'll try that.

And what if I wanted to address the nested symbol from the main timeline?

In Edge Animate it is

in compositionReady:

sym.getSymbol().$('button').css({'background-color':'red'});

Votes

Translate

Translate

Report

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 ,
May 02, 2018 May 02, 2018

Copy link to clipboard

Copied

Nice.

You can write:

this.intro.startbtn

Start with 'this' and continue with dot notation.

Votes

Translate

Translate

Report

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 ,
May 02, 2018 May 02, 2018

Copy link to clipboard

Copied

Also I like to keep my code on frame 1 of main timeline for most everything. Is that a good idea or not. In EA I keep everything in compositionReady.

Votes

Translate

Translate

Report

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 ,
May 02, 2018 May 02, 2018

Copy link to clipboard

Copied

I also like to do this.

But, sometimes I do like to use the main timeline as an effective state machine.

So, for example, I like to put variable and function definitions in their respective frames.

If I have a timeline with 3 frames: start, menu, game, I think it's a good idea to have the vars and functions for the game, for example, declared in that frame.

In this way I don't have to worry about resetting everything I need when the user goes back to that frame and also the code gets more organized because sometimes the one-frame approach creates really huge amounts of code in one single frame.

I don't know if it is the best way, but is the way I do things.

I hope it makes sense.

Votes

Translate

Translate

Report

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 ,
May 02, 2018 May 02, 2018

Copy link to clipboard

Copied

Thank you very much for your input. Coming reluctantly from Edge Animate. Last time I really used Flash was at Flash MX so it is pretty far back and of course it did not have canvas at the time.

Votes

Translate

Translate

Report

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 ,
May 02, 2018 May 02, 2018

Copy link to clipboard

Copied

Don't forget that Edge Animate continues to work fine, and is still part of what you can download from your CC subscription.

Votes

Translate

Translate

Report

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 ,
May 02, 2018 May 02, 2018

Copy link to clipboard

Copied

Yes I am actually the one monitoring the forum and answering questions.

Votes

Translate

Translate

Report

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 ,
May 02, 2018 May 02, 2018

Copy link to clipboard

Copied

I spotted your ACP badge, I knew you were special! I'm ACP too, but I hide it under an MVP badge, so that people don't get too excited.

Votes

Translate

Translate

Report

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 ,
May 02, 2018 May 02, 2018

Copy link to clipboard

Copied

I would not even know how to do that! and I am not so special!

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Hey, could you give me the syntax for that?

I have one symbol on main timeline  (instructions)

I have button in another symbol.  (geronimoBtn in symbol nativesSymbol

I want to hide the first symbol from the button in the other symbol. Line 05 is the problem since I am not sure how to use exportRoot

this.nativeSymbol.geronimoBtn.addEventListener("click", geronimoInfo.bind(this));

function geronimoInfo(){

    this.nativeSymbol.gotoAndPlay("geronimoPage");

    this.instructions.visible = false;  // this element is on the main timeline so this. is incorrect

}

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Hi!

If you want to safely bind the handler function to the main timeline, pass exportRoot as the parameter for the bind function.

this.nativeSymbol.geronimoBtn.addEventListener("click", geronimoInfo.bind(exportRoot));

So the 'this' keyword inside of the handler function body will refer to the exportRoot/main timeline.

Alternatively, you can use exportRoot in the function body.

function geronimoInfo(){

    this.nativeSymbol.gotoAndPlay("geronimoPage");

    exportRoot.instructions.visible = false;

}

I hope this helps!

Regards,

JC

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

hum. I tried that earlier and no joy. thought I had it wrong.

Votes

Translate

Translate

Report

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 ,
May 02, 2018 May 02, 2018

Copy link to clipboard

Copied

Going back to the original need, although you can use exportRoot, you can also use the window itself. That can be handy if you need non-Animate Javascript to talk to Animate Javascript. Something like this:

window.connectiontosomethingthatcanbedeeplyburied = this;

in the location that you need to access, and:

var whototalkto = window.connectiontosomethingthatcanbedeeplyburied;

somewhere else. Then that other location can use whototalkto as a way to access the original location, no matter where it is.

Votes

Translate

Translate

Report

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 ,
May 02, 2018 May 02, 2018

Copy link to clipboard

Copied

Interesting! I'll have to explore this.

It's just hard to get back to Flash after having devoted my time to EA since preview 1.

Votes

Translate

Translate

Report

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 ,
Jun 12, 2018 Jun 12, 2018

Copy link to clipboard

Copied

All this drives me crazy. I opted to write the code on the main timeline frame 1 which is something I used to do way back then when I used Flash MX.

So basically I address the objects in symbols from root and them if I need to address the main limeline it work fine.

Example:

main timeline has symbol instructions with button nextBtn and several pages.

var step = 1;

this.instructions.nextBtn.addEventListener("click", instructions.bind(this));

function instructions(){

    step++;

    if(step<4 ){       

        this.instructions.gotoAndStop("page" + step);        // symbol timeline

    }else if(step == 4){

        this.gotoAndPlay("game");      // main timeline

   }   

}

Votes

Translate

Translate

Report

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