Search code examples
delphiflashdelphi-7

execute swf in delphi7


I am trying to create something like a "preloader" in Delphi 7: when the user loads a file or executes a procedure that takes a while, I want to have an indicator that shows him that the procedure is working but he has to wait a bit.

I have in mind a loading bar or a spinning circle, if necessary without showing the percentage that has been loaded or the remaining percentage.

I created a spinning circle in flash but I can't find a way to use in Delphi 7.

I tried to call my swf "preloader" through an Animate Control but failed because it is only compatible with avi files.

I also downloaded a free spinning circle in .gif and tried to add it to my Delphi project in an Image Control but this also failed, because the image isn't compatible with gif format.

Is there any way to create this knd of "preloader" in Delphi or add one through an external swf or gif resource file ? How can this be implemented?


Solution

  • After searching internet forums for many days I found the following solution. First you have to have already installed Flash player (not the Flash web-designer of the Adobe suite). If not then close Delphi and visit the Adobe's website. From there you should download the appropriate flash player according to your OS. After you have installed or if you already have installed Flash player then follow the below procedure:

    1. Open Delphi and go to menu→Component→Import ActiveX Control. You will see a dialog box. Inside this dialog box you will see a list of components. From this list search and find the "Shockwave flash" component. Check it and press install. Then Delphi will ask you some questions which you don't have to spend time, just press the "ok" button.

    2. After finishing with the 3-4 dialog boxes, Delphi will eventually add a new component to the "ActiveX" tab. Open Delphi and choose the "ActiveX" tab, you will see the "ShockwaveFlash" component as the last control of this tab.

    3. In order to use it Select this control and put it in a form. Give the appropriate dimensions and the path and filename of the .swf (or .flv) file you want to play. Set properties "play", "loop" to true if you want to make it play continuously or put "loop" to false in order to make it play just once.

    Be aware: Not all properties of the control work as they should. If for example you want through code your file to be visible or to hide at your will (e.g. on the press event of a button) then you will find out that the control does not follow your orders.