Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Student and Teacher Editions
More products
Solutions
Creative tools for business
Digital marketing
Digital media
Education
Financial services
Government
Web Experience Management
More solutions
Learning Help Downloads Company
Buy
Home use for personal and home office
Education for students, educators, and staff
Business for small and medium businesses
Licensing programs for businesses, schools, and government
Special offers
Search
 
Info Sign in
Welcome,
My cart
My orders My Adobe
My Adobe
My orders
My information
My preferences
My products and services
Sign out
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out My orders My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Review and Checkout
Adobe Developer Connection / Adobe AIR Developer Center / Native extensions for Adobe AIR /

NetworkInfo native extension sample

by Adobe

Adobe logo

Content

  • The ActionScript library
  • Application usage
  • The iOS native library
  • Where to go from here

Created

21 September 2011

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
ActionScript Adobe AIR 3 iOS mobile

Requirements

Prerequisite knowledge

Familiarity with building mobile AIR applications for iOS, including familiarity with Objective C and Xcode.

 

Required third-party products

  • iOS SDK 4
  • Xcode

User level

Intermediate

Required products

  • Adobe AIR 3

Sample files

  • Binaries.zip
  • NetworkInfoActionScriptLibrary.zip
  • NetworkInfoiOSLibrary.zip
  • NetworkInfoUsageApp.zip

Note: By clicking the download link for any source examples on this page, you acknowledge that you have read and agree to the Adobe AIR SDK License Agreement. These files are considered Sample Code.

Note: Adobe recommends using the next version of Flash Builder for developing native extensions for Adobe AIR. Sign up now to get access to the prerelease of Flash Builder 4.6.

The NetworkInfo class is a native extension for Adobe AIR. It allows AIR application developers, from ActionScript, to get information for each network interface.

ActionScript already provides a NetworkInfo class that works on desktop and AIR for TV devices. This native extension provides a similar class so that AIR applications for iOS can also get information for each network interface.

The attached ZIP files contain:

  • The ActionScript library in the directory NetworkInfoActionScriptLibrary: This directory contains the Flash Builder project for creating the ActionScript side of the NetworkInfo extension.
  • The iOS native library in the directory NetworkInfoiOSLibrary: This directory contains an Xcode project for creating the iOS native side of the NetworkInfo extension. To build the Xcode project, first copy FlashRuntimeExtension.h from <AIR_SDK>/include/FlashRuntimeExtensions.h to the directory
     NetworkInfoiOSLibrary.
  • A directory called Binaries: This directoyt contains everything the AIR application developer needs to use the native extension: the ANE file, the SWC file, and a text file that contains the extension ID.
  • A directory called NetworkInfoUsageApp: This directory contains a sample AIR application that uses the NetworkInfo native extension.

The ActionScript library

The ActionScript library contains the NetworkInfo class. The NetworkInfo class provides the AIR application this public method and property:

  • public static function get networkInfo(): NetworkInfo
  • public function findInterfaces(): Vector.<NetworkInterface>

The NetworkInfo object is a singleton. The AIR application gets the single NetworkInfo object using the static networkInfo property.

The findInterfaces() method returns a Vector of NetworkInterface objects. The NetworkInterface class is also defined in the ActionScript library. The NetworkInterface class provides these public properties:

  • public function get name():String
  • public function get displayName():String
  • public function get mtu():int
  • public function get hardwareAddress():String
  • public function get active():Boolean
  • public function get addresses():Vector.<InterfaceAddress>

The addresses() property returns a Vector of InterfaceAddress objects. The InterfaceAddress class is also defined in the ActionScript library. It contains these public properties:

  • public function get address():String
  • public function get broadcast():String
  • public function get prefixLength():int
  • public function get ipVersion():String

Note: The public functions and properties of the classes in the NetworkInfo extension—NetworkInfo, NetworkInterface, and InterfaceAddress—correspond with the public functions and properties in the existing ActionScript classes by the same name. See NetworkInfo, NetworkInterface, and InterfaceAddress in the ActionScript 3 Reference for the Adobe Flash Platform.

Application usage

To use the NetworkInfo extension, an AIR application does the following:

  • Get the NetworkInfo singleton object by accessing the static property NetworkInfo.networkInfo .
  • Call the NetworkInfo singleton object's findInterfaces() method to get a list of network interfaces.

For example:

var ntf:Vector.<NetworkInterface> = NetworkInfo.networkInfo.findInterfaces();

Note: Do not call new NetworkInfo() . Trying to create an instance of the NetworkInfo class in this manner throws an exception.

Then you can process each NetworkInterface object in the returned Vector. For example:

for each (var interfaceObj:NetworkInterface in ntf) { // Access interfaceObj.name, interfaceObj.displayName, interfaceObj.active, // interfaceObj.hardwareAddress, and interfaceObj.mtu for each(var address:InterfaceAddress in interfaceObj.addresses) { // Access address.address, address.broadcast, address.ipVersion, and address.prefixLength } }

Note that the prefixLength field of the InterfaceAddress class is not supported. Its value is always -1 .

The iOS native library

The iOS native library is implemented in Objective C, using the native extension C API. The native library contains examples of these native extension C APIs:

  • The extension initializer and finalizer, using the signatures of FREInitializer()and FREFinalizer().
  • The context initializer and finalizer, using the signatures of FREContextInitializer() and FREContextFinalizer() .
  • A native function, findInterfaces(), that uses the signature of FREFunction().
  • FRENewObject()
  • FRENewObjectFromBool()
  • FRENewObjectFromInt32()
  • FRENewObjectFromUTF8()
  • FRESetArrayElementAt()

The native function findInterfaces() calls the iOS API getifaddrs() function to get a linked list of the device's network interfaces. The function processes the elements in the list, returning an array of NetworkInterface objects to the ActionScript side of the extension.

Where to go from here

For more information about developing native extensions for Adobe AIR, see:

  • Extending Adobe AIR
  • Developing Native Extensions for Adobe AIR
  • Adobe native extension samples

For more information about using a native extension in an AIR application, see:

  • Using native extensions for Adobe AIR

More Like This

  • Gyroscope native extension sample
  • Vibration native extension sample
  • Notification native extension sample

Products

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Mobile Apps
  • Photoshop
  • Touch Apps
  • Student and Teacher Editions

Solutions

  • Digital marketing
  • Digital media
  • Web Experience Management

Industries

  • Education
  • Financial services
  • Government

Help

  • Product help centers
  • Orders and returns
  • Downloading and installing
  • My Adobe

Learning

  • Adobe Developer Connection
  • Adobe TV
  • Training and certification
  • Forums
  • Design Center

Ways to buy

  • For personal and home office
  • For students, educators, and staff
  • For small and medium businesses
  • For businesses, schools, and government
  • Special offers

Downloads

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2012 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy Policy and Cookies (Updated)

Ad Choices

Reviewed by TRUSTe: site privacy statement