Selasa, 22 Juli 2008

FLASH DI DELPHI

Bagi programmer yang ingin memainkan FLASH DI DELPHI dengan senang hati saya berikan suatu contoh program sederhana yang sourcenya sebagai berikut :
{
Menggunakan swf file di kamu delphi aplikasi kamu harus punya swf plugin memasang kemudian ikut langkah ini:
Di delphi ide
- click on "Component", "Import ActiveX Control"
- chose "Shockwave Flash" and click on "install".
Now you have a TShockwaveFlash component in your IDE on the ActiveX tabsheet.Place the TShockwaveFlash Component onto your form, resize it as needed but for now do not assign a movie to it.
You will need to register the ocx file if it is not installed on the target computer. So you should have a resource file with

Sekarang kamu punya komponen tshockwaveflash di activex tabsheet. Tempat komponen di form.Kamu akan perlu mendaftarkan ocx file jika ini tidak memasang di komputer sasaran. Kamu harus punya file sumber dengan

- the swflash.ocx and your Flash ( *.swf) file.
- Copy swflash.ocx (from i.e. windows\system32\macromed\flash) and your custom swf file to your project path.
- Create a textfile with a code like this:
SHOCKWAVEFILE RCDATA yourfile.swf
SHOCKWAVEOCX RCDATA swflash.ocx
(Where yourfile.swf is your swf-file)
- Simpan file dengan nama flash.rc
- lompat ke line tertentu , ubah direktorinya and dan tulis:
"Brcc32 -r flash.rc"
}
{************************************************************}
uses ShockwaveFlashObjects_TLB; // will be used automatically
{...}
implementation
{$R *.DFM}
{$R flash.res} // your new created resource
{...}

procedure TForm1.FormCreate(Sender: TObject);
var
SystemDir : array[0..MAX_PATH] of Char;
SWFDir, AppDir: String;
Fres: TResourceStream;
Ffile: TFileStream;
begin
GetSystemDirectory(@SystemDir,MAX_PATH);
SWFDir := SystemDir+'\macromed\flash\';
GetDir(0,AppDir); // Get current directory

//check whether the sw-flash ocx is already installed
if fileexists(SWFDir+'swflash.ocx')=false then begin
//create directories if needed and extract file from resource.
{$i-} //compiler directive to suppress i/o error messages
MkDir(SystemDir+'\macromed');
MKDir(SystemDir+'\macromed\flash');
{$i+}
Fres := TResourceStream.Create(0,'SHOCKWAVEOCX',RT_RCDATA);
Ffile := TFileStream.Create(SWFDir+'swflash.ocx',fmCreate);
Ffile.CopyFrom(Fres,Fres.Size);
Fres.Free;
Ffile.Free;

//register ocx (simple but useful)
winexec(PChar('regsvr32 /s '+SWFDir+'swflash.ocx'),SW_HIDE);
end;
// extract ShockwaveFile from resource to application directory
Fres := TResourceStream.Create(0,'SHOCKWAVEFILE',RT_RCDATA);
Ffile := TFileStream.Create('flashmovie.swf',fmCreate);
Ffile.CopyFrom(Fres,Fres.Size);
Fres.Free;
Ffile.Free;

//Assign the extracted swf file to your TShockwaveFlash object
FlashMovie.Movie := AppDir+'\flashmovie.swf';
end;

{
Jika kamu tidak mau punya popup menu ditampilkan di programmu dan memilih menu tshockwave ke false
}
Semoga dapat membantu, tapi jika anda tidak mengerti bahasa inggris diatas anda bisa mendownload Translator XP di artikel saya di Translator XP

Tidak ada komentar: