[flexcoders] Re: Multiple Lists

2008-08-03 Thread Rafael Faria
Ok... got it working the way i wanted. Maybe it's useful to someone else.


var dumm:ArrayCollection = new ArrayCollection(['Test1','Test2','Test3']);
var hhbox:HBox = new HBox();
hhbox.percentWidth = 100;

var list1:List = new List();
list1.percentWidth = 50;
list1.dataProvider = dumm;
list1.allowMultipleSelection = true;
list1.dropEnabled = true;
list1.dragEnabled = true;
list1.dragMoveEnabled = true;
list1.setStyle("alternatingItemColors",["#FF", "#EE"]);
list1.name = value.fieldname + '_source';
list1.id = value.fieldname + '_source';

list1.addEventListener(DragEvent.DRAG_DROP,function(e:DragEvent):void 
{
e.currentTarget.hideDropFeedback(e);
});

list1.addEventListener(DragEvent.DRAG_OVER,function(e:DragEvent):void 
{
if (e.target.id.replace('_source','') ==
List(e.dragInitiator).id.replace('_source','')) 
{
e.currentTarget.showDropFeedback(e);
DragManager.showFeedback(DragManager.MOVE);
} 
else 
{
e.currentTarget.hideDropFeedback(e);
e.preventDefault();
}
});

list1.addEventListener(DragEvent.DRAG_EXIT,function(e:DragEvent):void {
e.currentTarget.hideDropFeedback(e);
});


var list2:List = new List();
list2.percentWidth = 50;
list2.dataProvider = new ArrayCollection();
list2.allowMultipleSelection = true;
list2.dropEnabled = true;
list2.dragEnabled = true;
list2.dragMoveEnabled = true;
list2.setStyle("alternatingItemColors",["#FF", "#EE"]);
list2.name = value.fieldname;
list2.id = value.fieldname;
list2.addEventListener(DragEvent.DRAG_DROP,function(e:DragEvent):void 
{
e.currentTarget.hideDropFeedback(e);
});

list2.addEventListener(DragEvent.DRAG_OVER,function(e:DragEvent):void 
{


if (e.target.id == List(e.dragInitiator).id.replace('_source','')) 
{
e.currentTarget.showDropFeedback(e);
DragManager.showFeedback(DragManager.MOVE);
} 
else 
{
e.currentTarget.hideDropFeedback(e);
e.preventDefault();
}
});

list2.addEventListener(DragEvent.DRAG_EXIT,function(e:DragEvent):void {
e.currentTarget.hideDropFeedback(e);
});

hhbox.addChild(list1);
hhbox.addChild(list2);

addChild(hhbox);

