【发布时间】:2017-01-04 13:16:31
【问题描述】:
我在 Apache/Adobe Flex 4 中有一个 WindowedApplication,它当前包含一个视图(在 WindowedApplication MXML 中定义的视图)。
在那个应用程序中,我有一个对象可以监听来自网络的数据。当数据可用时,对该对象调用一个方法,它会通过更改标签的文本来更新我的视图。
虽然我没有对网络侦听器对象中的视图的引用。我怎样才能得到它?
这是我定义视图的 MXML 的一部分。
<fx:Script source="./ViewCodeBehind.as"/>
<!-- ommited stuff -->
<s:Label id="errorLabel"
text=""
fontSize="14"/>
<!-- Stuff in between -->
<s:Button label="Get Status"
click="getStatus();"/>
点击按钮时调用的代码:
public function getStatus(): void
{
var networkGateway: NetworkGateway = new NetworkGatewayImpl();
networkGateway.getConnectionStatus();
}
还有 NetworkGatewayImpl
public class NetworkGatewayImpl implements NetworkGateway
{
public function NetworkGatewayImpl()
{
}
public function getConnectionStatus(): void
{
// Start asynchronous network call
// when error occurs onNetworkError() is called
}
private function onNetworkError(): void
{
// Set "errorLabel" here: How?
}
}
基本上我想知道一些从 NetworkGatewayImpl 更新“errorLabel”的方法。
【问题讨论】:
-
请发布一些代码,让我们确切知道您面临的问题?
-
添加了相关代码。
标签: actionscript-3 apache-flex air flex4 mxml