Suppose you are developing some kind of a Delphi application designed to display various graphics file formats. By default, Delphi lets you handle and show BMP, JPG, WMF and other "standard" picture file formats, and even animations. If you want to take you application to the next level, sooner or later, you'll want to include an option to play Flash animations. Macromedia Flash animations (*.swf) are those fancy movies you see everyday while surfing the Internet.
How to prepare for Flash animations
To display a Flash animation in a Delphi application, you'll need to import Macromedia Flash ActiveX control. The Flash ActiveX is titled 'SWFLASH.OCX' and it will probably be located somewhere inside the C:\Windows\System\Macromed\Flash folder.
First, let's see how to import the control into Delphi - of course, you only need to do this once:
- Start Delphi and select Component | Import ActiveX Control... from the main menu

- Select the Component palette location in which you want to place selected library. Maybe the best is to leave the ActiveX option selected.

- Click on Install.
- Select a package where the new component must be installed or create a new package for the control. By default, Delphi will propose the dclusr.dpk package.
- Click on OK.
- Delphi will prompt you whether you want to rebuild the modified/new package or not. Click on Yes.
- After the package is compiled, you'll get a message saying that the new TShokwaveFlash component was registered and already available as part of the VCL.
- Close the package detail window, allowing Delphi to save the changes to it.
- The component is now available in the ActiveX tab (if you didn't change this setting in step 4)
You are now ready to create your fist Flash enabled Delphi application. Here's how:
- Select the ActiveX tab on the Component palette.
- Pick the TShokwaveFlash component.
- Drop the component on a form.
- Select the component you just dropped on a blank form.
- Using the object inspector, set the Movie property to the name of an existing swf file on your system. Note that you must set it with the full path name.
- Make sure that the Playing property is set to True.
- Run the project, and here it is! A sample swf file is running below, though you do not see it running :)

No comments:
Post a Comment