1 Reply Latest reply on May 11, 2007 1:44 PM by sank22

    Flex package

    MadamZuZu Level 1
      hi :)

      i keep getting this error:


      1119: Access of possibly undefined property categories through a reference with static type Class. AOHotSpot.mxml AOHotSpot line 35 May 11, 2007 3:55:13 PM 221

      i'v never tried classes in Flex before, but basically what i want to try and do is define categories in a class, and have the maina pplication populate a combo box based on it.

      here is my main application code:

      [code]
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="absolute"
      backgroundGradientColors="[#92abd1, #206d93]"
      xmlns:local="*" >

      <mx:Script>
      <![CDATA[
      import mx.controls.Label;
      import flash.net.navigateToURL;


      ]]>
      </mx:Script>

      <mx:Panel width="70%" height="70%" layout="absolute" horizontalCenter="0" verticalCenter="-7.5">
      <mx:HBox width="80%" height="33" horizontalAlign="center" verticalAlign="middle" top="0" horizontalCenter="-0.5">
      <mx:Label text="AO Hotspot Category:" fontWeight="bold"/>
      <mx:ComboBox></mx:ComboBox>
      <mx:ComboBox
      id="employeeDepartment"
      dataProvider="{AOCat.categories}"
      selectedIndex="{AOCat.category}"
      change="{AOCat.category=employeeDepartment.selectedIndex;}"
      />


      </mx:HBox>
      <mx:List width="80%" height="227" horizontalCenter="0" y="41"></mx:List>
      </mx:Panel>

      </mx:Application>
      [/code]

      and my package looks like this:
      [code]
      package
      {
      public class AOCat
      {
      private var _category:uint = 0;


      [Bindable]
      public var modelValid:Boolean = false;

      [Bindable]
      public var categories:Array;
      public function AOCat()
      {
      categories =
      [
      "test", "test2", "test3"
      ];
      }



      [Bindable]
      public function get category():uint
      {
      return _category;
      }

      public function set category(category:uint):void
      {
      _category = category;
      }


      public function get categoryName():String
      {
      return categories[_category];
      }


      }
      }

      [/code]

      do i need some sort of a include or something?
      please ehlp :(
        • 1. Re: Flex package
          sank22
          Hi, please write me the line no.35. where is it located?

          Also what i see here is, dataProvider="{AOCat.categories}"
          selectedIndex="{AOCat.category}"

          you are calling Class Name.field name and property name. you should create object for class AOCat. Then use that object to call field or property name.

          As "categories" & category is not static field or property, you can not use
          AOCat.categories
          AOCat.category

          That is why you are getting the error messge.

          I think you create object like var myobj:AOCat=new AOCat();