--- In flexcoders@yahoogroups.com, "Rafael Faria"
<[EMAIL PROTECTED]> wrote:
>
> I got this working, but if it doesnt use the builtin events when i
> drop it. I just disapear with the items i'm dragging. 
> 
> I don't want to create new function to the drop event, i want to use
> the builtin one. Any idea why?!
> 
> Alex, anything you can help me with this code so i can keep using the
> builtin dragdrop events and just specify the list i want to interact?
> 
> DragManager.showFeedback(DragManager.MOVE) doesn't seem to be working
> if you don't put the DragManager in the Enter event. 
> 
> =/
> 
> 
> var dumm:ArrayCollection = new
ArrayCollection(['Test1','Test2','Test3']);
> var hhbox:HBox = new HBox();
> hhbox.percentWidth = 100;
> 
> var list1:List = new List();
> list1.percentWidth = 50;
> list1.dataProvider = dumm;
> list1.allowMultipleSelection = true;
> list1.dropEnabled = false;
> list1.dragEnabled = true;
> list1.dragMoveEnabled = true;
> list1.setStyle("alternatingItemColors",["#FF", "#EE"]);
> list1.name = value.fieldname + '_source';
> list1.id = value.fieldname + '_source';
> list1.addEventListener(DragEvent.DRAG_ENTER,function(e:DragEvent):void {
>   DragManager.acceptDragDrop(UIComponent(e.currentTarget));
> });
> 
> list1.addEventListener(DragEvent.DRAG_OVER,function(e:DragEvent):void 
> {
>   if (e.target.id == List(e.dragInitiator).id + '_source') {
>   DragManager.showFeedback(DragManager.MOVE);
>   } else {
>   DragManager.showFeedback(DragManager.NONE);
>   return;
>   }
> });
> 
> 
> var list2:List = new List();
> list2.percentWidth = 50;
> list2.dataProvider = new ArrayCollection();
> list2.allowMultipleSelection = true;
> list2.dropEnabled = false;
> list2.dragEnabled = true;
> list2.dragMoveEnabled = true;
> list2.setStyle("alternatingItemColors",["#FF", "#EE"]);
> list2.name = value.fieldname;
> list2.id = value.fieldname;
> list2.addEventListener(DragEvent.DRAG_ENTER,function(e:DragEvent):void {
>   DragManager.acceptDragDrop(UIComponent(e.currentTarget));
> });
> 
> list2.addEventListener(DragEvent.DRAG_OVER,function(e:DragEvent):void 
> {
>   
>   if (e.target.id == List(e.dragInitiator).id.replace('_source','')) {
>   DragManager.showFeedback(DragManager.MOVE);
>   } else {
>   DragManager.showFeedback(DragManager.NONE);
>   return;
>   }
> });
> 
> hhbox.addChild(list1);
> hhbox.addChild(list2);
> 
> 
> 
> --- In flexcoders@yahoogroups.com, "Alex Harui"  wrote:
> >
> > dragInitiator in the dragEvent
> > 
> > 
> > 
> > From: flexcoders@yahoogroups.com
[mailto

[flexcoders] Re: Multiple Lists

2008-08-03 Thread Rafael Faria
I got this working, but if it doesnt use the builtin events when i
drop it. I just disapear with the items i'm dragging. 

I don't want to create new function to the drop event, i want to use
the builtin one. Any idea why?!

Alex, anything you can help me with this code so i can keep using the
builtin dragdrop events and just specify the list i want to interact?

DragManager.showFeedback(DragManager.MOVE) doesn't seem to be working
if you don't put the DragManager in the Enter event. 

=/


var dumm:ArrayCollection = new ArrayCollection(['Test1','Test2','Test3']);
var hhbox:HBox = new HBox();
hhbox.percentWidth = 100;

var list1:List = new List();
list1.percentWidth = 50;
list1.dataProvider = dumm;
list1.allowMultipleSelection = true;
list1.dropEnabled = false;
list1.dragEnabled = true;
list1.dragMoveEnabled = true;
list1.setStyle("alternatingItemColors",["#FF", "#EE"]);
list1.name = value.fieldname + '_source';
list1.id = value.fieldname + '_source';
list1.addEventListener(DragEvent.DRAG_ENTER,function(e:DragEvent):void {
DragManager.acceptDragDrop(UIComponent(e.currentTarget));
});

list1.addEventListener(DragEvent.DRAG_OVER,function(e:DragEvent):void 
{
if (e.target.id == List(e.dragInitiator).id + '_source') {
DragManager.showFeedback(DragManager.MOVE);
} else {
DragManager.showFeedback(DragManager.NONE);
return;
}
});


var list2:List = new List();
list2.percentWidth = 50;
list2.dataProvider = new ArrayCollection();
list2.allowMultipleSelection = true;
list2.dropEnabled = false;
list2.dragEnabled = true;
list2.dragMoveEnabled = true;
list2.setStyle("alternatingItemColors",["#FF", "#EE"]);
list2.name = value.fieldname;
list2.id = value.fieldname;
list2.addEventListener(DragEvent.DRAG_ENTER,function(e:DragEvent):void {
DragManager.acceptDragDrop(UIComponent(e.currentTarget));
});

list2.addEventListener(DragEvent.DRAG_OVER,function(e:DragEvent):void 
{

if (e.target.id == List(e.dragInitiator).id.replace('_source','')) {
DragManager.showFeedback(DragManager.MOVE);
} else {
DragManager.showFeedback(DragManager.NONE);
return;
}
});

hhbox.addChild(list1);
hhbox.addChild(list2);



--- In flexcoders@yahoogroups.com, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> dragInitiator in the dragEvent
> 
> 
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of Rafael Faria
> Sent: Sunday, August 03, 2008 7:57 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Multiple Lists
> 
> 
> 
> I have multiple lists and i want one drag to another.
> 
> The drag and drop is already working. My problem is that i have like
> 10 lists and any of them can drag to any other.
> 
> Is there an easy way to set what list it can come from?
> 
> like
> 
> list1 can just receive dragable item from list2 and vice-versa. 
> 
> list3 can jusst receive from list4 and vice-versa.
> 
> list5 from list6. 
> 
> and so on.
> 
> What is the best way to work with drag and drop between lists? the
> native one or using the dragmanager?
> 
> Thanks :p
>