Flex: Sample Network Info List


/ Published in: MXML
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
  3. xmlns:s="library://ns.adobe.com/flex/spark" title="SampleNetworkInfo">
  4.  
  5. <fx:Script>
  6. <![CDATA[
  7. import flash.events.ErrorEvent;
  8. import flash.events.MouseEvent;
  9. import flash.events.UncaughtErrorEvent;
  10. import flash.net.NetworkInfo;
  11. import flash.net.NetworkInterface;
  12.  
  13. import mx.collections.ArrayCollection;
  14.  
  15. [Bindable]
  16. protected var ac:ArrayCollection = new ArrayCollection();
  17.  
  18. protected function button1_clickHandler(event:MouseEvent):void
  19. {
  20. var ni:NetworkInfo = NetworkInfo.networkInfo;
  21. var interfaceVector:Vector.<NetworkInterface> = ni.findInterfaces();
  22. for each (var item:NetworkInterface in interfaceVector)
  23. {
  24. ac.addItem(item);
  25. }
  26. }
  27.  
  28. protected function msgFunc(item:NetworkInterface ):String
  29. {
  30. item = item as NetworkInterface;
  31. return item.hardwareAddress+" active: " + item.active + " mtu: " + item.mtu;
  32. }
  33. ]]>
  34. </fx:Script>
  35. <s:layout>
  36. <s:VerticalLayout paddingTop="20" paddingBottom="20" paddingLeft="20" paddingRight="20" gap="40" horizontalAlign="center"/>
  37. </s:layout>
  38. <s:TextArea width="95%" verticalAlign="justify"
  39. text="The list below displays the available network interfaces found on the device."/>
  40. <s:List id="list" dataProvider="{ac}" width="95%" height="80%">
  41. <s:itemRenderer>
  42. <fx:Component>
  43. <s:IconItemRenderer labelField="name" messageField="hardwareAddress" height="48"
  44. paddingTop="8" paddingBottom="8" verticalGap="8"/>
  45. </fx:Component>
  46. </s:itemRenderer>
  47. </s:List>
  48. <s:Button label="Find Network Interfaces" click="button1_clickHandler(event)" horizontalCenter="0"/>
  49. </s:View>
  50. qa

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.