Animated Hotspot in VTour

  • Hello,

    I'm trying to make an animated hotspot in a VTour with no luck. I've tried various bits of code from previous forum threads and xml from the Usage Examples page.

    I run the droplet and put the target.png file in the skin folder.

    Through the tour_editor.html, I add the default hotspot (unanimated) and then edit the tour.xml.

    I'm trying to add code from the anihotspots.xml file from the Examples-Usage page. I understand that I need to add the action "do_crop_animation" and also the relevant line of code from the example hotspots. Is that correct?

    So where do I copy the crop animation action to? Just under the startup action? Before the scene code? And do I add the attributes so the first line of the action looks like this?
    <action name="do_crop_animation(128,128, 60)">
    registerattribute(xframes, calc((imagewidth / %1) BOR 0)); [etc etc]

    And then how do I integrate the example hotspot with the current hotspot?
    Current hotspot: <hotspot name="spot1" style="skin_hotspotstyle" ath="1.235" atv="0.488" linkedscene="scene_baja-02-rtf" />
    Example hotspot: <hotspot name="spot5" url="target.png" onloaded="do_crop_animation(128,128, 60);" ath="+15" atv="-12" onclick="looktohotspot(get(name),65)" scale="0.40" zoom="true" />

    So should the line look like this?
    <hotspot name="spot1" url="target.png" onloaded="do_crop_animation(128,128, 60);" ath="1.235" atv="0.488" onclick="looktohotspot(get(name),65)" scale="0.40" zoom="true" linkedscene="scene_baja-02-rtf" />

    Any help greatly appreciated!!
    Many thanks,
    Sarah

  • Hi,
    I haven't looked the exemple but your action name is wrong :

    <action name="do_crop_animation(128,128, 60)">
    shoiuld be
    <action name="do_crop_animation">

    when you call the action you send settings to it from the hotspot :
    onloaded="do_crop_animation(128,128, 60);"

    and thoses settings are used with %1 %2 %3...
    in that case %1 is 128, %2 is 128 and %3 is 60

    Hope I'm clear enough ?

  • Thanks jeromebg.

    The reason I changed the name is there's a message in the second line of the action that says: <!-- add attributes to the hotspot -->

    So shall I just leave the action as it is and copy it into the tour.xml and then just add the hotspot?

    Cheers!


    This is the action from the animated hotspot example:

    <action name="do_crop_animation">
    <!-- add attributes to the hotspot -->
    registerattribute(xframes, calc((imagewidth / %1) BOR 0));
    registerattribute(yframes, calc((imageheight / %2) BOR 0));
    registerattribute(frames, calc(xframes * yframes));
    registerattribute(frame, 0);

    set(crop, '0|0|%1|%2');

    setinterval(calc('crop_anim_' + name), calc(1.0 / %3),
    if(loaded,
    inc(frame);
    if(frame GE frames, if(onlastframe !== null, onlastframe() ); set(frame,0); );
    mod(xpos, frame, xframes);
    div(ypos, frame, xframes);
    Math.floor(ypos);
    mul(xpos, %1);
    mul(ypos, %2);
    calc(crop, xpos + '|' + ypos + '|%1|%2');
    ,
    clearinterval(calc('crop_anim_' + name));
    );
    );
    </action>

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!