May 16, 2010
@ 04:38 PM
Just my first Flex test, I wrote two simple methods in the asp.net webservice page.

Some key points I learn from this practice:
1. Call and bind webservice.
2. Fire event after webservice loaded. (  <s:CallResponder id="HelloWorldResult" result="WSLoadComplete(event)" />)
3. Redirect to other page ( navigateToURL(new URLRequest('../default.aspx'),'_self'))

here is the MyFirstFlex.mxml:
<?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/mx" minWidth="955" minHeight="600"
 xmlns:testwebservice="services.testwebservice.*"
creationComplete="application_creationCompleteHandler(event)">     <fx:Script>                  <![CDATA[             import mx.controls.Alert;             import mx.events.FlexEvent;             import mx.rpc.events.ResultEvent;             import mx.utils.ObjectUtil;             protected function btnLoad_clickHandler(event:MouseEvent):void             {                 TestArraryResult.token = testwebservice.TestArrary(txtName.text);                 //ddlDropdown1.dataProvider=             }                                       protected function btnHello_clickHandler(event:MouseEvent):void             {                 HelloWorldResult.token = testwebservice.HelloWorld();              //HelloWorldResult.addEventListener(             }             protected function WSLoadComplete(event:ResultEvent):void             {                 lblTest.text="Load Completed";             }                                               protected function application_creationCompleteHandler(event:FlexEvent):void             {             //    HelloWorldResult.token = testwebservice.HelloWorld();             }                          protected function btnHome_clickHandler(event:MouseEvent):void             {                 // TODO Auto-generated method stub                 navigateToURL(new URLRequest('../default.aspx'),'_self')             }         ]]>     </fx:Script>     <fx:Declarations>         <s:CallResponder id="TestArraryResult" />         <testwebservice:Testwebservice id="testwebservice"
fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>         <s:CallResponder id="HelloWorldResult" result="WSLoadComplete(event)" />                   <!-- Place non-visual elements (e.g., services, value objects) here -->     </fx:Declarations>     <s:TextInput x="81" y="68" id="txtName" text="ws"/>     <s:Button x="259" y="68" label="Load" id="btnLoad" enabled="{ txtName.text.length > 0 }"
 click="btnLoad_clickHandler(event)"/>     <s:DropDownList x="81" y="127" id="ddlDropdown1">         <s:AsyncListView list="{TestArraryResult.lastResult}"/>     </s:DropDownList>     <s:Label x="81" y="31" text="My First Test" width="147" height="29" id="lblTitle" fontSize="21"
fontFamily="Verdana" color="#C53A3A"/>     <s:Button x="123" y="256" label="Hello" id="btnHello" click="btnHello_clickHandler(event)"/>     <s:Label x="259" y="256" text="" id="lblTest" fontSize="19" color="#19B011" fontWeight="bold"
width="124" height="21" />     <s:TextArea x="126" y="291" text="{HelloWorldResult.lastResult}" width="190" height="91"/>     <s:Button x="418" y="39" label="Home" id="btnHome" click="btnHome_clickHandler(event)"/> </s:Application>


Flex plug-ins for visual studio:

Ensemble Tofino plug-in, available free from http://www.ensemble.com/

Related Articles:

http://www.flashmagazine.com/News/detail/tofino_-_flex_authoring_in_ms_visual_studio/

http://www.developerfusion.com/article/9536/using-adobe-flex-in-visual-studio/

Some flex resource:

(http://www.adobe.com/devnet/flex/flex_net.html)





 
Categories: FLEX