0

I have never worked on action script. need help with listener. I am calling and event DrawManager.ZOOM_TO_SELECTION but need to wait for this event to finish before I call the next function "saveMapImage". Can anyone tell me how to do that with a code example?

    public function saveMapImageAndForward(projectLocationWKT:String, projectMapType:String, hasMapImageFromIPaCMap:String, projectName:String):void {
        this.projectLocationWKT = projectLocationWKT;
        this.projectMapType = projectMapType;
        this.hasMapImageFromIPaCMap = hasMapImageFromIPaCMap;
        this.projectName = projectName;

        //GlobalDispatcher.dispatchEvent(new Event(Event.COMPLETE));

         GlobalDispatcher.dispatchEvent(new AppEvent(DrawManager.ZOOM_TO_SELECTION));

        //GlobalDispatcher.removeEventListener

        saveMapImage();
    }

Thanks in advance.

4

1 回答 1

0
public function someFunctionCalledAheadOfTime():void
{
    .
    .
    .
    GlobalDispatcher.addEventListener(DrawManager.ZOOM_TO_SELECTION, saveMapImage);
    .
    .
    .
}

public function saveMapImageAndForward(projectLocationWKT:String, projectMapType:String, hasMapImageFromIPaCMap:String, projectName:String):void {
    this.projectLocationWKT = projectLocationWKT;
    this.projectMapType = projectMapType;
    this.hasMapImageFromIPaCMap = hasMapImageFromIPaCMap;
    this.projectName = projectName;

    //GlobalDispatcher.dispatchEvent(new Event(Event.COMPLETE));

     GlobalDispatcher.dispatchEvent(new AppEvent(DrawManager.ZOOM_TO_SELECTION));

    //GlobalDispatcher.removeEventListener

    //saveMapImage();
}

private function saveMapImage(pEvent:AppEvent):void
{
    .
    .
    .
}

编辑:看起来 AppEvent 不是一个非常标准的类,它可能是你自己的。我基于 AppEvent 继承自 Event 的假设,并且单参数构造函数的工作方式与常规 Event 的情况相同。

于 2013-05-22T19:05:30.103 回答