2 Replies Latest reply on Sep 3, 2011 10:36 AM by Jason Woodcock

    ERROR: "1119: Access of possibly undefined property selectedItem...

    Jason Woodcock

      Okay, I'm new to Flash Builder 4.5 here so I am developing a mobile app for practice...

       

      Here's the setup:

       

      I have a tabbed view app. In one view I have a list that is populated by data from an XML file (bugs - creepy crawly kind not ghost in the machine type). What I am trying to do is call a new view when a user touches an item in the list. The new view contains data on the bug itself.

       

      The problem I am having is that in the bugList_changeHandler I am getting the error:

       

      ERROR: "1119: Access of possibly undefined property selectedItem through a reference with static type services.bugslist:BugsList.

       

      Here is my function:

       

      import spark.events.IndexChangeEvent;

       

      protected function bugsList_changeHandler(event:IndexChangeEvent):void {

       

      navigator.pushView(views.BugsDetailView,bugsList.selectedItem);

       

      }

       

      Here is my list:

       

      <s:List id="Bugs" width="100%"

      creationComplete="Bugs_creationCompleteHandler(event)" labelField="name" change="bugsList_changeHandler(event)" verticalScrollPolicy="off">

      <s:itemRenderer>

      <fx:Component>

      <s:IconItemRenderer messageField="loc"

      iconField="img" iconWidth="60"

      iconHeight="60" decorator="images/right.png">

      </s:IconItemRenderer>

      </fx:Component>

      </s:itemRenderer>

      <s:AsyncListView list="{getDataResult.lastResult}"/>

       

      And on the detail view, here is my list:

       

      <s:VGroup>

      <s:Label text="{data.img}"/>

      <s:Label text="{data.name}"/>

      <s:Label text="{data.price}"/>

      <s:Label text="{data.loc}"/>

      <s:Label text="{data.time}"/>

      <s:Label text="{data.months}"/>

      <s:Label text="{data.rare}"/>

      </s:VGroup>

       

      And for good measure, here is a sample from my XML file:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <bugs>

      <bug id="agrias">

      <img>http://www.jasonwoodcock.biz/adc/cf/bugs/agrias-butterfly.png</img>

      <name>Agrias Butterfly</name>

      <price>3,000 Bells</price>

      <loc>Near water (not during rain)</loc>

      <months>Jun - Sep</months>

      <time>8:00 am - 5:00 pm</time>

      <rare>Yes</rare>

      </bug>

       

      And for bonus points, name the game this app is for...