Today, when Flash is so popular, have you ever thought about adding a few pieces of Flash to your program to show off? Let's try it. The premise is that you have to install flash playback software (your IE can display flash). The reason why IE can display flash is that a swflash.ocx control is installed, provided by Macromedia, Inc., and we also use it. Yes, win98 is under $WindowsSystemMacromedFlash, and win2k is under $WinntSystem32MacromedFlash. ActiveX controls are common in Windows, and of course Delphi also supports them. Open your Delphi and let's get started. Select the menu Component --> Import ActiveX Control, select the SWFlash.OCX file, and install it. After completion, the TShockwaveFlash control will appear in the ActiveX panel. This is delphi's encapsulation of SWFlash.OCX. Now we can use this control to play flash. Drag one over and place it on the form, specify its Movie attribute as d: est.SWF, press F9, and everything is OK. Delphi programming is so easy and comfortable.
TShockwaveFlash main properties, methods, events
property:
ReadyState - The state when reading a flash file. 0=Loading, 1=Uninitialized, 2=Loaded, 3=Interactive, 4=Complete.
TotalFrames - Total frames, only accessible when ReadyState = 4.
FrameNum - The currently playing frame.
Playing - Play or pause a flash.
Quality - Specifies the quality of the current rendering, 0=Low, 1=High, 2=AutoLow, 3=AutoHigh
ScaleMode - Scale mode, 0=ShowAll, 1= NoBorder, 2 = ExactFit.
AlignMode - Alignment mode, Left=+1, Right=+2, Top=+4, Bottom=+8.
BackgroundColor - background color, red*65536+green*256+blue, -1 is the default color.
Loop - Whether to loop.
Movie - specifies the path of the flash file to be played, which can be a URL.
method:
Play() - Start playing the animation.
Stop() - Stops the animation.
Back() - Plays the previous frame of animation.
Forward() - Plays the next frame of animation.
Rewind() - Play the first frame of animation.
SetZoomRect(int left, int top, int right, int bottom) - Set the zoom area
Zoom(int percent) - Zoom by percentage.
Pan(int x, int y, int mode) - Zoom the playback panel. The mode is: 0-by number of pixels, 1-by window percentage
event:
OnPRogress(int percent) - triggered when reading a flash.
OnReadyStateChange(int state) - Fires when the state changes. states can be 0=Loading, 1=Uninitialized, 2=Loaded, 3=Interactive, 4=Complete.
For specific help, please see http://www.macromedia.com/support/flash/
This is my work on a whim. Please correct me for any shortcomings. Anyone who is interested is welcome to discuss it together ([email protected]).