flex属性值在不同mxml中使用
有两个mxml文件,a.mxmlb.mxml在a里面当鼠标经过一个label时,,需要把label的ID传给b里面使用。怎么做??是注册监听器吗?不太明白。能写个小例子吗...
有两个mxml文件,a.mxml b.mxml
在a里面当鼠标经过一个label时,,需要把label的ID传给b里面使用。
怎么做??
是注册监听器吗?
不太明白。
能写个小例子吗 展开
在a里面当鼠标经过一个label时,,需要把label的ID传给b里面使用。
怎么做??
是注册监听器吗?
不太明白。
能写个小例子吗 展开
1个回答
展开全部
在a的鼠标经过label时,派发一个自定义事件,在b中监听就可以了!
a.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import manager.TestManager;
private var instance:TestManager=TestManager.getInstance();
private function mouseOverHandler():void{
instance.msg=label2.id;
}
]]>
</mx:Script>
<mx:Label id="label2" text="mouseOver" mouseOver="mouseOverHandler()"/>
</mx:Canvas>
----------------------------------------------------------------------
b.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import manager.TestManager;
[Bindable]
private var instance:TestManager=TestManager.getInstance();
]]>
</mx:Script>
<mx:TextArea id="msg_txt" text="{instance.msg}"/>
</mx:Canvas>
----------------------------------------------------------------------
TestManeger.as
package manager
{
import flash.events.EventDispatcher;
[Bindable]
public class TestManager extends EventDispatcher
{
private static var _instance:TestManager;
public var msg:String;
public static function getInstance():TestManager{
if(_instance==null) _instance = new TestManager();
return _instance;
}
}
}
a.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import manager.TestManager;
private var instance:TestManager=TestManager.getInstance();
private function mouseOverHandler():void{
instance.msg=label2.id;
}
]]>
</mx:Script>
<mx:Label id="label2" text="mouseOver" mouseOver="mouseOverHandler()"/>
</mx:Canvas>
----------------------------------------------------------------------
b.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import manager.TestManager;
[Bindable]
private var instance:TestManager=TestManager.getInstance();
]]>
</mx:Script>
<mx:TextArea id="msg_txt" text="{instance.msg}"/>
</mx:Canvas>
----------------------------------------------------------------------
TestManeger.as
package manager
{
import flash.events.EventDispatcher;
[Bindable]
public class TestManager extends EventDispatcher
{
private static var _instance:TestManager;
public var msg:String;
public static function getInstance():TestManager{
if(_instance==null) _instance = new TestManager();
return _instance;
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询