Use Flash to develop LAN P2P projects between computers and Android

Source: Internet
Author: User

Requirements

You must first install the following products:

Flash Professional CS5
  • Trial
  • Purchase
AIR for Android development plug-in on Flash Professional CS5
  • Download
Example file:
  • P2P_example.zip (ZIP, 311 K)
Prerequisites
  • Uses Flash Pro to create and release projects.
  • ActionScript 3.0 intermediate programming level
Use flash professional CS5 to develop AIR2.5 applications running on the ANDROID platform

Android 2.2 supports the Adobe AIR runtime environment, Version 2.5. You can use the development tool Flash Builder Burrito to develop an AIR2.5 Application Based on Flex SDK 4.5 (Hero). For Flash Pro users, flash Pro CS5 with the AIR for Android plug-in can also be used to conveniently and quickly develop a mobile app.

If you have not installed Flash compression sion CS5, please download the trial version here, and then download AIR2.5 development plug-in (Beta 2) from the Adobe lab. After the installation is successful, open Flash, create an AIR for Android document on the Start Screen. This post uses the English version of MAC Flash Pro as an example.

Figure 1. Create an AIR for Android project in Flash compression sion CS5

Since the AIR2.5 Development Kit is installed, Flash Professional CS5 can be used as a tool for publishing AIR2.5. Open Publish Settings and you can see that the Flash release environment is AIR Android. Click the setting button on the right, you can go to the publishing settings panel of AIR2.5:

Figure 2. AIR2.5 release settings panel

General is some basic information about the application. The application installation package on the Android platform is an APK file. In this panel, you can directly name the APK file and define the application name. Note that the Application ID can be defined in the App ID field. The id value cannot contain special characters such as underscores. Otherwise, an error is reported during compilation.

In Aspect ratio, you can set the display mode of the application on the mobile phone to landscape or portrait ). You can also specify whether to automatically adjust the horizontal and vertical display (Auto orientation) in the full screen or in the skewed direction of the device ).

Next, set the rendering method of the image. Here there are three options: Auto, CPU, and GPU. If you select GPU, the video card of the device is used first to render the image, different device graphics cards have different limits, so if you choose this option, you need to test it in multiple devices to ensure it is correct. The GPU of Android has the following restrictions:

  • Filter effect not supported
  • PixelBender's image overlay and filling effect are not supported
  • The following image overlays are not supported: layer, alpha, erase, overlay, hardlight, lighten, and darken.
  • GPU is not recommended for video rendering.

If you use GPU rendering, the input box is not automatically adjusted to the visible range when the soft keyboard is opened. Therefore, you need to place the text box in the upper half of the screen.

If a display object cannot be rendered by a GPU, such as a video clip with a filter added, it will not be displayed at all.

Figure 3. Set Deployment and release parameters in the Deployment panel

Deployment is a set of Deployment and release. Just like publishing a desktop version of The AIR application, releasing Android AIR also requires verification.
In Android Deployment Type), you can select Device release, Emulator release, and Debug. If Debug is selected, you can establish a test environment between the device and Flash through the network, enable Debug in Flash-> Begin Remote Debug Session-> ActionScript 3.0, in the displayed dialog box, enter the host IP address and host name.
After publishing, you can select to install the application to the device and run the application at the same time. We recommend that you select two options.

Icons is used to set the application's display Icons (36 × 36, 48 × 48, 72 × 72). Images support PNG files.

Figure 4. Set INTERNET Permissions in Permissions

Permissions is used to set application access Permissions. In this example, You need to select INTERNET to develop a P2P network application.

Next, set HTC Desire in this example on a mobile device. Choose Settings> Application> development and select USB debugging to connect the device to the computer using USB, and publish an AIR2.5 application.

Build a NETGROUP connection in the LAN Using FLASH P2P Technology

Flash P2P (Pear to Pear) technology allows various online clients to use the Real-Time Media Flow Protocol (RTMFP) Protocol for point-to-point communication. You need to connect to a server that supports the RTMFP protocol in the WAN. You do not need a server in the LAN. You can use the Multicast address for communication. P2P needs to transmit data through User Datagram Protocol (UDP), so make sure that your gateway does not block the UDP protocol.
If you are not sure whether your device supports UDP communication, use your mobile browser to access this URL http://cc.rtmfp.net to automatically detect your network status.

Here is an example of establishing P2P in a LAN. The basic idea is to establish a NetConnection, then build a NetGroup, that is, the Communication Team, and finally broadcast and communicate with other neighbors in the team.

Use NetConnection to establish a connection. If the parameter is "rtmfp:", a LAN connection is established.

 
 
  1. nc = new NetConnection(); 
  2. nc.addEventListener(NetStatusEvent.NET_STATUS,netStatus); 
  3. nc.connect("rtmfp:"); 

Use NetGroup to build a communication team. In GroupSpecifier, you can specify the team id and use it to create a PIN code for user filtering. The following code creates a NetGroup team. If you want to build a P2P Lan, you must use the Multicast Address and specify the IP Address and port. For more information, see here.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.