2 Replies Latest reply on Feb 11, 2010 11:28 PM by Sherwette.Mansour

    Checkbox, click's call to a function

    Sherwette.Mansour

      I have created a checkbox in an itemRenderer in a dataGrid, I wanted to link this check box by a click to a function created in actionscript. However, when I try to call the function it says: "1180: Call to a possibly undefined method topSelected." , which doesn't make sense because I have defined the function!

       

      Please if anyone can assist me in this, I'd really appreciate it.

       

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

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">


      <mx:Script>

      <![CDATA[

       

      import mx.controls.*;

      public function topSelected():void{

       

      }

        public function bottomSelected():void{

       

      }

      ]]>

      </mx:Script>


      <mx:XML id="games" source="data.xml"/>


      <mx:Panel width="530" height="610" layout="absolute" title="Advanced Datagrids">

          <mx:Label horizontalCenter="0" y="1" text="Our Favorite Games"

             fontSize="16" fontWeight="bold"/>

          <mx:DataGrid id="dgPeeps" x="0" y="25" width="510" height="260" selectedIndex="0" dataProvider="{games.image}">

            <mx:columns>

              <mx:DataGridColumn headerText="Name" width="75">

              <mx:itemRenderer>

          <mx:Component>

            <mx:VBox verticalGap="2">

              <mx:Label text="{data.id}" />       

            </mx:VBox>

          </mx:Component>

        </mx:itemRenderer>

              </mx:DataGridColumn>

              <mx:DataGridColumn headerText="Info" width="80">

              <mx:itemRenderer>

          <mx:Component>

            <mx:VBox verticalGap="2">

              <mx:Label text="{data.imageURL}" />       

            </mx:VBox>

          </mx:Component>

        </mx:itemRenderer>

              </mx:DataGridColumn>

              <mx:DataGridColumn headerText="Favorite Game">

              <mx:itemRenderer>

          <mx:Component>

            <mx:VBox verticalGap="2">

              <mx:Image source="assets/{data.imageURL}" width="100" height="100"

         scaleX=".25" scaleY=".25"/>       

            </mx:VBox>

          </mx:Component>

        </mx:itemRenderer>

              </mx:DataGridColumn>

              <mx:DataGridColumn headerText="Top">

              <mx:itemRenderer>

          <mx:Component>

            <mx:VBox verticalGap="2">

             <mx:CheckBox id="top" click="topSelected()" />     

            </mx:VBox>

          </mx:Component>

        </mx:itemRenderer>

              </mx:DataGridColumn>

              <mx:DataGridColumn headerText="Bottom" >

              <mx:itemRenderer>

          <mx:Component>

            <mx:VBox verticalGap="2">

             <mx:CheckBox id="bottom" />     

            </mx:VBox>

          </mx:Component>

        </mx:itemRenderer>

              </mx:DataGridColumn>

             

        

            </mx:columns>

          </mx:DataGrid>

          <mx:Canvas>

          <mx:Image x="10" y="338" width="300" height="240" id="imgGameScreen"

          source="assets/{dgPeeps.selectedItem.imageURL}" visible="true"/>

          <mx:Image x="10" y="568" width="300" height="240" id="imgGameScreen2"

          source="assets/{dgPeeps.selectedItem.imageURL}" visible="true"/>

          <mx:Label x="10" y="293" fontWeight="bold" fontSize="13" id="lblGameName"/>

          <mx:Label x="318" y="318" text="Developer:"/>

          <mx:Label x="318" y="335" id="lblDeveloper" text="{dgPeeps.selectedItem.id}"/>

          <mx:Label x="318" y="361" text="Publisher:"/>

          <mx:Label x="318" y="378" id="lblPublisher" text="{dgPeeps.selectedItem.imageURL}"/>

          </mx:Canvas>

         

        </mx:Panel>

       

      </mx:Application>