简体   繁体   English

AS3:使用外部SWF中的按钮

[英]AS3: use buttons in external swf

I am making a website in Adobe Flash that imports it´s navigation buttons from an external swf-file. 我正在Adobe Flash中创建一个网站,该网站从外部swf文件导入其导航按钮。 The problem is how my Main FLA-file will know which of the navigation buttons the users has pressed, since the buttons and it's eventListeners are in the external swf-file. 问题是我的主FLA文件如何知道用户按下了哪个导航按钮,因为这些按钮及其事件监听器位于外部swf文件中。

With other word: can I make my external swf-file return a Number to my website FLA-file, to determine which button that have been pressed? 换句话说:我可以使我的外部swf文件向我的网站FLA文件返回一个数字,以确定已按下哪个按钮吗? If so, how? 如果是这样,怎么办?

You can set up a connection between the external swf and main swf using the LocalConnection() 您可以使用LocalConnection()在外部SWF和主SWF之间建立连接

In main.swf 在main.swf中

var sending_lc:LocalConnection;
sending_lc = new LocalConnection();

function send_it(evt:MouseEvent):void 
{
    sending_lc.send("connectionName", "functionName", "myData");
    //params are (connection name, function to execute in the receiving swf, the data to pass through)
}

my_btn.addEventListener(MouseEvent.MOUSE_UP, send_it);

In exetrnal.swf 在exetrnal.swf中

var receiving_lc:LocalConnection;
receiving_lc = new LocalConnection();

receiving_lc.connect("connectionName");
receiving_lc.client = this;

function functionName(data:String):void {
trace(data);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM