The methods listed below work with animated buttons.
>>-aBaseDialog~AddAutoStartMethod(--+---------+--,--MethodName--+---------------+--)->< +-InClass-+ +-,--Parameters-+
The AddAutoStartMethod method adds a method name and parameters to a special internal queue. All methods in this queue will be started automatically and run concurrently when the dialog is executed. The given method (MethodName) in the given class (InClass) is started concurrently with the dialog when the dialog is activated using the Execute or ExecuteAsync method. This is useful for processing animated buttons.
The arguments are:
The class where the method is defined. If this argument is omitted, the method is assumed to be defined in the dialog class.
The name of the method
All parameters that are passed to this method
The following example installs the ExecuteB method of the MyAnimatedButton class so that it is processed concurrently with the dialog execution:
MyDialog~AddAutoStartMethod("MyAnimatedButton", "ExecuteB") ::class MyAnimatedButton ::method ExecuteB . . .
>>-aBaseDialog~ConnectAnimatedButton(--id,--+------------+--,---> +-msgToRaise-+ >--+-----------+--,--bmpFrom--,--+-------+--,--moveX--,--moveY--,--> +-AutoClass-+ +-bmpTo-+ >--+-------+--,--+-------+--,--delay--,--+------+--,--+------+--)->< +-sizeX-+ +-sizeY-+ +-xNow-+ +-yNow-+
The ConnectAnimatedButton method installs an animated button and runs it concurrently with the main activity.
The arguments are:
The ID of the button
The name of a method within the same class. This method is called each time the button is clicked.
The class that controls the animation (default is AnimatedButton Class)
The ID of the first bitmap in the animation sequence within a binary resource. It can also be the name of an array stored in the .local directory containing handles of bitmaps to be animated and bmpTo is omitted. See LoadBitmap for how to get bitmap handles. The array starts at index 1.
The ID of the last bitmap in the animation sequence within a binary resource. If omitted, bmpFrom is expected to be the name of an array stored in .local that holds the bitmap handles of the bitmaps that are to be animated.
Size of one move (in pixels)
Size of the bitmaps (if omitted, the size of the bitmaps is retrieved)
The time in milliseconds the method waits after each move
The starting position of the bitmap
The following example defines and runs an animated button. The example loads ten bitmaps ("anibmp1.bmp" to "anibmp10.bmp") into memory and stores them into the array "My.Bitmaps" that is stored in the .local directory. The name "My.Bitmaps" is specified as the bmpfrom and bmpto is omitted. After the dialog execution the bitmaps are removed from memory again. The sample also uses a different animation class (".MyAnimation") which subclasses from .AnimatedButton and overrides method HitRight which plays a tune each time the animated bitmap hits the right border.
/* store array in .local */ .Local["My.Bitmaps"] = .array~new(10) /* load 10 bitmaps into .local array */ do i= 1 to 10 .Local["My.Bitmaps"][i] = Dialog~LoadBitmap("anibmp"i".bmp") /* you could also use .My.Bitmaps[i] = ... */ end /* connect bitmap sequence and .MyAnimated class with button IDANI */ Dialog~ConnectAnimatedButton("IDANI", ,.MyAnimation,"My.Bitmaps", ,1,1, , ,100) ... Dialog~Execute ... /* Free the bitmap previously loaded */ do bmp over .Local["My.Bitmaps"] /* You could also use do bmp over .My.Bitmaps */ Dialog~RemoveBitmap(bmp) end ::class MyAnimation subclass AnimatedButton /* play sound.wav whenever the bitmap hits the right border */ ::method HitRight ret = Play("sound.wav", yes) return self~super:hitright