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
Ïà¹ØÎĵµ£º
<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate the DateTimeAxis class. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
import mx.collections.ArrayCollection;
......
ÓÃFLEXÈçºÎÈ¡ä¯ÀÀÆ÷µØÖ·À¸ÖеÄÓòÃûÐÅÏ¢£¿ÎÒ²éÕÒµ½Á½ÖÖ·½·¨£º
µÚÒ»ÖÖ·½·¨ÊÇÓÃExternalInterface.call('window.location.href.toString')£¬ËüµÄÖµ¾ÍÊǵØÖ·À¸ÖеÄÓòÃû
ÓÐÒÔϼ¸µãÐèҪעÒ⣺
1.µ±FlashºÍ¼ÓÔØËüµÄÍøÒ³²»Í¬Óòʱ£¬ÐèÒªÔÚÍøÒ³ÔÚ PARAM »ò EMBED ±êÇ©ÖнøÐÐÉèÖÃAllowScriptAccess Ϊ“always”
¹ØÓÚ ......
¼òµ¥½éÉÜÐÅFlexÓëWeb·þÎñµÄ½»»¥
Ö÷ÒªÄÚÈÝ:
1.ActionScriptÓë·þÎñ¶ËµÄ»ù±¾½»»¥·½Ê½(REST).
2.ActionScriptÌØÓеÄÊý¾Ý´«Êä¸ñʽ(AMF)Óë·þÎñÆ÷½»»¥.
3.FlexÓëWebService.
ҪʵÏÖActionScriptÓë· ......
http://yecon.blog.hexun.com/36798900_d.html
ʹÓà Adobe Flex ²úÆ·ÏßµÄʱºò£¬²ÉÓÃͼ±íºÍͼÐÎÀ´Õ¹Ê¾Êý¾Ý»áʹÓû§ÓëÊý¾ÝµÄ½»»¥¸ü¼ÓÈÝÒס£Ïà¶Ô¼òµ¥µÄÊý×Ö±í¸ñÀ´Ëµ£¬¿ÉÒÔʹÓñíʾÊý¾ÝµÄ²»Í¬ÑÕÉ«¡¢±êÌâ¡¢ÏßÌõÀ´Õ¹Ê¾ÌõÐÎͼ¡¢±ýͼ¡¢ÏßͼµÈµÈ¡£
ͼ±í¿Ø¼þÊÇ Adobe Flash Builder רҵ°æµÄÌØÐÔ¡£Ò²¿ÉÒÔÔÚ Falsh Builder ±ê×¼°æÖ ......