FlexÒì²½ÁîÅÆAsyncTokenµÄÓ÷¨½éÉÜ
ʲôÊÇAsyncToken£¿¹Ù·½ÎĵµÊÇÕâÑùÃèÊöµÄ£º"Õâ¸öÀàÕë¶ÔÒì²½RPC²Ù×÷ÌṩÁËÒ»¸öÓÃÀ´ÉèÖöîÍâµÄ»òÕßÁîÅƼ¶Êý¾ÝµÄµØ·½¡£ËüÒ²ÔÊÐíÒ»¸öIResponder×÷Ϊһ¸ö¶ÀÁ¢µ÷Óñ»¸½¼Ó¡£Õâ¸öAsyncTokenÄܹ»ÔÚResultEventºÍFaultEventÖÐÓÃtokenÊôÐÔÀ´ÒýÓá£"
Èç¹ûÄã¶ÔFlexÖÐÔ¶³ÌÒì²½µ÷Óõı¾Öʲ»ÊìϤ£¬¿Ï¶¨»¹ÊÇÓеãÀ§»óµÄ¡£ÎÒÅö¼û¹ý´óÁ¿µÄ¶ÔÕâ¸ö±ã½ÝÀ಻ÊìϤµÄÈË£¬Òò´ËÎÒÊÔ×ÅÀ´ÈÃËüÃ÷ÀÊÒ»µã¡£
ÎÞÂÛºÎʱ´ÓÄãµÄflex/AIRÓ¦ÓÃÖÐʹÓöà¸öÍⲿµ÷ÓÃÖеÄÒ»¸ö£¬Ä㶼²»»áÖªµÀÕâЩµ÷ÓÃÊÇ·ñ»òÕߺÎʱ·µ»Ø½á¹û£¨»òÕß´íÎ󣩣¬ÄãÒ²²»»áÖªµÀËüÃÇ·µ»ØµÄ˳Ðò¡£¼´Ê¹Äã°´ÕÕ"RO1","RO2","RO3"µÄ˳Ðòµ÷ÓÃÔ¶³Ì¶ÔÏó£¬ËüÃÇ·µ»ØµÄ˳Ðò»¹ÊÇ¿ÉÄܲ»Ò»Ñù¡£Äã¿ÉÄÜҲϣÍûÕë¶ÔÕâЩ½á¹ûÄÜÓв»Í¬µÄ´¦Àí¡£
Ò»ÖÖ·½Ê½¾ÍÊǸøÿһ¸öµ÷Ó÷ÖÅäÒ»¸öÒì²½ÁîÅÆ£¨AsyncToken £©À´×·×ÙÕâЩµ÷Óá£
²»ÒªÕâÑùÀ´½øÐÐÔ¶³Ìµ÷ÓÃ:
myRO.myRemoteMethod();
ÄãÓ¦¸ÃÕâÑù:
var token:AsyncToken=myRO.myRemoteMethod();(È·±£µ¼ÈëÁËmx.rpc.AsyncToken)
ÏÖÔÚ¾ÍÓÐÁËÒ»¸ö±äÁ¿"token",´ú±íÕâ¸öµ¥¶ÀµÄµ÷Óá£ÏñÕâÑù£¬Äã¿ÉÒÔ·ÖÅätoken×Ô¼ºµÄresultºÍfault´¦Àíº¯Êý
token.addResponder(myResponderClass);
ÕâÀïmyResponderClassÀàʵÏÖÁËIResponder.ʵÏÖIresponder¼òµ¥µÄÒâζ×Ŷ¨ÒåÁËÈçÏÂÁ½¸ö·½·¨Ç©Ãû£º
* public function result(data:Object):void
* public function fault(info:Object):void
Òò´ËÄã¿ÉÒÔ¶ÔÄãµÄÔ¶³Ìµ÷ÓÃÔÚµ÷ÓÃʱÉèÖÃresultºÍfault´¦Àíº¯Êý£¬¶ø²»ÓðÑÓ²±àÂë·Åµ½ÄãµÄÔ¶³Ì¶ÔÏó£¬HTTPService»òÕßWebService±êÇ©Àï¡£ÕâҲǡºÃ¾ÍÊÇCairngormºÍÆäËû΢Ìåϵ½á¹¹µÄÔËÐз½Ê½¡£
AsyncToken×îºóÒ»µãºÜ¿áµÄÌØÐÔ¾ÍÊÇËüÊǶ¯Ì¬Àà¡£ÕâÒâζ×Å£¬µ±Äã½øÐÐÔ¶³Ìµ÷ÓÃʱ¿ÉÒÔÌí¼ÓÊôÐÔµ½tokenÉÏ£¬È»ºóresult/fault´¦Àíº¯ÊýÖжÁÈ¡ÕâЩÊôÐÔ¡£
ÁíÍ⣬ÔÚflex sdk3.4ÖÐÓÐCallResponder£¬¿ÉÒ
Ïà¹ØÎĵµ£º
¾³£ÔÚDemoÖлῴµ½ÁÐ±í£¬±í¸ñµÈ·½Ê½À´ÏÔʾÊý¾Ý¡£µ±È»ÓÐʱºòÒ²ÐèÒªÌí¼ÓÊý¾Ýµ½ÕâЩÁбí»òÕß±í¸ñÖС£Óкܶ෽ʽÌá½»£¬ÕâÀïչʾһ¸öµ¯³ö´°¿ÚµÄ·½Ê½À´Ìí¼ÓеÄÊý¾Ýµ½DataGridÖС£
Àý×Óչʾ£º
Ê×ÏÈ£¬ÎÒÃÇ¿ªÊ¼½¨ÉèÒ»¸ö»ù±¾µÄ½çÃæ½á¹¹£¬Ò»¸ö´øÓГNotes"±êÌâµÄPanel,Ò»¸öDataGrid£¬ÒÔ¼°Ò»¸öÓÃÓÚÌá½»Êý¾ÝµÄ°´Å¥¡£
<?xml ......
<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate the Zoom effect. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
">
<mx:Style source="style/style.css"/>
<mx:Scri ......
modeÓÐÈýÖÖģʽ£ºProgressBarMode.EVENT£¬ProgressBarMode.POLLED £¬ProgressBarMode.MANUAL £¬Ê¼þģʽºÍÂÖѯģʽÊÇ×î³£ÓõÄģʽ¡£ ÔÚʼþģʽÏ£¬source ÊôÐÔÖ¸¶¨Éú³É progress ºÍ complete ʼþµÄ¼ÓÔØÄÚÈÝ£»ÔÚ´ËģʽÏ£¬Ó¦Ê¹Óà UILoader ¶ÔÏó¡£ ÔÚÂÖѯģʽÏ£¬source ÊôÐÔÖ¸¶¨¹«¿ª bytes ......
ͨ¹ýFlexÖеÄTimer¿ÉÊÇʵÏÖÊý×ÖʱÖÓµÄЧ¹û£¬ÆäЧ¹ûͼÈçÏ£º
ʵÏֵĴúÂëÈçÏ£º
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<!--[CDATA[
import mx.formatters.DateFormatt ......