DelphiFlash

delphi与flash交互具体存在两个问题:
1、如何能让delphi应用程序接收到flash发来的消息,并处理;

2、怎样能从delphi应用程序向flash传递命令,控制.swf文件的运行。

一、flash向delphi发送消息:
      flash向delphi发送消息运用flash中自带的fscommand命令即可。


 第一步(flash中Button添加script):
on (release) {
  var userCode = editCode.text
  var userName = editName.text;
  fscommand("btSubmit", userCode+","+userName); //这样传入args
}
   flash中某一元件的单击事件会触发fscommand命令了,其中参数“btSubmit”是命令,后面的就是命令的值。


   以下为在delphi中使用的接收代码:
procedure TFrmMain.Flash1FSCommand(Sender: TObject; const command,
args: WideString);
begin
  If Command='btSubmit' Then
      ShowMessage(args);
end;
在TShockwaveFlash控件中已经存在了专门接收命令的事件了"OnFSCommand",其它的就很清楚了。


二、delphi向flash传递指令:
    delphi方面,执行代码如下:
    Flash1.SetVariable('btSubmittoflash','这是delphi向flash传的');
    flash中必需存在变量名为"btSubmittoflash"的元件,应为文本元件(必须),后面是传递的内容。执行后会在flash中名为btSubmittoflash的文本元件中显示传入的“这是delphi向flash传的”这段内容。

三、由于播放Flash的时候,点击右键会出现诸如放大,缩小的flash控件的字样,所以最好屏蔽右键。
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;  var Handled: Boolean);
var
  mPoint : TPoint;
begin
  //if IsChild(Flash1.Handle, Msg.Hwnd) then
  if   ((Msg.Message = WM_RBUTTONDOWN) or (Msg.Message = WM_RBUTTONUP))  then
  begin
    GetCursorPos(mPoint);
    //如果去掉下面这行就是屏蔽右键菜单,不去掉为自定义右键菜单
    PopupMenu1.Popup(mPoint.X, mPoint.Y);
    Handled:=True;
  end;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  Application.OnMessage := ApplicationEvents1Message;  //屏蔽Flash右键菜单,或弹出自定义右键菜单
end;

===========(背景透明)============
wmode参数值为transparent


 

原文地址:https://www.cnblogs.com/doorsky/p/1502671.html