Hi,

Have a one more question about drag & drop.
 
This code is for dragging an item from "GridItem" to canvas. 
It works well while there is no scrollbar(now there are only 2 grid items
no scroll bar appears). 
When I add another few grid items(ex. 30 items), then scrollbar appears, 
and when I drag  it to canves, image(item) didn't visible until I released
mouse. It(item) comes under the scrollbar and canvas. 

What should I do to drag it over the scrollbar and canvas?

I thing setting the depth of the item may slove this. But don't know 
how to do it.I can't use "getNextHighestDepth()" because this is not
movie clip.


thanks

----------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"; 
creationComplete="initApp()">
<mx:Script>
<![CDATA[               
        var bMouseDown:Boolean = false;
        var objectBeingDragged:Object;
        var origLocs:Object = {};
        var targets:Object = {};
        
        function initApp() {
           origLocs[job1] = {x:job1.x, y:job1.y}; 
           origLocs[job2] = {x:job2.x, y:job2.y}                             
           targets[job1] = Canves1;
           targets[job2] = Canves1;   
           cvs.setDepthAbove(Canves1); 
       }
        
        function handleMouseDown(event){
            bMouseDown = true;
            objectBeingDragged = event.target;
        }
        
        function handleMouseMoveSomewhere(event){
            if(bMouseDown)
            {
                 objectBeingDragged.startDrag(true);
                 updateAfterEvent();
            }
        }
        
        function handleMouseUpSomewhere(event){
            if(bMouseDown){
                objectBeingDragged.stopDrag();
                bMouseDown = false;
         
                var x = objectBeingDragged.x + objectBeingDragged.width/2;
                var y = objectBeingDragged.y + objectBeingDragged.height/2; 
                var target = targets[objectBeingDragged];
                var tx = target.x;
                var ty = target.y;
                var th = target.height;
                var tw = target.width;
               
                if ((x >= tx && x<= (tx + tw)) && (y >= ty && y<= (ty + th))) {
                     target.createChild(mx.controls.Image,"", 
{source:objectBeingDragged.source, autoLoad:true, width:32, height:32, 
x:Canves1.mouseX, y:Canves1.mouseY});
                     objectBeingDragged.visible = true;
                       
                }
                objectBeingDragged.x = origLocs[objectBeingDragged].x;
                objectBeingDragged.y = origLocs[objectBeingDragged].y;
                objectBeingDragged = null;   
            }
        }
        ]]>
    </mx:Script>

  <mx:Panel width="100%" height="100%" title="panel1">
  <mx:Canvas width="100%" height="100%">
  <mx:Canvas id="cvs" x="3" y="2" width="100%" height="50" 
backgroundColor="#B9C6F9">
      <mx:Grid x="1" y="1" id="grid" vScrollPolicy="off">
          <mx:GridRow vScrollPolicy="off" hScrollPolicy="off" >
            <mx:GridItem>
                   <mx:Image source="job2.jpg" width="32" height="32" id="job1" 
mouseDown="handleMouseDown(event)" 
mouseMoveSomewhere="handleMouseMoveSomewhere(event)" 
mouseUpSomewhere="handleMouseUpSomewhere(event)" />
            </mx:GridItem>
                <mx:GridItem>
                    <mx:Image source="job3.jpg" width="32" height="32" 
id="job2" mouseDown="handleMouseDown(event)" 
mouseMoveSomewhere="handleMouseMoveSomewhere(event)"  
mouseUpSomewhere="handleMouseUpSomewhere(event)"/>
            </mx:GridItem> 
          </mx:GridRow>
      </mx:Grid>
  </mx:Canvas>
  <mx:Canvas id="Canves1" x="4" y="145"  width="100%" height="225" 
backgroundColor="#DEE0FE" vScrollPolicy="auto" visible="true"></mx:Canvas>
  </mx:Canvas>
  </mx:Panel>
</mx:Application> 



----------------------------------------------------------------------



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to