FABridge½Ì³Ì(Flex+Ajax)
½ñÌìÕÒһЩFlex×ÊÁÏ£¬Å¼È»·¢ÏֺܶàÈËÔÚÎÊÓйØFABridgeµÄÎÊÌ⣬¿´ÁËһϣ¬´óÖ¶¼ÊÇÔÚÎÊÔÚFlashBuilderÖÐÈçºÎͨ¹ýFABridgeÀ´ÊµÏÖF-AµÄ½»»¥¡£¼òµ¥ËµËµ°É¡£
Ò».ͨ¹ýjs·ÃÎÊFlex×é¼þ
1.×¼±¸¹¤×÷¡£ÏȽ¨Á¢Flex¹¤³Ì :fademo£¬²¢·ÅÖÃÒ»¸öÎı¾¿ò:txtName¡£×öÍêºó´úÂëÓ¦¸ÃÀàËÆÓÚÕâ¸öÑù×Ó£º
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="0" minHeight="0" width="400" height="300">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:TextInput x="160" y="96" id="txtName"/>
</s:Application>
·Ç³£¼òµ¥£¬ºÇºÇ¡£ÎÒÓõÄflex4£¬flex3µÄ»°Ò²ÀàËÆ¡£
×¢ÒâÒ»µã£¬flash³õʼ´óС±ðÉèÖõÄÌ«´óÁË£¬·ñÔò»á¿´²»µ½Îı¾¿ò¡£
2.ÔÚ¹¤³ÌÉϵãÓÒ¼ü£¬Ñ¡Ôñ¡¾´´½¨Ajax Bridge¡¿£¬Ìí¼ÓFABridgeÖ§³Ö¡£ÕâÀï»áÈÃÄãÑ¡Ôñ¶Ôµ±Ç°¹¤³ÌÖÐÄÄЩÀࣨÊôÐÔ£¬·½·¨£©½øÐÐFAÇŽӡ£³õѧµÄ»°£¬Ö»Ñ¡ÔñÎÒÃÇ´´½¨µÄÎı¾¿ò¼´¿É£¬ÃâµÃµÈ»ájs´úÂëÌ«¶à¡£ÕâÀïÎÒÃÇֻѡÖÐtxtNameÇ°ÃæµÄ¹´¹´¡£µã»÷È·¶¨°´Å¥¡£
3.¿´¿´¶¼ÓÐʲô±ä»¯£¿Ê×ÏÈÔÚsrcÄÚ¶àÁËÒ»¸öbridge°ü£¬ÆäÄÚ¶àÁ˸öFABridge.as£»Æä´Î£¬ÔÚ¹¤³ÌĿ¼Ï£¬Ò²´´½¨ÁËÒ»¸öÃûΪAjaxBridge\fademoµÄĿ¼£¬ÆäÖÐlibÏÂÓÐÒ»¸ö¶ÔÓ¦µÄFABridge.js¡£ÕâÁ½¸öÎļþµÄ×÷ÓÃÎҾͲ»·Ï»°ÁË£¬ÊǺËÐÄ£¬²»¹ýÎÒÃDz»ÐèÒª¶¯Ëü¡£
ÁíÍ⣬»¹ÓÐÎÒÃÇÏÂÃæҪ˵µÄÁ½¸öÎļþ£¬fademo.jsºÍfademo.html£¬ÕâÁ½¸öÎļþÊÇÎÒÃÇÐèÒª¹Ø×¢µÄ£¬¼ò½àÆð¼û£¬ÎÒ°ÑÓ¢ÎÄ×¢ÊÍ»»µôÁË¡£
ÏÈ¿´¿´fademo.js£º
//¶¨ÒåÒ»¸öÈ«¾Ö±äÁ¿fademo
fademo = {};
//»Øµ÷
FABridge.addInitializationCallback("b_fademo", fademoReady);
function fademoReady() {
//¾Ö²¿±äÁ¿£¬»ñµÃFlexÓ¦Óã¨b_fademo£©µÄ¸ù£¬¿ÉÒÔͨ¹ýb_fademo_root²Ù×÷flex
b_fademo_root = FABridge["b_fademo"].root();
//ΪfademoÌí¼ÓÒ»¸ö·½·¨getTxtName£¬Ï൱ÓÚfademo½èÖúb_fademo_root²Ù×÷flex
fademo.getTxtName = function () {
return
Ïà¹ØÎĵµ£º
±¾ÀýÖн«ÊµÏÖµ±Ó¦ÓÃÔËÐÐʱ²»½øÐÐÈκβÙ×÷¾ÍÏȵ¯³ö´°¿Ú£¬µã»÷¹Ø±Õ/µã»÷´°¿ÚÈÎһλÖà ʱ½«¹Ø±Õ´°¿Ú
1£©´´½¨Component—DefaultWin.mxml £¨Ä¿Â¼½á¹¹src/components/DefaultWin.mxml£©
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
  ......
FLEX±àÒëµÄSWFÎļþ£¬Ö»ÄÜÑ¡Ôñ·ÃÎʱ¾µØÎļþ»ò·ÃÎÊÍøÂçÎļþ£¬¶þÕßÖ»ÄÜÈ¡Ò»£¨àÅ£¬ÎªÊ²Ã´£¿ÎÒÒ²²»ÖªµÀ£¬¹Ù·½ËµÊÇΪÁË°²È«¿¼ÂÇ£©£¬¶øFLEX±àÒëµÄĬÈÏÑ¡ÏîÊÇÖ»ÄÜ·ÃÎÊÍøÂçÎļþ£¬ËùÒÔÄ㽫binÀïµÄ¶«Î÷COPYµ½ÆäËûµØ·½¾Í²»ÄܶÁÈ¡ÁË¡£¶øÄãÔÚĬÈϵÄbinĿ¼Ï¿ÉÒÔ¶ÁÈ¡µÃµ½£¬ÊÇÒòΪFLEXÈÏΪÄãÊÇÔÚIDE»·¾³ÖÖ£¬ÕâʱÊÇûÓÐÕâ¸öËùνµÄ°²È«ÏÞÖÆµÄ ......
×é¼þÖصþÏÔʾ£¬Ê¹ÓÃÊôÐÔincludeInLayoutµÄtrue»òfalse
ÔÚFlexÖУ¬½«includeInLayoutÉèÖÃΪfalse£¬²¢²»´ú±í´Ó“²¼¾Ö”ÖГÒþ²Ø”µôÕâ¸öUIComponent£¬¶ø½ö½öÊǽ«Õâ¸öUIComponent´Ó²¼¾ÖÖкöÂÔ£¬Ö±½Ó²¼¾ÖÏÂÒ»¸ö¶ÔÏó¡£Èç¹ûÏëÍêÈ«´ÓÈÝÆ÷ÖÐÒþ²ØµôÒ»¸ö¶ÔÏó£¬ÇëͬʱʹÓÃvisible=”false” includeInL ......
¼òµ¥½éÉÜÐÅFlexÓëWeb·þÎñµÄ½»»¥
Ö÷ÒªÄÚÈÝ:
1.ActionScriptÓë·þÎñ¶ËµÄ»ù±¾½»»¥·½Ê½(REST).
2.ActionScriptÌØÓеÄÊý¾Ý´«Êä¸ñʽ(AMF)Óë·þÎñÆ÷½»»¥.
3.FlexÓëWebService.
ҪʵÏÖActionScriptÓë· ......