《一》

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"  creationComplete="createListener();">
<mx:Panel  title="Currency Converter" width="450" height="150" x="20" y="20" layout="absolute">
<mx:Label text="Price in Dollars" x="25" y="37"/>
<mx:Label x="120" y="65" id="lblResults"/>
<mx:TextInput x="120" y="35" id="txtPrice"/>
<mx:Button id="btnConvert" x="290" y="35"  label="Convert to yen" />
 
</mx:Panel> 
<mx:Script>
 <![CDATA[
 public function createListener():void{
 btnConvert.addEventListener(MouseEvent.CLICK,convertCurrency);
 }
  public function convertCurrency(e:Event):void{
  var rate:Number=120;
  var price:Number=Number(txtPrice.text);
  if(isNaN(price))
  {
   lblResults.text="Please enter a valid price;";
  }
  else
  {price=price*rate;
  lblResults.text="Price in Yen:"+String(price);
  }
  }
 ]]>
</mx:Script>
</mx:Application>
《二》

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
 <mx:Panel width="350" height="200" x="10" y="10" title="Rate Customer Service" layout="absolute">
  <mx:ComboBox x="20" y="20" id="cbxRating">
  <mx:dataProvider>
   <mx:Array>
    <mx:String>ab</mx:String>
    <mx:String>cd</mx:String>
    <mx:String>efg</mx:String>
    <mx:Object label="asdf" data="5"/>
    <mx:Object label="qwer" data="6"/>
   </mx:Array>
  </mx:dataProvider>
  </mx:ComboBox>
  <mx:Button label="Send" x="140" y="20"/>
  <mx:Label x="20" y="120" text="{cbxRating.value}"/>
 
 </mx:Panel>
</mx:Application>

《三》

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
 <mx:Label x="20" y="60" text="Email"/>
 <mx:TextInput y="60" left="90" right="60"/>
 <mx:Label x="20" y="90" text="Comments"/>
 <mx:TextArea left="90" right="60" top="90" bottom="190"/>
 <mx:Button label="Send" bottom="60" right="150"/>
 
</mx:Application>
《四》

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="feedRequest.send()">
 <mx:Panel x="10" y="10" width="475" height="400" layout="absolute" title="{feedRequest.lastResult.rss.channel.title}">
  <mx:DataGrid x="20" y="20" width="400" id="dgPosts" dataProvider="{feedRequest.lastResult.rss.channel.item}">
   <mx:columns>
    <mx:DataGridColumn headerText="Posts" dataField="title"/>
    <mx:DataGridColumn headerText="Date" dataField="pubDate" width="150"/>
    
   </mx:columns>
  </mx:DataGrid>
  <mx:TextArea x="20" y="175" width="400"  htmlText="{dgPosts.selectedItem.description}"/>
  <mx:LinkButton x="20" y="225" label="Read Full Post" click="navigateToURL(new URLRequest(dgPosts.selectedItem.link));"/>
 </mx:Panel>
 <mx:HTTPService id="feedRequest" url="http://blogs.adobe.com/mchotin/index.xml" useProxy="false"/>
 
</mx:Application>

posted on 2009-10-29 23:09  sweting  阅读(202)  评论(0编辑  收藏  举报