Adobe Dreamweaver Forums



Last 10 THreads :         Live stream player (Last Post : noobie_here - Replies : 0 - Views : 1 )           »          cfloop within a cfif tag (Last Post : Azadi - Replies : 2 - Views : 3 )           »          Making constraints on a symbol... (Last Post : sirkibble2 - Replies : 0 - Views : 1 )           »          Creating a boundry in the stage... (Last Post : fazstp - Replies : 2 - Views : 3 )           »          Director or Flash? (Last Post : Sean Wilson - Replies : 1 - Views : 2 )           »          DW8 Activation not working (Last Post : moonliner - Replies : 0 - Views : 1 )           »          Re: Mouse capture won't activate (Last Post : robertnagle - Replies : 0 - Views : 1 )           »          help! my FB3 has gone insane! (Last Post : peteandrus - Replies : 0 - Views : 1 )           »          help! my FB3 has gone insane! (Last Post : peteandrus - Replies : 0 - Views : 1 )           »          How come the html is being displayed, and not the link (Last Post : Skaterstu - Replies : 0 - Views : 1 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 10-09-2008, 08:14 PM
PetervMeijel2704
 
Posts: n/a
Diggs:
Default Drag a child canvas from its parent canvas

Hello,

For days I've been struggeling with a problem that looks fairly simple, but
turns out to be pretty complicated (At least for me).

I have an application with two canvases: a blue canvas and a red canvas. The
red canvas is a child of the blue canvas. As soon as the user drags the red
canvas, he/she should not be able to drop it on the blue canvas again. The rest
of the application (everything except the blue canvas) should accept drag drop
of the red canvas.

I struggeled a lot with this because the drag enter event handler of the
application seems to "override" the application event of the blue canvas: the
blue canvas seems to accept the drag drop of the red canvas. Does anybody know
a solution for this problem?

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
width="780"
creationComplete="creationCompleteHandler()">


<mx:Canvas id="BlueCanvas" x="97" y="263" width="300" height="300"
backgroundColor="blue">

<mx:Canvas id="RedCanvas" x="26" y="38" width="200" height="200"
mouseDown="childMouseDown(event)"
backgroundColor="red">
</mx:Canvas>

</mx:Canvas>

<mx:Script>
<![CDATA[
import mx.core.DragSource;
import mx.core.UIComponent;
import mx.events.DragEvent;
import mx.managers.DragManager;

//Create the event listeners for the drag operations.
private function creationCompleteHandler():void
{
BlueCanvas.addEventListener(DragEvent.DRAG_ENTER, blueCanvasDragEnter);
application.addEventListener(DragEvent.DRAG_ENTER, applicationDragEnter);
}

//The application accepts the drag drop.
//(except when the user drags the red canvas over the blue canvas)
private function applicationDragEnter(eventragEvent):void
{
if (event.dragSource.hasFormat("data"))
{
DragManager.acceptDragDrop(event.currentTarget as UIComponent);
}
}

//The blue canvas should not accept the drag drop.
private function blueCanvasDragEnter(eventragEvent):void
{
event.stopPropagation();
}

//Start the drag drop operation
private function childMouseDown(event:MouseEvent):void
{
var data:String = "data";
var sourceragSource= new DragSource();
source.addData(data, "data");
DragManager.doDrag(event.currentTarget as UIComponent, source, event);
}
]]>
</mx:Script>
</mx:Application>



Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 02:36 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk