The AnimatedButton class provides the methods to implement an animated button within a dialog. The attributes and methods are only described briefly in this document. An example program, oowalker.rex, is provided with the OODialog sample programs.
Attribute holding the handle of the parent dialog
Animation ends when set to 1 (see Stop method)
Initialize the animation parameters:
but = .AnimatedButton~new(buttonid,from,to, , movex,movey,sizex,sizey,delay, , startx,starty,parentdialog)
The values are stored in a stem variable:
ID of animation button
Array of in-memory bitmap handles, or a bitmap resource ID in a DLL, or the name of an array in the .local directory containing handles to bitmaps loaded with LoadBitmap. The array has to start with 1 and continue in increments by 1.
0 if sprite.from is an array, or the name of an array stored in .local, or a bitmap resource ID in a DLL
Size of one move horizontally (pixels)
Size of one move vertically
Horizontal size of all bitmaps (pixels)
Vertical size of all bitmaps
Time delay between moves (ms)
Startx and starty are the initial bitmap position, and parentdialog is stored in the ParentDlg attribute.
Two more values are initialized in the stem variable:
Set to 1 for smooth edge change (can be changed to 0 for a bouncy edge change)
Set to 1 as the step size between sprite.from and sprite.to for bitmaps in a DLL
Set all the sprite. animation values using a stem:
mysprite.from = .array~of(bmp1,bmp2,...) mysprite.to = 0 mysprite.movex = ... ... self~setSprite(mysprite.)
Retrieve the animation values into a stem:
Set bitmap information (sprite.from and sprite.to):
Set size of one move (sprite.movex and sprite.movey):
Set delay between moves in milliseconds (sprite.delay):
Set smooth (1) or bouncy (0) edges (sprite.smooth):
self~setSmooth(smooth) /* 1 or 0 */
Set the step size (sprite.step) between sprite.from and sprite.to for bitmaps in a DLL, for example, if bitmap resources are numbered 202, 204, 206, etc:
Run the animation by going through all the bitmaps repetitively until dialog is stopped; invokes MoveSeq:
Animate one sequence through all the bitmaps in the given move steps; invokes MovePos:
Move the bitmaps by the arguments:
Move the bitmaps in the predefined steps to the given position; invokes MoveSeq:
Set the new starting position of the bitmaps:
Retrieve the current position into a stem:
self~getPos(pos.) say "pos=" pos.x pos.y
Check the parent dialog window and return its finished attribute (1 means finished)
Stop animation by setting the stopped attribute to 1
Invoked by run when the bitmap hits the right edge (returns 1 and bitmap starts at left again; you can return 0 and set the new position yourself)
Invoked when the bitmap hits the left edge (default action is to start at right again)
Invoked when the bitmap hits the bottom edge (default action is to start at top again)
Invoked when the bitmap hits the top edge (default action is to start at bottom again)
To use an animated button a dialog has to:
Define a button in a resource file (owner-drawn)
Load the bitmaps of the animation into memory using an array
Initialize the animated button with the animation parameters
Invoke the run method of the animated button
Stop the animation and remove the bitmaps from memory
The dialog may also dynamically change the parameters (for example, the size of a move, or the speed) and override actions, such as hitting an edge.
See the oowalker.rex and oowalk2.rex examples in OODIALOG\SAMPLES.
For further information see ConnectAnimatedButton.