Change scene with JavaScript

Hi!
I have a question about a javascript function:

...
console.log(hypeDocument.currentSceneName());
hypeDocument.showSceneNamed('next',hypeDocument.kSceneTransitionPushRightToLeft,1);
console.log(hypeDocument.currentSceneName());
...

In console first time it says "now"
second time “now” again!

Sorry I know it will be a stupid mistake!!
Thanks

S

Can you share the document?

Is the transition working and the “next” scene showing?

Don’t forget “next” should be the name of the scene you want to go to. If you just want to go to the next scene you can use showNextScene()

D

I’m guessing that the name of your scene is wrong; I tested your code and it worked just fine for me when I specifically had a scene named “next”. When that scene didn’t exist, it would just show “now” twice.

Hi @jonathan and @DBear!

This is my projext:
changeScene.zip (295.9 KB)

Can you take a look to my console?
First time:
“scene = now”
click on < button (prec)
“CHANGE TO NEXT (button PREC)”
“scene = next”

all is ok

click on < button again (prec1)

“scene BEFORE showSceneNamed= now” it should be “next”. Why is “now” again?
“CHANGE TO NEXT (button PREC1)”
“scene AFTER showSceneNamed= now”
“scene = now”

I call my function only loading “now” scene. Is it wrong?

S

I cannot look at this properly since I am on hype 2.5 at the Mo.

But in your code it looks like you have both clicks going to next. ?

 hypeDocument.showSceneNamed('next',hypeDocument.kSceneTransitionPushRightToLeft,1);

Is it possible that you need to change the second one to:

 hypeDocument.showSceneNamed('now',hypeDocument.kSceneTransitionPushRightToLeft,1);

And also check you have named the button IDs correctly.

I ran this in Hype 2.5 this way and the scenes changed as expected.

The code was on scene load on the first scene only.

Why do you want to use your own callbacks for button clicks??

Hi @patxbit,

In your last scene you have an action on “prec2” on mouse click “jump to scene”, “now”. So your console is going to show the “now” scene name because you’re back in the “now” scene. Perhaps you want this to go to the “next” scene?

Also, in your “next” scene you have another Mouse Click action pointing to the “now” scene. If you remove this then your javascript will work as asked.

Remember, any changes made in the inspector will override any in the javascript. You should not use the same calls and actions in both environments anyway.

D

1 Like

yes, this is true.
I want always go to scene "next" when I click on < button.

But if I call
hypeDocument.showSceneNamed('next'
why does it go to "now" scene?

I think all is ok...

is this not right?

You are right!
I try to do something both with javascript and both with mouse click action!

Thank you!

1 Like

Ok.

Can we clear up some confusion.

Do you want

1, [scene 1] click(prec)->[scene 2] , [scene 2] click(prec1) ->[scene 1].

or

2,[scene 1] click(prec)->[scene 2] , [scene 2] click(prec1) ->[scene 3]…

or

3, [scene 1] click(prec)->[scene 2] , [scene 2] click(prec1) ->[scene 2].

Cheers,

That would be the thing I am missing . I only stripped the oen function out of the plist ( did not see the other) and had to create my own 2.5 proj.

Really need to get v3 on this Machine. :sob:

1 Like

The issue is that you also have mouse click actions on those buttons that will change the scene. If you try to change scenes while in the middle of a scene transition, we'll ignore the other scene change. Thus it is still going to say "now" even if you try to change to the "next" scene.

If you want full programmatic control, then you'll want to first remove the mouse click actions that jump to the scene.

Seriously!

Lol. Yer, I have a 10.6.8 machine that I cannot upgrade yet. And need to be able to maintain a set of pages from it when I am using it… Hopefully i will be able to upgrade the mac in the near future.