Question : A button & image inside a tileList

1:
2:
3:
4:
5:
                    <mx:TileList width="100%" height="100%" id="product_tile" itemRenderer="CustomItemRenderer" 
					columnCount="4" 
					styleName="tile1"
					itemClick="tileList_itemClick(event)">

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
private function tileList_itemClick(evt:ListEvent):void { 
                img = new Image(); 
                // img.width = 300; 
                // img.height = 300; 
                img.maintainAspectRatio = true; 
                img.addEventListener(Event.COMPLETE, image_complete); 
                img.addEventListener(ResizeEvent.RESIZE, image_resize); 
                img.addEventListener(MouseEvent.MOUSE_OUT, image_click); 
				img.addEventListener(MouseEvent.MOUSE_DOWN, image_start_drag);
				img.addEventListener(MouseEvent.MOUSE_UP, image_stop_drag);				
                img.source = "http://localhost/funktion/templates/index/productimg/big/" + noS(evt.itemRenderer.data.spic);
				//Alert.show(img.source.toString());
                img.setStyle("addedEffect", image_addedEffect); 
                img.setStyle("removedEffect", image_removedEffect); 
                if (evt.itemRenderer.data.spic != "no_photo80x80.gif") {
				PopUpManager.addPopUp(img, this, true); 
		}
				
            

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
<?xml version="1.0" encoding="utf-8"?> 
<!-- http://blog.flexexamples.com/2008/03/08/creating-a-simple-image-gallery-with-the-flex-tilelist-control/ --> 
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" 
        horizontalAlign="center" 
        verticalAlign="middle" width="150" height="180">  
  

	<mx:Image source="http://localhost/funktion/templates/index/productimg/{data.spic}" />
    <mx:TextArea text="{data.name}" styleName="myFontStyle" wordWrap="true" editable="false" /> 
	<mx:Button label="details"  />


  
</mx:VBox>


The problem is, the tilelist itemClick will cover the button onclick or the image click function. that means,
i only want to click the image to enlarge the image, and click the button show alert box. But now, i click the button (actually clicking the tile item), will also enlarge the image and show the alert box....

Answer : A button & image inside a tileList

In the button tag define a click event handler say its btn_clickHandler(event)

private function btn_clickHandler(event:MouseEvent):void{
         //Do whatever you want to do when button is clicked
       
       //Then stop the click event propagation
       event.stopImmediatePropagation();
}


you can do the same with the image.
Random Solutions  
 
programming4us programming4us