ÈçºÎ´Ó itemRenderer ÖзÖÅÉʼþ[Flex][·Òë]
ÔÎÄ£ºHow to dispatch an event from a custom item renderer
´Ó MXML ×é¼þÖзÖÅÉʼþ²¢²»À§ÄÑ£¬µ«ÊÇÏëÒª´Ó itemRenderer ÖзÖÅÉʼþ¾ÍûÓÐÄÇôֱ½ÓÁË¡£ÏÂÎÄÖУ¬ÎÒÃǽ«»Ø¹ËÒ»ÏÂÕâÁ½ÖÖÇé¿öµÄ´¦Àí·½Ê½²¢ÕÒ³öÒ»¸öºÏÊʵĽâ¾ö·½°¸¡£
Õý³£Çé¿öÏ£¬µ±ÄãÏë´Ó MXML ×é¼þÖзÖÅÉÒ»¸öʼþʱ»áʹÓÃÈçϵÄÔªÊý¾Ý±êÇ©£º
<!-- дÔÚij¸ö×é¼þÖÐ -->
<mx:metadata>[Event(name="myEvent")]</mx:metadata>
ÔªÊý¾Ý±êÇ©ÈÃÄãÄÜÔÚÁíÒ»¸öÀàÖÐÒÔÈçÏ·½Ê½¼àÌýʼþ£º
<!-- дÔÚµ÷ÓÃÉÏÃ涨ÒåµÄÄǸö×é¼þµÄÀàÖÐ -->
<nw:somecomponent myEvent="onSomeEventHandler(event)"/>
×îºó£¬µ±ÄãÏëÔÚ×é¼þÖзÖÅÉʼþʱ¿ÉÒÔÊÖ¹¤µÄʹÓà dispatchEvent() ·½·¨À´·ÖÅÉ¡£
µ«ÊÇÈç¹ûÄãÊÇÏë´ÓÒ»¸ö×÷Ϊ itemRenderer µÄ×é¼þÖзÖÅÉʼþµÄ»°»áÈçºÎÄØ£¿¿¼ÂÇÒ»ÏÂÒÔϵÄÇé¿ö£º
ÔÚ Flex Ó¦ÓóÌÐòÖÐн¨Ò»¸ö List ×é¼þ¡£È»ºóн¨Ò»¸ö°üº¬ÓÐ RadioButton µÄ×é¼þÓÃÓÚ List µÄ itemRenderer¡£µ±Óû§µ¥»÷ RadioButton ʱ£¬¿ÉÄÜÄã»áÏëÈÃËûµÄ¸¸×é¼þ List ²úÉúÒ»¸öʼþ¡£
µ«ÊÇÈçϵĴúÂë»á²úÉúÒ»¸ö±àÒëÆ÷´íÎó£¬ÒòΪ List ×é¼þ²¢Ã»ÓГmyEvent”ÊôÐÔ£º
<!-- »á²úÉúÒ»¸ö±àÒëÆ÷´íÎó -->
<mx:list id="myList" dataprovider="{listData}"
itemRenderer="uk.nwebb.CustomRenderer"
myEvent="onSomeEventHandler(event)" />
ÓÉÓÚÎÒÃDz¢Ã»ÓÐʵÀý»¯×Ô¼ºµÄ itemRenderer£¬ÈçºÎ²ÅÄÜ»ñµÃ¹ã²¥³öÀ´µÄʼþÄØ£¿ÒªÏëʵÏÖÕâÑùµÄ¹¦ÄÜ£¬±ØÐëͨ¹ýÏÂÃæµÄÁ½¸ö²½Ö裺
Ê×ÏÈ£¬ÎÒÃDZØÐëÈÃÎÒÃÇ·ÖÅɵÄʼþÉϸ¡£¬Ö»ÒªÔÚ·½·¨ÖÐÌí¼ÓһЩ¶øÍâµÄ²ÎÊý¾Í¿ÉÒÔ×öµ½¡£ÈçÏÂÉèÖà bubble ºÍ cancelable ²ÎÊý£º
//дÔÚij¸ö×é¼þÖÐ
dispatchEvent("myEvent", true, true);
//ÓÉÓÚÔÎıȽÏÀÏ£¬ÉÏÃæÕâ¸öд·¨ÊÇ Flex 2 µÄ¡£Flex 3 µÄºóÃæÁ½¸ö²ÎÊýÒª¸³µ½ Event ʵÀýÀïÃæ¡£
//Flex 3 ´úÂëÈçÏÂ
dispatchEvent(new Event("myEvent", true, true));
ÏÖÔÚ List ×é¼þÈÔÈ»»¹ÊÇûÓÐ myEvent ÊôÐÔ¡£ÎªÁËÄÜÈà List ×é¼þ½ÓÊÕµ½ÉÏÃæ·ÖÅɵÄʼþ£¬ÎÒÃDZØÐëÈ·±£Õâ¸ö List ×é¼þÓÐ ID£¬È»ºó¿ÉÒÔÔÚ³õʼ»¯º¯Êý»òÕß creattionComplete º¯ÊýÖаó¶¨Ê¼þ£º
//дÔÚ´´½¨ List ×é¼þµÄÀàÖÐ
private function onInit():void
{
myList.addEventListener("myEvent", myEventHandler);
}
¾ÝÎÒËù
Ïà¹ØÎĵµ£º
1.¹ØÓÚflexµ÷ÊÔ³ö´íеĽâ¾ö˼·:³ýÁËÍøÉÏ˵µÄflash debug°æ±¾Ã»×°Íâ,nodɱ¶¾Èí¼þÒ²ÊÇÒ»¸öÎÊÌâ »¹ÓоÍÊǵ÷ÊÔģʽµÄÎÊÌâ Óб¾µØģʽºÍÔ¶³Ìģʽ ¾ßÌåÐ޸ķ½Ê½µ÷ÊÔ״̬ÏÂÓÒ»÷µ÷ÊÔÆ÷Ñ¡Ôñ×Ô¼ºÏëÒªµÄ. 2.flex°ó¶¨Êý×éɾ³ýÔªËغólistûÓиüÐÂÊý¾Ý ¿ÉÒÔÓÃinvalidateList() 3.progressBar½ø¶Èû¸üпÉÄÜÊÇmodeÉ趨µÄÔÒò ......
Flex (actionscript3.0)×Ö·û´®´¦ÀíÀàMyStringUtils.as
×öÏîÄ¿µÄ¹ý³ÌÖУ¬ÄÑÃâÒªÓõ½Ò»Ð©¸ö¹«¹²µÄ´¦ÀíÀ࣬±ÈÈç ×Ö·û´® ÈÕÆÚ ¸ñʽ»¯ Êý×éµÈ¡£±¾ÈËдµÄÒ»¸ö×Ö·û´®´¦ÀíÀ࣬ϣÍû´ó¼ÒÖ¸µã½»Á÷¡£
¹¦ÄÜ°üÀ¨£º
1,´¦ÀíxmlÏà¹ØµÄ×Ö·û£¬ÒòΪÔÚ¸úºǫ́java´ò½»µÀʱ£¬Õâ¸öÎÊÌâ¾³£Óöµ½:°ÑxmlÀïÃæµÄÌØÊâ×Ö·ûת»»³ÉÌæ´ú×Ö·û
2,ÅжϿÕ
3, ......
×î½üÓÃflexÀ´×öÒ»¸ö¹¤×÷Á÷¶¨Òå±à¼Æ÷¡£ÔÚÍøÉÏÕÒÁ˺ܶàÀý×Ó£¬Ò²Ñ§µ½Á˲»ÉÙ¶«Î÷¡£
flexÊÇadobe¹«Ë¾³öµÄ¶ÔÓÚflashµÄÒ»¸ö²úÆ·¡£¶ÔÓÚѧ¹ýjavaµÄÈËÀ´ËµÔÙ¼òµ¥²»¹ýÁË¡£ÕâÀïÒ²²»¶à˵ÁË£¬¾Í¶ÔÓÚÕ⼸ÌìÔÚÏîÄ¿ÖÐÓöµ½µÄÎÊÌâ̸һÏÂ×Ô¼ºµÄ½â¾ö·½·¨ÓëÈÏʶ¡£
Ò»¡¢flexÖн«×Ô¼ºµÄÒ»¸öCanvas±ä³ÉΪͼƬ£¬±£´æµ½±¾µØ¡£
var bitmapData ......
Flexƽ̨֧³Ö·¶Î§¹ã·ºµÄ·¢²¼Ä£Ê½£¬ËüÃÇÊÇ£º
1. ¿Í»§¶Ëģʽ£¬¼´Ó¦ÓóÌÐòÖ»ÔËÐÐÔÚ¿Í»§¶ËÉ϶ø²»ÐèÒª·þÎñÆ÷×ÊÔ´¡£
2. ʹÓüòµ¥µÄRPC ·ÃÎÊ·þÎñÆ÷Êý¾Ý£¬ ¼´Ê¹ÓÃHTTPService £¨HTTP GET»òPOSTÇëÇó£©
ºÍ WebService£¨Í¨¹ýʹÓÃSOAP£© ¡£
3. Flex Data Servicesģʽ£¬¿ÉÒÔÌṩ¸üΪ¸ß¼¶µÄÌØÐÔ£¬È ......