FlashCanvasControl.pas
上传用户:raido2005
上传日期:2022-06-22
资源大小:5044k
文件大小:2k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit FlashCanvasControl;
  2. interface
  3.  Uses Windows, FlashPlayerControl, FlashObjects, Classes;
  4. type
  5.   TFlashCanvasControl = class(TFlashPlayerControl)
  6.   private
  7.     FFlashMovie: TFlashMovie;
  8.     CurentDepth: word;
  9.     FVersionMovie: byte;
  10.     function GetFlashCanvas: TFlashCanvas;
  11.   public
  12.     constructor Create(AOwner: TComponent); override;
  13.     destructor Destroy; override;
  14.     property FlashMovie: TFlashMovie read FFlashMovie;
  15.     property FlashCanvas: TFlashCanvas read GetFlashCanvas;
  16.     procedure UpdateCanvas;
  17.   published
  18.     property VersionMovie: byte read FVersionMovie write FVersionMovie;
  19.   end;
  20. procedure Register;
  21. implementation
  22. Uses Forms, SWFConst, SWFObjects;
  23. constructor TFlashCanvasControl.Create(AOwner: TComponent);
  24. begin
  25.  inherited;
  26.   SAlign := 'LT';
  27.   Scale := 'NoScale'; 
  28.   FFlashMovie := TFlashMovie.Create(0, 0, twips * Screen.Width, twips * Screen.Height, 1);
  29.   FFlashMovie.SystemCoord := scPix;
  30.   FFlashMovie.Version := 6;
  31.   CurentDepth := 1;
  32. end;
  33. destructor TFlashCanvasControl.Destroy;
  34. begin
  35.   FFlashMovie.Free;
  36.   inherited;
  37. end;
  38. function TFlashCanvasControl.GetFlashCanvas: TFlashCanvas;
  39. begin
  40.   result := FFlashMovie.Canvas;
  41. end;
  42. procedure TFlashCanvasControl.UpdateCanvas;
  43.  var MS: TMemoryStream;
  44. begin
  45.   MS := TMemoryStream.Create;
  46.   if (FFlashMovie.ObjectList.Count > 0) and
  47.     (FFlashMovie.ObjectList[FFlashMovie.ObjectList.Count - 1] is TSWFShowFrame) then
  48.       FFlashMovie.ObjectList.Delete(FFlashMovie.ObjectList.Count - 1);
  49.   FFlashMovie.Canvas.Place(CurentDepth, true);
  50.   FFlashMovie.ShowFrame;
  51.   FFlashMovie.MakeStream;
  52.   FFlashMovie.SaveToStream(MS);
  53.   LoadMovieFromStream(0, MS);
  54.   MS.Free;
  55.   inc(CurentDepth);
  56. end;
  57. procedure Register;
  58. begin
  59.   RegisterComponents('Flash', [TFlashCanvasControl]);
  60. end;
  61. end.