Target timeline of an instance of a symbol, not every instance


(Brian) #1

I am building out a structure for Hype for a client. I decided to take advantage of the automatic id generation for flexibility on multiple layouts, where our team can duplicate symbols, and have the same ids as far as the code is concerned, even though there are multiple instances of the same id.

That is working just fine.

What I am hoping to do is to have say 10 instances of a symbol on stage, and target one specific one. No problem, have that.

I am trying to talk to a timeline in that specific instance of the symbol and tell it to play a timeline that none of the other 9 are playing. But it triggers all 10 instances to play the same timeline in unison.

Is it possible to target an element timeline and not the symbol?

for example:

var instance = hypeDocument.getSymbolInstanceById($(level4TopLeftInstance).attr(‘id’));
instance.startTimelineNamed(‘pulse’, hypeDocument.kDirectionForward);

Thanks!


#2

Hi Brian!

If I understand You correctly…

In my attached project are (2) symbol instances and two buttons. One button fires the timeline for the first instance; and the second button fires the second instance’s timeline. While both timelines are called “Main Timeline” they could have been called something different. Each symbol instance has an unique ID.

The code below fires the “Main Timeline” for each symbol instance.

hypeDocument.getSymbolInstanceById('menuSymbol_1').startTimelineNamed('Main TimeLine', hypeDocument.kDirectionForward);

hypeDocument.getSymbolInstanceById('menuSymbol_2').startTimelineNamed('Main TimeLine', hypeDocument.kDirectionForward);

FireTimeline.hype.zip (20.6 KB)


(Mark Hunte) #3

As @JimScott has pointed out each symbol instance can have it’s own ID

But you can use the symbols Display name.
A symbol instance will use the same display name on every layout. But not the same ID.

var instances =  hypeDocument.getSymbolInstancesByName('level4BottomLeftInstance')[0]
 
 
instances.startTimelineNamed('Main Timeline', hypeDocument.kDirectionForward)

SymbolInstancesByName.hype.zip (56.6 KB)

This way you do not have to give every symbol instance a unique ID in every layout.


(Brian) #4

Jim,

Thanks, once I ran into it I should have built something more specific. Layering what I was doing into what you sent worked like a charm, so I know there is just a small bug in my code.

I am basically building things out without any specific names, so that on various layouts, I can swap symbols that are customized without having repeated ids.

I figured out a nice algorithm to drill down and get specifics in the nodes, and how the nodes relates to the timeline layers. My test dealt with numerous nested symbols that are all other symbols that are nested two more times over.

Thanks again.


(Brian) #5

Jim,

I had my timeline named wrong. Was _P_ulse not _p_ulse. Ha!

Thanks again for your help.


(Brian) #6

Mark,

Thanks, as it turns out I had just mislabeled the Timeline I was targeting.

Thanks for your help regardless.


#7

Hi Brian!

Glad You have found your solution. Is your test piece something You can publish here? It could be a valuable learning experience for others (myself included!).

Thanks!


(Brian) #8

A couple bugs to work out, but yes of course.