flex-users / flexlib

Open Source Flex components library.
github.com/flex-users/flexlib
MIT License
204 stars 91 forks source link

NullPointerException in SuperTabNavigator when using NavigatorContent #295

Open nicoulaj opened 13 years ago

nicoulaj commented 13 years ago

Originally filed by dasha.fi...@gmail.com on 2010-04-19T20:28:39

What steps will reproduce the problem?

  1. Create SuperTabNavigator w/ tabs as NavigatorContent (Flex4)
  2. Run the application
  3. Get an exception:

TypeError: Error #1009: Cannot access a property or method of a null object reference. at flexlib.containers::SuperTabNavigator/reorderTabList()[C:\Users\dfilippo\Desktop\flexlibSVN\src\flexlib\containers\SuperTabNavigator.as:1183] at Function/http://adobe.com/AS3/2006/builtin::apply() at mx.core::UIComponent/callLaterDispatcher2()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:11354] at mx.core::UIComponent/callLaterDispatcher()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:11292]

Code at SuperTabNavigator.as at line 1176:

    var child:Container = this.getChildAt(i) as Container;

    var obj:Object = new Object();
    //setting the type to an empty string bypasses a bug in MenuItemRenderer (or in 
    //DefaultDataDescriptor, depending on how you look at it). Try commenting out the
    //line and check out the menu items.
    obj.type = "";
    obj.label = (child.label != "") ? child.label : "Untitled Tab";

Explanation: NavigatorContent is not a Container so when a tab above is cast to Container type, child becomes null. Workaround: let child object be an INavigatorContent.

nicoulaj commented 13 years ago

Updated by jessewo...@gmail.com on 2010-04-30T01:34:04

Thanks for the suggested workaround:

Replace line 1174: var child:Container = this.getChildAt(i) as Container; with var child:INavigatorContent = this.getChildAt(i) as INavigatorContent;

nicoulaj commented 13 years ago

Updated by dasha.fi...@gmail.com on 2010-07-09T14:48:33

happens in flexlib 2.5. for Flex 4 as well - same line, same issues

nicoulaj commented 13 years ago

Updated by rajvbhar...@gmail.com on 2010-10-07T23:27:17

How did you guys replace the code? I am not able to get the source code to flexlib? Any pointers, please.

nicoulaj commented 13 years ago

Updated by jessewo...@gmail.com on 2010-10-07T23:40:20

@rajvbharadwaj

1) Download the zip file and unzip it 2) Create a new Flex Library Project 3) Copy the contents of the src directory into the project src directory. This includes the flexlib directory and the manifest.xml file 4) Open SuperTabNavigator.as under flexlib/containers 5) Update the line and compile 6) Copy the new swc to the lib folder of the project you're using it in.

nicoulaj commented 13 years ago

Updated by rajvbhar...@gmail.com on 2010-10-08T01:23:35

Thanks @jessewolff. I did the same, but when I get the project into FB$, I get an error for undefined FLEX_TARGET_VERSION. I am wondering where I set this property. I am using Flash Builder 4.

nicoulaj commented 13 years ago

Updated by jessewo...@gmail.com on 2010-10-08T01:34:59

Make sure the following is set under the 'Flex Library Compiler' project properties:

Namespace URL: http://code.google.com/p/flexlib/

Manifest file: manifest.xml

Additional compiler arguments: -locale en_US -define+=FLEX_TARGET_VERSION::flex4,true -define+=FLEX_TARGET_VERSION::flex3,false

nicoulaj commented 13 years ago

Updated by rajvbhar...@gmail.com on 2010-10-08T02:51:00

Cool, thank you very much!