Delphi itself is difficult to implement some Very dazzling or flexible animation changes, Flash is to achieve these are more common functions, is there a way to combine Delphi and flash?
The answer is yes. How can I use it?
(1) install swflash. ocx in Delphi and run flash in other environments.
Find it in $ WINDOWS \ SYSTEM \ macromed \ flash in Win98 or in $ winnt \ system32 \ macromed \ flash in Win2000.
After running Delphi, select component → import ActiveX Control and find the swflash. ocx file for installation. After the installation is complete, the tshockwaveflash control appears in the ActiveX panel.
The encapsulation of swflash. ocx enables you to use the Delphi language to control flash in the Delphi environment.
(2) how to make Delphi interact with Flash
You need to solve two problems: running the hosts file.
Question 1: Delphi receives flash messages
Flash sends messages to delphi. You only need to use the fscommand in flash. This command exists in various flash versions that the author can see,
For example, in qqp_528flash.swf ):
// Code in flash
On (click ){
Fscommand ("Test", "flash sends messages to the delphi Program ");
}
The following is the receiving code used in delphi:
Procedure TFrmMain. Flash1FSCommand (Sender: TObject; const command,
Args: WideString );
Begin
If command = 'test' then
Showmessage (ARGs );
End;
The tshockwaveflash control contains an event that specifically receives commands ".
Question 2: Delphi sends commands to flash
For Delphi, The Execution Code is as follows:
Flash1.setvariable ('test', 'this is what Delphi transfers to flash ');
The component named "test" must exist in the executed flash. It must be a text component (required) followed by the transmitted content. After the command is executed, the input "this is uploaded by Delphi to flash" will be displayed in the text component named test in flash.
Segment Content.
(3) If you want to implement drag and drop events for flash in Delphi, there is a way not to send commands to flash.
TShockwaveFlash = class(ShockwaveFlashObjects_TLB.TShockwaveFlash) protected { TWinControl } procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST; end; procedure TShockwaveFlash.WMNCHitTest(var Message: TWMNCHitTest); begin Message.Result := HTTRANSPARENT; end;
This function means to tell the mouse that it is null. In this case, you only need to implement the relevant method of the flash control.
Delphi controls flash in many aspects, such as playing, stopping, and starting from which frame. For details, see the tshockwaveflash control.