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
Ïà¹ØÎĵµ£º
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
private var loader:URLLoader = new URLLoader();
private var request:URLRequest = new URLRequest("a.txt");
private function initComplete():void
{
  ......
¼òµ¥½éÉÜÐÅFlexÓëWeb·þÎñµÄ½»»¥
Ö÷ÒªÄÚÈÝ:
1.ActionScriptÓë·þÎñ¶ËµÄ»ù±¾½»»¥·½Ê½(REST).
2.ActionScriptÌØÓеÄÊý¾Ý´«Êä¸ñʽ(AMF)Óë·þÎñÆ÷½»»¥.
3.FlexÓëWebService.
ҪʵÏÖActionScriptÓë· ......
http://www.slsay.com/archives/154
ʹÓà AreaChart ¿Ø¼þ½«Êý¾ÝչʾΪÆäÏßÐͱ߽ç±íʾÊý¾ÝÖµµÄÃæ»ýÇøÓò¡£Ãæ»ýÇøÓòÓÉÏßÌõ¼°ÆäϱßËùÌî³äµÄÑÕÉ«ºÍͼ°¸×é³É¡£¿ÉÒÔʹÓÃͼ±ê»ò·ûºÅÑØ×ű߽çÏßչʾÿ¸öÊý¾Ýµã£¬Ò²¿ÉÒÔչʾ²»´øͼ±êµÄ¼òµ¥ÇøÓòÏß¡£
´´½¨ AreaChart ¿Ø¼þµÄÀý×ÓÈçÏ£º
<?xml version="1.0"
?>
< ......
º¯ÊýÊǽøÐÐÄ£¿é»¯³ÌÐòÉè¼ÆµÄ»ù´¡£¬±àд¸´ÔÓµÄAjaxÓ¦ÓóÌÐò£¬±ØÐë¶Ôº¯ÊýÓиüÉîÈëµÄÁ˽⡣JavaScriptÖеĺ¯Êý²»Í¬ÓÚÆäËûµÄÓïÑÔ£¬Ã¿¸öº¯Êý¶¼ÊÇ
×÷Ϊһ¸ö¶ÔÏó±»Î¬»¤ºÍÔËÐеġ£Í¨¹ýº¯Êý¶ÔÏóµÄÐÔÖÊ£¬¿ÉÒԺܷ½±ãµÄ½«Ò»¸öº¯Êý¸³Öµ¸øÒ»¸ö±äÁ¿»òÕß½«º¯Êý×÷Ϊ²ÎÊý´«µÝ¡£ÔÚ¼ÌÐø½²Êö֮ǰ£¬ÏÈ¿´Ò»Ïº¯ÊýµÄʹÓÃÓï
·¨£º
function func1(& ......
ʲôÊÇ AJAX ¿â API£¿
AJAX ¿â API ÊÇÒ»ÖÖÄÚÈÝ·Ö²¼ÍøÂ磬¿ÉÔØÈë×îÊÜ»¶ÓµÄ¿ªÔ´ JavaScript ¿âµÄ¼Ü¹¹¡£Í¨¹ýʹÓà Google AJAX API ÔØÈë³ÌÐòµÄ google.load() ·½·¨£¬ÄúµÄÓ¦ÓóÌÐòÄܹ»Ñ¸ËÙ´ÓÈ«ÇòÈκÎλÖ÷ÃÎʲ»¶ÏÔö³¤µÄ¡¢×îÊÜ»¶ÓµÄ¿ªÔ´ JavaScript ¿âÁÐ±í£¬°üÀ¨£º
jQuery
jQuery UI
Prototype
script.aculo.us
Mo ......