1 person found this helpful
Yes. You can use a similar code as this one:
Call your labels with numbers like L0, L1, L2, L3, tec...
sym.play('L' + i);
// write code to stop at the end (max numb of your labels for example)
sym.play('L' + i);
I personally don't like the ActionScript-like incrementation of variable names. Instead, I generally will stick all of my labels into an array and step through the array.
Like you said, it is a matter of preference (and sometimes habbits!) as you said!
Actually after reflection, your way is probably more flexible!
@resdesign - how do you ensure this method plays within a symbol?
I can't get mine to play - probably a path issue?
Are you playing the timeline of a symbol?
If so use:
Are the play buttons in the symbol or somewhere else?
Awesome! thank you!
Hmm, im no web coder and i thought it maybe a little more simple than this, im an AE user and the most of my coding has been done in DVD architecture, is there a way to add a number to say a variable each time the forward button is clicked? then when the backward button is clicked it reads the variable and plays the corrisponding label?
Liam, this is what i++ and i-- do. Every time you click on the button next, i is incremented by +1 and the button prev by -1.
If you are using an array for the labels as Elaine mentioned then you can limit the click to the length on the label in the next and even reset it there to 0
On next button
// do something like return the variable to zero creating a loop or stop there.
On previous button
// stop there or return the variable to zero or go the the last label to create a loop.
Actually, i want to set up a button, on rollover, that will play to a specific frame.
(basically a frame that has a glow effect)
this is what i have - but it doesn't seem to work"
on main timeline - on btn_1 i have this set for on mouseover:
I am trying to set up a similar system and I am still very green with code.
I already have my labels with a number so I think this technique would work fine for me (it doesn't need to be particularly flexible).
My question is, where do I put this code?
And, is i++/i-- just creating a number? And if so, can I use that number in multiple actions?
For example: when I click my "FWD" button can I say go to "label"[i] and play "symbolname"[i] with the understanding that both the label and symbol are numbered the same?
I have since this post simplified the system.
The easiest is to set an array with your labels. That way you can give them more meaningful names, which can be helpful.
Setup the array like so:
var myStops =['red','white', 'blue, 'green'];
Then you var use the same kind of code for your buttons.
Is the shorthand for adding 1 so if you start at 0, next value of i is 1, next is 2, etc...
Remember an array starts at 0.
So if you want to okay a label on the timeline it will be:
In a symbol
If you have text, caption or some other text you could also set the array to contain your text and it will change on the click event as well.
Sorry typing on iPhone can be challenging, use minuscule i for the var
Variables are case sensitive. Just keep it consistent.
Thanks, but where exactly do I put the array code?
Sorry, I've come to Edge as an animator rather than a coder. Still very much learning
Ok, nevermind that last question.
I have the code in and almost working.
I am now having a slight inconsistency issue.
When I click forward, sometimes the symbols play from the start, sometimes they play from the middle and sometimes they are stopped at the end of their animation.
When I click back, they sometimes play from the start, sometimes they don't play.
Here is the code I have:
// Array for my Timeline labels
var myLabels = ['Pn1','Pn2','Pn3','End'];
//Array for my symbols
var myPanels = ['Panel1','Panel2','Panel3'];
// Initial setting of 'i'
// For forward button click
// For backward button click
Thanks for all your help so far...
Might be the symbols are all autoplaying ?
Add a stop on 0th second trigger for the symbols so that they start playing when the button is clicked.
If adding stop does not help can you share files?
Thanks but I seem to have conquered it.
I removed the stop action at the end of the symbol timelines and that did the trick.
I do not know how your project is set up but I now changed a few things.
For example I hide the left button (previous or back)at start and in code when i==0 and on the right button (next) when it reaches the end so that no click action can be done. This way I does not increment for sure and the user has a visual telling him there is nothing left to see on next and nothing left to see when he goes back to the first slide.
Hope this makes sense.
Maby you are still looking for a solution to this issue?!?
The following will do the trick if your labels are all on the main timeline (as i understand they are from your original post).
PS: It is important that you put a stop trigger after each label so the timeline does not continue. This also works for mobile devices on swipe...
Action -> click: sym.playReverse("position");
Action -> click: sym.play("position");