You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Thursday, June 25th 2015, 6:40am

Variable declared in Action, access error, please help~

Hi, I'm newbie here.

I made a little planet intro action like this:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<events onxmlcomplete="lpinit()" />
<action name="lpinit">
    set(ohlookat, get(view.hlookat));
    set(ovlookat, get(view.vlookat));
    set(ofov, get(view.fov));

    set(view.stereographic, true);
    set(view.fisheye, 1.0);
    set(view.fov, 160);
    set(view.hlookat, 0);
    set(view.vlookat, 90);
    trace(ohlookat);
</action>

<events onloadcomplete="delayedcall(2.0, lp());" />
<action name="lp">
    trace(ohlookat);
    tween(view.hlookat, ohlookat, 2.5, easeInOutQuad);
    tween(view.vlookat, ovlookat, 2.5, easeInOutQuad);
    tween(view.fov, ofov, 2.5, easeInOutQuad);
    tween(view.fisheye, 0.0, 2.5, easeInOutQuad);
</action>



the trace(ohlookat) in "lpinit" action show correct, but in the "lp" action,trace(ohlookat) display 0; if I can't access the variable in another action? Anyone help, thx!


Best regards,

Jove.

spacerywirtualne

Professional

Posts: 907

Location: Poland, Europe

Occupation: krpano developer : virtual tours

  • Send private message

2

Thursday, June 25th 2015, 9:40am

Hi

I personally use in such situations 'get();' method:

The variables are available at any time - globally.


Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<events onxmlcomplete="lpinit()" />
<action name="lpinit">
    copy(ohlookat, view.hlookat);
    copy(ovlookat, view.vlookat);
    copy(ofov, view.fov);

    set(view.stereographic, true);
    set(view.fisheye, 1.0);
    set(view.fov, 160);
    set(view.hlookat, 0);
    set(view.vlookat, 90);
    trace(get(ohlookat));
</action>

<events onloadcomplete="delayedcall(2.0, lp());" />
<action name="lp">
    trace(get(ohlookat));
    tween(view.hlookat, get(ohlookat), 2.5, easeInOutQuad);
    tween(view.vlookat, get(ovlookat), 2.5, easeInOutQuad);
    tween(view.fov, get(ofov), 2.5, easeInOutQuad);
    tween(view.fisheye, 0.0, 2.5, easeInOutQuad);
</action>


tween(view.hlookat, get(ohlookat), 2.5, easeInOutQuad);
...


Try it

Piotr
Your own online, cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube

cms4vr team *thumbsup*

3

Thursday, June 25th 2015, 11:38am

Hi spacerywirtualne,

I use trace(get(ohlookat)) in the "lp" action, but still, it shows 0. the same as trace(ohlookat).
What do I do wrong ?

spacerywirtualne

Professional

Posts: 907

Location: Poland, Europe

Occupation: krpano developer : virtual tours

  • Send private message

4

Thursday, June 25th 2015, 12:41pm

This means that the panorama was in position view.hlookat = 0, when You get ohlookat variable (onxmlcomplete event).

Move the panorama and try this:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<events onclick="lpinit()" />

<action name="lpinit">
    copy(ohlookat, view.hlookat);
    copy(ovlookat, view.vlookat);
    copy(ofov, view.fov);

    delayedcall(2.0, lp());
</action>

<action name="lp">
    trace('new var: ',get(ohlookat));
    tween(view.hlookat, get(ohlookat), 2.5, easeInOutQuad);
    tween(view.vlookat, get(ovlookat), 2.5, easeInOutQuad);
    tween(view.fov, get(ofov), 2.5, easeInOutQuad);
    tween(view.fisheye, 0.0, 2.5, easeInOutQuad);
</action>


Piotr
Your own online, cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube

cms4vr team *thumbsup*

5

Thursday, June 25th 2015, 1:11pm

Hi spacerywirtualne,

I found the point. the onxmlcomplete event executed twice, so the second time ohlookat set to a viewlookat with 0, but why onxmlcomplete event executed twice? I think I must check the documentation.

Thanks!