Saturday, February 19, 2011

drag-and-drop problem in a Tilelist using an ItemRenderer

Hello,

in my flex application, I created a Tilelist. In this Tilelist, I am using an ItemRenderer to create a box consisting of an image and an VSlider in each tile.

The tile need to be dragable when you click on the image, but not dragable when you slide the slider. How can I achieve this ? I have been scratching my head searching on Google for one day and I have really no idea.

I look forward to your help. Thank you.

From stackoverflow
  • Hello, I found a solution to my problem, however it may not be the best one.

    Using this :

            public var overImage:Boolean = false;
    
            public function checkAllow(evt:DragEvent):void {
    
                if(overImage == false)
                {
                 evt.preventDefault()
                }
            }
    
            public function isOverImage():void {
                overImage = true;
            }
    
            public function isOutImage():void {
                overImage = false;
            }
    

    I call those functions like this :

    On my image component

    mouseOver="outerDocument.isOverImage()" mouseOut="outerDocument.isOutImage()"
    

    And for my tilelist I did this

    Tiles.addEventListener(DragEvent.DRAG_START, checkAllow);
    

    Hope it helps some people.

0 comments:

Post a Comment