AsyncTokenä¸çæ¸ã
AsyncTokenã¯RemoteObjectã§ã®å¼ã³åºãã¤ãã³ãã¸ã®åç
§ããã¤ã¯ã©ã¹ã§ãã
ã¾ããã±ããã¨ãã£ã¦ããããããããªãã
ãªã®ã§RemoteObjectã¨ããã°ãAsyncTokenãããã®å¢ãã§ãã
ã§ãAsyncTokenã«æåæã¨å¤±ææã®ã¤ãã³ããItemResponderã®å½¢ã§æ¸¡ãã¦ããã¾ãã
é¢åãããããªãããã¯ãç¡åFunctionã2ã¤æ¸¡ãã¡ããæãã§ã
ã¨ãããã¨ã§ã³ã¼ããã¿ã¼ã³ã¨ãã¦ã¯ãä¸è¨ã®ããã«ãªãã¾ãã
var token:AsyncToken = remote.update(view.model.employee);//RemoteObjectã¯Dynamicã¯ã©ã¹ããã token.addResponder(new AsyncResponder( function(e:ResultEvent, o:Object=null):void { //æåæå¦ç }, function(e:FaultEvent, o:Object=null):void { //失ææå¦ç } ));
ã¤ã¸ã§ã¦ãAsyncTokenä¸çæ¸ãã§ããã
ä¸åº¦ããå®è¡ã§ããªãEventListener
id:c9katayamaã«æãã¦ããã£ã¦ã®ã§ç¡é§ã«ä½¿ã£ã¦ã¿ãã
ãããã¿ã³(button)ã¯ä¸åº¦ããåºæ¥ãªããã¨ãä¿éãããã¨ãã¦ã
å®è¡ããç¬éã«removeEventListenerãããã¨ããã
ãã ããå¥ã®ãã¿ã³(button2)ãæ¼ããããªã«ãã¼ãããã¨ããã
ãããªã¨ãã¯ã¾ãã¯ãããªã¦ã¼ãã£ãªãã£ãç¨æãã¦ããã¦ãããã¨ã
å®éã«å®è¡ãããFunctionããæ´ã«Functionã§ãã³ã¬ã¼ããã¦ãã£ã¦ã
removeEventListenerãå·®ãè¾¼ãã§ãã¾ãã®ããã¤ã³ãã
public static function addOnceEventListener(dispatcher:EventDispatcher, eventType:String,listener:Function):void{ var f:Function = function(e:Event):void{ dispatcher.removeEventListener(eventType,f); listener(e); }; dispatcher.addEventListener(eventType,f); }
ã§ãããã¤ãç¡é§ã«ãªã«ãã¼ããããã«ããã
ãã¤ã³ãã¯ä¸åº¦ã£ããã®ã¤ãã³ããå®è¡ããFunctionãæºåããFunctionãå®ç¾©ãã¡ããã¼ã£ã¦ã¨ããã
ï¼ä½è¨ã£ã¦ããããããªãã£ã¦ï½ï½ï½ï¼ï¼
ã§ãããã¤ãå³æå®è¡ããã®ã¨ãæ´ã«button2ãæ¼ãããã¨ãã«ãå®è¡ãããã¨ã
var once:Function = function():void { addOnceEventListener(button, MouseEvent.CLICK, function(e:MouseEvent):void { Alert.show("hoge"); } ); }; once.apply(); button2.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void { once.apply(); } );
ã§ããã
çµè«ãï½·ï¾ï½´ï½ï½ï½ï½ï½ï½ï½ï½ï½ï½