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.
Hi.
Try using exportRoot to refer to the main timeline.
Copy link to clipboard
Copied
Hi.
Try using exportRoot to refer to the main timeline.
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'});
Copy link to clipboard
Copied
Nice.
You can write:
this.intro.startbtn
Start with 'this' and continue with dot notation.
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.
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.
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.
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.
Copy link to clipboard
Copied
Yes I am actually the one monitoring the forum and answering questions.
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.
Copy link to clipboard
Copied
I would not even know how to do that! and I am not so special!
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
}
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
Copy link to clipboard
Copied
hum. I tried that earlier and no joy. thought I had it wrong.
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.
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.
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
}
}