Select to view content in your preferred language

Flex API 2.0 with Air Android API 2.5

832
6
09-20-2010 08:25 PM
AlpineTech
Regular Contributor
I am testing the Flex API 2.0 to see if I can get it to run with latest pre-release of the Air Android 2.5 SDK (AIR25_win_sdk_20100909.zip).  Using Flex Builder 4 I created an Air Desktop app and added a reference to the ArcGIS Flex API 2.0 library.  First, I tried one of the simple sample applications that just shows a tiled map from ArcGIS online, nothing fancy.  It built, but did not run.  It threw an error, but I expected that because the Air Android SDK does not support .mxml files yet.  Second, I tried the same thing with a simple action script no .mxml file.  I thought that might work, but it threw an error when I ran it.  The error says:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.esri.ags::Map()
at FlexMobileGIS1()

Please see the action script below and let me know if there is something I am missing here?

package
{
import com.esri.ags.Map;
import com.esri.ags.layers.ArcGISTiledMapServiceLayer;
import com.esri.ags.geometry.Extent;
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.system.*;

public class FlexMobileGIS1 extends Sprite
{
 
  public function FlexMobileGIS1()
  { 
   stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;
   stage.align = StageAlign.TOP_LEFT;
   var map:Map = new Map();     
   var extent:Extent = new Extent(-13635000,4541000,-13625000,4547000);
   extent.spatialReference.wkid = 102100;
   map.extent = extent;
   var tiledLyr:ArcGISTiledMapServiceLayer = new ArcGISTiledMapServiceLayer();
   tiledLyr.url = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer";
   map.addLayer(tiledLyr);
   stage.addChild(map);
  } 
}
}
Tags (2)
0 Kudos
6 Replies
BjornSvensson
Esri Regular Contributor
This is/was a bug that will be fixed in version 2.1 of the Flex API.
0 Kudos
AlpineTech
Regular Contributor
Can I get a patch in the mean time?
0 Kudos
DasaPaddock
Esri Regular Contributor
0 Kudos
AlpineTech
Regular Contributor
I tried the new ArcGIS Flex 2.1 API, and yes my first error did not occur, but still no go.  I suspect it might be because the API still depends on mx.styles.StyleManager (and other mx stuff).  I found this information that indicates that a bunch of the mx stuff was depreciated for Air:

http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/deprecated.html

What now?

This is the ERROR:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at mx.styles::StyleManager$/getStyleManager()
at mx.styles::StyleProtoChain$/getStyleManager()
at mx.styles::StyleProtoChain$/initProtoChain()
at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::initProtoChain()
at mx.core::UIComponent/regenerateStyleCache()
at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::addingChild()
at mx.core::UIComponent/addChildAt()
at com.esri.ags::Map/addLayer2()
at com.esri.ags::Map/collectionAddHandler()
at com.esri.ags::Map/collectionChangeHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.collections::ListCollectionView/dispatchEvent()
at mx.collections::ListCollectionView/addItemsToView()
at mx.collections::ListCollectionView/listChangeHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.collections::ArrayList/internalDispatchEvent()
at mx.collections::ArrayList/addItemAt()
at mx.collections::ListCollectionView/addItemAt()
at com.esri.ags::Map/addLayer()
at FlexMobileGIS1()
0 Kudos
AlpineTech
Regular Contributor
It works!  I tried another approach with an mxml.  I'll write up something later and post it.
0 Kudos
Neesheykhan
Emerging Contributor
i m using Eclips 3.5.2,i followed the mapview tutorial displaying esri online maps v fine but when i add my Gis server maps they apear in a v thin line,what should i do to resolve this ??if any one has gone through this problem and have any guide line for resolve plz help me too.
0 Kudos