[Laszlo-user] Novice help - animating a view on mouseout

rogerhoward@rogerroger.org rogerhoward at rogerroger.org
Mon Mar 3 06:10:04 PST 2008


I'm a novice with OpenLaszlo, though I work a lot with Flex. I'm
learning OL to possibly use the LZC compiler to generate
SWFs as part of a batch process, and as well as a learning exercise.
I've got a question about mouse tracking and animating a multiimage
resource on mouseout and OL is different enough from Flex that I'm a
little stumped.

I've reduced my code to the relevant parts below. This LZX loads 18
frames (in this case) into a view, and using mousetracking switches the
current frame (using setResourceNumber) based on the position of the
mouse on the x plane. This much works fine.

When the mouse leaves the view I'd like to trigger the sequence of
frames to play as a looping animation, regaining mouse control only when
the mouse enters the view. I've tried adding a onmouseout handler  to
call play() on the view but I can't get anywhere.

What am I missing?

Thanks,

Roger Howard

----- Example below -----

<canvas width="320" height="240">

   <resource name="spinframes">
       <frame src="001.jpg" />
       <frame src="003.jpg" />
       <frame src="005.jpg" />
       <frame src="007.jpg" />
       <frame src="009.jpg" />
       <frame src="011.jpg" />
       <frame src="013.jpg" />
       <frame src="015.jpg" />
       <frame src="017.jpg" />
       <frame src="019.jpg" />
       <frame src="021.jpg" />
       <frame src="023.jpg" />
       <frame src="025.jpg" />
       <frame src="027.jpg" />
       <frame src="029.jpg" />
       <frame src="031.jpg" />
       <frame src="033.jpg" />
       <frame src="035.jpg" />
   </resource>

   <view resource="spinframes" id="spinview" visible="true"
clickable="true">
       <attribute name="moustracker_del" value="$once{ new LzDelegate(
this, 'trackmouse' )}" />

       <handler name="onmouseover">
           moustracker_del.register(LzIdle,'onidle');
       </handler>

       <handler name="onmouseout">
           spinframes.play();
       </handler>

       <method name="trackmouse">
           var xc = this.getMouse('x');
           var slwid = 320 / 18;
           var sl = ( Math.floor(xc/slwid) ) + 1;
           spinview.setResourceNumber(sl);
       </method>

   </view>

</canvas>



More information about the Laszlo-user mailing list