Getting Started with iClient for Flash

Feedback


After you installed SuperMap iClient 8C for Flash according to the System Requirements, you can use this product to build map applications with characteristics of friendly interface, high interaction and excellent experience. The development workflow of SuperMap iClient 8C for Flash is shown as follows:

Development Workflow of SuperMap iClient 8C for Flash

Figure 1 The Development Workflow of SuperMap iClient 8C for Flash

Here is an introduction about how to use SuperMap iClient 8C for Flash to build a simple map application.

Step 1: Download and Extract Library Files

  1. Download SuperMap iClient 8C for Flash and unzip the package onto local computer.

  2. Below is the catalog structure of the software package:

    SuperMap iClient 8C for Flash Package Structure

    Figure 2 SuperMap iClient 8C for Flash Package Structure

Step 2: Create a New Flex Project

  1. In Flash Builder4, Select File > New >Flex Project, or right click in Package Explorer and click New > Flex Project to display the New Flex Project dialog box. Input the project name in the Project name text box.

    New Project
    Figure 3 New Project

  2. Click Next, and click Next again to go to the New Flex Project page.

  3. Click Library path to add library files. Click Add SWC to siplay the Add SWC dialog box, and click Browse to navigate to the folder where the library files are located. To use client basic map functionalities, add SuperMap.Web.*.swc; to use SuperMap iServer 8C functionalities, add SuperMap.Web.iServer7C.*.swc. For instance, if you want to display maps of SuperMap iServer services, you need to add SuperMap.Web.*.swc and SuperMap.Web.iServer7C.*.swc. Also, you can add the folder where the library files are located to add the library files. Change the name of the main application in Main application name text box.

    Add library files
    Figure 4 Add library files
  4. Click Finish to complete. A project named Flex is added to Package Explorer. Double click GettingStarted.mxml in the src folder to open it in the window on the right side. Now we can add code.

    Flex Project

    Figure 5 Flex project

Step 3: Add Code to Realize Map Accessing

        Add code below into GettingStarted.mxml to realize the accessing of tiled dynamic layer of SuperMap iServer 8C service. Code in read is the added code:

MXML   
   
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"                       
               xmlns:s="library://ns.adobe.com/flex/spark"                       
               xmlns:mx="library://ns.adobe.com/flex/mx"                          
               xmlns:ic="http://www.supermap.com/iclient/2010"                        
               xmlns:is="http://www.supermap.com/iserverjava/2010"                    
               width="100%" height="100%">  
    <!--Add map-->   
    <!--scales: the map scale; url: Web service address; url: map service address-->   
    <ic:Map id="map" x="0" y="0" height="100%" width="100%"            
            scales="{[1.25e-9, 2.5e-9, 5e-9, 1e-8, 2e-8, 4e-8, 8e-8, 1.6e-7, 3.205e-7, 6.4e-7]}">          
        <is:TiledDynamicRESTLayer url="http://192.168.11.11:8090/iserver/services/maps/rest/maps/World Map"/>   
    </ic:Map>
</s:Application>

Figure 6 Access SuperMap iServer 8C map

Note: The map service url in the code is only for demonstration. To guarantee the proper running of this sample, you need to make sure that SuperMap iServer 8C has been installed on the computer, the cross-domain file has been placed in <SuperMap_iServer_Install_Location>\webapps\ROOT, and the service has been started successfully.

Step 4: Run the Project and View the Map

Click Ctr+F11 to run the application, or right click GettingStarted.mxml and click Run Application to run it. You can see WorldMap published by SuperMap iServer 8C through service.

Access map

Figure 7 Access World Map of SuperMap iServer 8C service