简体   繁体   中英

Openscales 2.2 Null Object Reference

I build a mobile app with Flash Builder 4.6 and openscales 2.2

I used openscales 1.2.1 and it works fine, but it is very slow and the zoom effect isn't nice.

So I want to upgrade to openscales 2.2. I added the .swc to my libs folder and I change FeatureLayer to VectorLayer, because this was renamed in the new version.

If I test the app the debugger gives me the following error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at org.openscales.core::Map()[D:\workspace\openscales\target\checkout\openscales-core\src\main\flex\org\openscales\core\Map.as:296]
    at org.openscales.fx::FxMap()[D:\workspace\openscales\target\checkout\openscales-fx\src\main\flex\org\openscales\fx\FxMap.as:70]
    at views::mapView/_mapView_FxMap1_i()
    at views::mapView/_mapView_Array1_c()
    at mx.core::DeferredInstanceFromFunction/getInstance()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\DeferredInstanceFromFunction.as:108]
    at spark.components::SkinnableContainer/createDeferredContent()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\SkinnableContainer.as:1049]
    at spark.components::SkinnableContainer/createContentIfNeeded()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\SkinnableContainer.as:1078]
    at spark.components::SkinnableContainer/createChildren()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\SkinnableContainer.as:885]
    at mx.core::UIComponent/initialize()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:7634]
    at spark.components::View/initialize()[E:\dev\4.y\frameworks\projects\mobilecomponents\src\spark\components\View.as:999]
    at views::mapView/initialize()
    at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:7495]
    at mx.core::UIComponent/addChildAt()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:7199]
    at spark.components::Group/addDisplayObjectToDisplayList()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Group.as:2037]
    at spark.components::Group/http://www.adobe.com/2006/flex/mx/internal::elementAdded()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Group.as:1628]
    at spark.components::Group/addElementAt()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Group.as:1387]
    at spark.components::Group/addElement()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Group.as:1345]
    at spark.components::SkinnableContainer/addElement()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\SkinnableContainer.as:761]
    at spark.components::ViewNavigator/createViewInstance()[E:\dev\4.y\frameworks\projects\mobilecomponents\src\spark\components\ViewNavigator.as:2018]
    at spark.components::ViewNavigator/commitNavigatorAction()[E:\dev\4.y\frameworks\projects\mobilecomponents\src\spark\components\ViewNavigator.as:1932]
    at spark.components::ViewNavigator/commitProperties()[E:\dev\4.y\frameworks\projects\mobilecomponents\src\spark\components\ViewNavigator.as:1301]
    at mx.core::UIComponent/validateProperties()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:8219]
    at mx.managers::LayoutManager/validateProperties()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\LayoutManager.as:597]
    at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\LayoutManager.as:813]
    at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1180]

D:\\workspace\\openscales\\target\\checkout\\openscales-core\\src\\main\\flex\\org\\openscales\\core\\Map.as:296] This line is really strange, because I don't have this folder on my pc and because of that I think there is a wrong path in the .swc of openscales?

Best regards Janine

I had the same problem, I created the project on my mac with the wrong windows path ORZ.... But the problem has been solved after reading the source code. In the class file named "org.openscales.core.Map.as", about line 300th.

var menu:ContextMenu = new ContextMenu();
menu.hideBuiltInItems();

var notice:ContextMenuItem = new ContextMenuItem("Powered by OpenScales");
notice.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, openLink);
menu.customItems.push(notice);
contextMenu = menu;

The contextMenu is not supported in an air mobile application. So, just comment them and rebuild the openscales lib.Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM