ÈçºÎ´Ó 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);
}
¾ÝÎÒËù
Ïà¹ØÎĵµ£º
Ò»£ºÖ±½ÓÉèÖÃ
¶þ£º»ÃæÉÏÉèÖãº
È磺
<mx:Style>
TextArea{
font-size:36px
font-weight: bold
}
</mx:Style>
Èý£ºÊ¹ÓÃÍâÖÃÎļþ
<mx:Style source="style.csss"/> ......
³öÓÚ°²È«ÐÔ¿¼ÂÇÂú×ãÒÔÏÂÌõ¼þÖ®Ò»Flash Player²ÅÄÜ·ÃÎÊÔ¶³ÌÊý¾Ý£º
Ò»£ºÓ¦ÓóÌÐòËù±àÒëµÄswfÎļþÓëÔ¶³ÌÊý¾ÝÔ´ÔÚͬһ¸öÓòÖÐ
¶þ£ºÊ¹ÓôúÀí£¨Proxy£©£¬ÇÒswfÎļþºÍ´úÀíÔÚÏàͬµÄ·þÎñÆ÷ÉÏ¡£»òÕßʹÓÃweb½Å±¾ÓïÑÔÈçJSP£¬PHP£¬ASP´´½¨¼òµ¥µÄÊý¾Ý´úÀí
Èý£º°²×°crossdomain.xmlÎļþλÓÚÊý¾ÝÔ´ËÞÖ÷µÄweb·þÎñÆ÷ÉÏ ......
Flexƽ̨֧³Ö·¶Î§¹ã·ºµÄ·¢²¼Ä£Ê½£¬ËüÃÇÊÇ£º
1. ¿Í»§¶Ëģʽ£¬¼´Ó¦ÓóÌÐòÖ»ÔËÐÐÔÚ¿Í»§¶ËÉ϶ø²»ÐèÒª·þÎñÆ÷×ÊÔ´¡£
2. ʹÓüòµ¥µÄRPC ·ÃÎÊ·þÎñÆ÷Êý¾Ý£¬ ¼´Ê¹ÓÃHTTPService £¨HTTP GET»òPOSTÇëÇó£©
ºÍ WebService£¨Í¨¹ýʹÓÃSOAP£© ¡£
3. Flex Data Servicesģʽ£¬¿ÉÒÔÌṩ¸üΪ¸ß¼¶µÄÌØÐÔ£¬È ......
Flex Chart ËäÈ»ÓÐÌṩÍêÕûµÄÊÔÓù¦ÄÜ
²»¹ý±àÒëÍê³ÉµÄͼ±í»á¼ÓÉÏˮӡ
“Flex Data Visualization Trial”µÄ×ÖÑù¡£
¼ÈÈ»ÊÇ AS£¬ÄÇÊÂÇé¾Í¼òµ¥ÁË
Ö»ÒªÔÚ Flex Project 內×ÔÐмÓÉÏÒÔÏ Class£º
package
mx.charts.chartClasses {
public class ChartsLicenseHandler {
}
}
È»ºó ......
//1.¸´ÖÆÄÚÈݵ½ÏµÍ³¼ôÌù°å
System.setClipboard(strContent);
//2.¸´ÖÆÒ»¸öArrayCollection
//dummy solution( well, it works )
var bar:ArrayCollection = new ArrayCollection();
for each ( var i:Object in ac ){
bar.addItem( i ); }
// fantastic ! //
var bar:ListCollecti ......