Keeping position of animation in layout when swapping orientation

I have been using code I found via this post

I am totally new to this and am creating a site where you can build a composite burger from the various parts; bun, topping, cheese, burger etc. The first burger is going to be called ‘Classic’ which I am using in the name of the variable below. I plan on having variables similarly named for 6 other burgers.

Every item is animated to appear between frame 1 to frame 7 (i.e. they are all part of the first half a second). What I have done it have a timeline for each part. Frame zero has nothing, frame 1 then has the first bun top, frame 2 the second top etc through to frame 7. So there are 7 main timelines for just the burger, i.e. the bun top, topping, cheese, burger, salad, relish and bun bottom.
On say pressing ‘Choose Bun’ then depending on what bun has been chosen, the timeline for ‘bun top’ and ‘bun bottom’ advance to the relevant frame.
In the head.html as per the 2011 post above, I have entered this…
The layout.timeload() is entered as
hypeDocument.goToTimeInTimelineNamed(layoutClassic, ‘Bun_Bottom’);

The layout.timeunload() is entered as
layoutClassic = hypeDocument.currentTimeInTimelineNamed(‘Bun_Bottom’);

I tried setting the variable to 1, but then realised this must mean the 1 second point; I need frame 1 though, hence my attempt at entering 0.1.
On previewing in Safari instead of the timeline advancing to the first bun bottom, it displays the 3rd bottom - the one on frame 3.
If I change the value in head.html to 0.2 it displays the 6th bun bottom.

How do I set the variable in head.html to work with the correct frame?
Once I get one part of the burger working (at the moment I am trying just ‘bun bottom’) then I plan on doing the same with all the other parts. Hopefully, once working the user can custom make a burger on screen and then not lost their creation when the screen rotates.

The goToTimeInTimelineNamed() API is in seconds, so .1 is a tenth of a second. Hype uses a timecode of 30 frames per second, so to get to the first frame you’d use (1/30) or 0.0333.

1 Like

Thanks! What a difference that makes!

1 Like