dispatchEvent和eventListener

时间:2012-03-04 13:03:17

标签: flex module addeventlistener dispatchevent

MENU - RightNavigation

<fx:Metadata>
[Event(name="interval", type="flash.events.Event")]
<fx:Metadata>

[Bindable]
public var sInterval:String;
[Bindable]
public var sIntervalId:String;

protected function intervalSelected(event:MouseEvent):void
        {
            sInterval = intervalMenu.selectedItem.intervals_miles;
            sIntervalId = intervalMenu.selectedItem.interval_id;
            dispatchEvent(new Event("interval"));
        }

MENU - RightNavigation =这是菜单中的按钮

<s:VGroup includeIn="iMenu" width="100%" height="100%" horizontalAlign="center" paddingTop="10">
    <s:List id="intervalMenu" styleName="leftNavContent" creationComplete="miles_handler(event)"
        itemRenderer="renderers.MilesItemRenderer" click="intervalSelected(event)" >
    <s:AsyncListView list="{intervalsResult.lastResult}"/>
    </s:List>
</s:VGroup>

MODULE - mcIntervals

initialize="init()"

import containers.RightNavigation;
import mx.binding.utils.ChangeWatcher;
import flash.events.*;

[Bindable]
public var interval:RightNavigation;

public function init():void
        {   
            //addEventListener("interval", intervalServices);
            ChangeWatcher.watch(interval, "sIntervalId", intervalServices);
        }

protected function intervalServices(e:Event):void
        {
            Alert.show("test");
        }

应用程序设置

  

MainApp有两个容器RightNavigation和MainContent

     

MainContent有一个名为mcIntervals的模块

所以我试图将值从RightNavigation发送到mcIntervals

这是一个桌面应用程序,如果这有任何区别

这不起作用我可以看到在调试模式下发送值但是ChangeWatcher或者evenListener没有检测到任何内容

谢谢,罗伯特

0 个答案:

没有答案