2011-11-14
1. HTTPService
  1. var service:HTTPService = new HTTPService(); 
  2. _service.url = "http://121.194.117.200:8080/monitorSystem/dataAction_getFlexValue.action"
  3. _service.method = "POST";    
  4. _service.addEventListener("result", httpResult);    
  5. _service.addEventListener("fault", httpFault); 
  6. _Service.send(param); 
  7. function httpResult(event:ResultEvent):void  
  8. {  
  9.     Alert.show(_service.lastResult); 
  10.      
  11. function httpFault(event:FaultEvent):void  
  12. {    
  13.     var faultstring:String = event.fault.faultString;    
  14.     Alert.show("Fault: " + faultstring);    
  15. }      
2. as3获取js地址参数
as3代码:
  1. var _str:String = ExternalInterface.call("getType"); 
  2. trace(_str); 
js代码:
  1. <script type="text/javascript"
  2.     function Request() 
  3.     { 
  4.         var strHref = window.document.location.href; 
  5.         var intPos = strHref.indexOf("?"); 
  6.         if(intPos == -1) 
  7.         { 
  8.             return ""
  9.         } 
  10.         var strRight = strHref.substr(intPos + 1); 
  11.         return strRight; 
  12.     } 
  13.  
  14.     function getType() 
  15.     { 
  16.         return Request(); 
  17.     } 
  18. </script> 
3. js调用as3中的方法
as3 代码:
  1. if(ExternalInterface.available) 
  2.     ExternalInterface.addCallback("getDataStart",getDataStart); 
  3.  
  4. function getDataStart(id:String = ""):void 
  5.     Alert.show("id = " + id, "start"); 
Js代码:
  1. <script type="text/javascript"
  2.     function sendStart() 
  3.     { 
  4.         // customDemo指嵌入的swf的id 
  5.         customDemo.getDataStart("xxxx"); 
  6.     } 
  7. </script> 
4. Json
  1. import com.adobe.serialization.json.*; 
  2.  
  3. var _obj:Object = JSON.decode(value); 
  4. var _str:String = JSON.encode(value); 
5. LineChart横坐标倾斜45°
css中:
  1. @font-face  
  2. {  
  3.     font-family: EmbeddedArial;  
  4.     srcurl("simkai.ttf"); 
  5.     embedAsCFF: false; 
  6. }  
  7.  
  8. .LineChart 
  9. {  
  10.     fontFamily:EmbeddedArial;  
Flex中:
  1. <mx:LineChart id="linechart" seriesFilters="[]" styleName="LineChart" 
  2.           showDataTips="true" dataProvider="{_DataArr}"
  3.  
  4.     <mx:horizontalAxis> 
  5.         <mx:CategoryAxis id="dateAxis" categoryField="x"/> 
  6.     </mx:horizontalAxis> 
  7.  
  8.     <mx:horizontalAxisRenderers>  
  9.         <mx:AxisRenderer labelRotation="45" axis="{dateAxis}"/>  
  10.     </mx:horizontalAxisRenderers>  
  11.  
  12. </mx:LineChart> 
6. Flex4 中 旋转特效
  1. <fx:Declarations> 
  2.     <s:Rotate id="rotateEffect" /> 
  3. </fx:Declarations> 
  4.  
  5. function changeAngle():void 
  6.     rotateEffect.angleFrom = 0; 
  7.     rotateEffect.angleTo = 100; 
  8.     rotateEffect.autoCenterTransform = false
  9.     rotateEffect.transformX = 5; 
  10.     rotateEffect.transformY = 7; 
  11.     rotateEffect.play([poiner]); 
 
2011-12-6
 
1. BlazeDS
配置BlazeDS

工作中的Flex总结_JavaScript

 
Flex代码
  1. public function submsg():void 
  2.     var consumer:Consumer = new Consumer(); 
  3.     consumer.destination = "tick-data-feed"
  4.     consumer.subtopic = xml.main; 
  5.     consumer.channelSet = new ChannelSet(["my-streaming-amf"]); 
  6.     consumer.addEventListener(MessageEvent.MESSAGE, messageHandler); 
  7.     consumer.subscribe(); 
  8.  
  9. private function messageHandler(event:MessageEvent):void  
2. 点击Legend隐藏显示线条
  1. <mx:Legend x="865" 
  2.     y="11" 
  3.     dataProvider="{linechart1}" 
  4.     color="0x323232"  
  5.     itemClick="itemClickHandler(event)" 
  6.     buttonMode="true"/> 
  7.  
  8. private function itemClickHandler(event:LegendMouseEvent):void 
  9.     event.item.element.visible = !event.item.element.visible; 
3. 限定charts的上下限
  1. <mx:verticalAxis> 
  2.     <mx:LinearAxis minimum="0"  maximum="100"/>  
  3. </mx:verticalAxis> 
4. 在LineChart中画网格
  1. <mx:backgroundElements>    
  2.     <mx:GridLines gridDirection="both">    
  3.         <mx:verticalStroke>    
  4.             <s:SolidColorStroke color="black" weight="0.5" alpha="0.2" />    
  5.         </mx:verticalStroke>    
  6.     </mx:GridLines>    
  7. </mx:backgroundElements> 
5. 自定义鼠标
  1. [Embed(source="assets/mouse.swf")] 
  2. private var mouseIcon:Class; 
  3.  
  4. CursorManager.setCursor(mouseIcon,2,-33,-65); 
  5.  
  6. //移除自定义鼠标形状 
  7. CursorManager.removeAllCursors(); 
6. Vslider
  1. <s:VSlider id="vslider"  
  2.     change="changePosition()" 
  3.     dataTipFormatFunction="vsliderDataTipFunction"  
  4.     maximum="3"  
  5.     minimum="0" 
  6.     value="0"/> 
  7.  
  8. private function vsliderDataTipFunction(value:Number):Object 
  9.     var _str:String; 
  10.      
  11.     return _str; 
  12.  
  13. private function changePosition():void 
7. Charts特效
  1. <mx:SeriesInterpolate id="rearange"/>    
  2. <mx:SeriesSlide id="slide"/>    
  3.  
  4. var _columnService:ColumnSeries = new ColumnSeries(); 
  5. _columnService.setStyle("showDataEffect",rearange); 
  6. _columnService.setStyle("hideDataEffect",null);