0 Replies Latest reply on Dec 30, 2010 2:26 AM by sankar_bhatta

    triggering a button click event


      hi Experts,


      in the MXML file i ma using Horizontallist control to display some images and when i click on the images i am displaying the image with some details of it using a tilelist control.


      here is the code for Horizontallist




      <mx:HorizontalList id="myList" dataProvider="{imgs}"


      {imgs.length}" itemClick="getImageData(event)" itemRenderer="Thumbnail" >


      imgs is an arraycollection contaiing image names and their paths


      getImageData fucntion code is given below which is triggered when i click on an image



      public function getImageData(evt:ListEvent):void



      tilelist =

      new TileList();


      img.width = 300;

      img.height = 300;

      tilelist.dataProvider = myList.selectedItem;

      tilelist.itemRenderer =

      new ClassFactory(imagedetails);

      tilelist.addEventListener(Event.COMPLETE, image_complete);

      tilelist.addEventListener(ResizeEvent.RESIZE, image_resize);

      tilelist.addEventListener(MouseEvent.CLICK, image_click);


      "addedEffect", image_addedEffect);


      "removedEffect", image_removedEffect);


      this, true);



      . i am using mouseevent.click event to call a method image_click(), which will close the tilelist popup triggered by the above function.




      private function image_click(evt:MouseEvent):void {


      as TileList);



      imagedetails is another mxml fiel i am using as itemrenderer for my tilelist controlthe code for imagedetails.mxml is as below





      initialize="initApp()" xmlns:local="



      white" borderColor="#FFFFFF" backgroundGradientAlphas="[0.0, 0.0]">





      import mx.controls.Button;


      import mx.controls.TileList;


      import mx.events.ListEvent;


      import mx.binding.utils.BindingUtils;


      import mx.controls.Image;


      import mx.core.ClassFactory;


      import mx.effects.Resize;


      import mx.events.ResizeEvent;


      import mx.events.ListEvent;



      import mx.events.ItemClickEvent;


      import mx.managers.PopUpManager;


      import flash.events.MouseEvent;


      import mx.controls.Alert;


      import mx.events.FlexEvent;


      import sap.FlashIsland;


      import mx.collections.*;


      public function initApp():void







      public function clicked():void {







      <mx:Form width="366" height="273" id="form" label="form">


      <mx:FormItem label="Label">


      <mx:HBox width="270" id="hbox" height="239">


      <mx:Image width="132" height="204" id="img" source="{data.IMAGE_URL}" scaleContent="true"/>


      <mx:VBox width="50%" height="100%" id="vbox" label="vbox">


      <mx:Label text="routeid" id="routeid" enabled="true"/>


      <mx:TextInput id="route" text="route" editable="false"/>


      <mx:Button label="Button" id="button" click="clicked()"/>











      if you see  there is a button and click event associated with it. what is happening is eventhough i click in the button the system is calling the image_click method instead of clicked() method associated with the button. how do i differentiate between the two events?