gpt4 book ai didi

空气处理 adt flex

转载 作者:行者123 更新时间:2023-12-04 07:04:46 28 4
gpt4 key购买 nike

我有两个空中应用程序并将它们安装在桌面上并执行它们,并且任务栏管理器中列出了两个空中进程。现在如何从另一个空中应用程序执行一个空中应用程序的某些方法?

最佳答案

使用LocalConnection .

您可以在一个 AIR 应用程序中托管连接并从另一个 AIR 人员连接...从那里 - 您可以调用方法。

注意:LocalConnection 可能有点棘手和奇怪(例如,连接是全局的并且名称不能重叠)。

从上面列出的示例文档中......

// Code in LocalConnectionSenderExample.as
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.net.LocalConnection;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.events.StatusEvent;
import flash.text.TextFieldAutoSize;

public class LocalConnectionSenderExample extends Sprite {
private var conn:LocalConnection;

// UI elements
private var messageLabel:TextField;
private var message:TextField;
private var sendBtn:Sprite;

public function LocalConnectionSenderExample() {
buildUI();
sendBtn.addEventListener(MouseEvent.CLICK, sendMessage);
conn = new LocalConnection();
conn.addEventListener(StatusEvent.STATUS, onStatus);
}

private function sendMessage(event:MouseEvent):void {
conn.send("myConnection", "lcHandler", message.text);
}

private function onStatus(event:StatusEvent):void {
switch (event.level) {
case "status":
trace("LocalConnection.send() succeeded");
break;
case "error":
trace("LocalConnection.send() failed");
break;
}
}

private function buildUI():void {
const hPadding:uint = 5;
// messageLabel
messageLabel = new TextField();
messageLabel.x = 10;
messageLabel.y = 10;
messageLabel.text = "Text to send:";
messageLabel.autoSize = TextFieldAutoSize.LEFT;
addChild(messageLabel);

// message
message = new TextField();
message.x = messageLabel.x + messageLabel.width + hPadding;
message.y = 10;
message.width = 120;
message.height = 20;
message.background = true;
message.border = true;
message.type = TextFieldType.INPUT;
addChild(message);

// sendBtn
sendBtn = new Sprite();
sendBtn.x = message.x + message.width + hPadding;
sendBtn.y = 10;
var sendLbl:TextField = new TextField();
sendLbl.x = 1 + hPadding;
sendLbl.y = 1;
sendLbl.selectable = false;
sendLbl.autoSize = TextFieldAutoSize.LEFT;
sendLbl.text = "Send";
sendBtn.addChild(sendLbl);
sendBtn.graphics.lineStyle(1);
sendBtn.graphics.beginFill(0xcccccc);
sendBtn.graphics.drawRoundRect(0, 0,
(sendLbl.width + 2 + hPadding + hPadding), (sendLbl.height + 2), 5, 5);
sendBtn.graphics.endFill();
addChild(sendBtn);
}
}
}


// Code in LocalConnectionReceiverExample.as
package {
import flash.display.Sprite;
import flash.net.LocalConnection;
import flash.text.TextField;

public class LocalConnectionReceiverExample extends Sprite {
private var conn:LocalConnection;
private var output:TextField;

public function LocalConnectionReceiverExample() {
buildUI();

conn = new LocalConnection();
conn.client = this;
try {
conn.connect("myConnection");
} catch (error:ArgumentError) {
trace("Can't connect...the connection name is already
being used by another SWF");
}
}

public function lcHandler(msg:String):void {
output.appendText(msg + "\n");
}

private function buildUI():void {
output = new TextField();
output.background = true;
output.border = true;
output.wordWrap = true;
addChild(output);
}
}
}

关于空气处理 adt flex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1286307/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com