Hi,
Below is the code where I am creating GridItems dynamically:
public function dynamicData(lower:int,upper:int):void{
//creating GridItems dynamically
for(var row_count:int=0;row_count<4;row_count++)
{
var grid_row:GridRow=new GridRow();
for(var item_count:int=0;item_count<5;item_count++)
{
if(item_count>=temp_EntityColl.getEntityCount())
break;
if(ind>=temp_EntityColl.getEntityCount())
break;
var ent_obj:Entity=temp_EntityColl.getEntityByIndex(ind);
var grid_item:GridItem=new GridItem();
grid_item.setStyle("paddingBottom",5);
grid_item.setStyle("paddingLeft",5);
grid_item.setStyle("paddingRight",5);
var v_box:VBox=new VBox();
var img:Image=new Image();
var txt:Label=new Label();
txt.setStyle("fontWeight", "bold");
txt.setStyle("fontSize", 10);
txt.maxWidth=120;
var img_type:String=ent_obj.getType();
img.source=ImageSelector.getImage(img_type);
txt.text=ent_obj.getName();
v_box.addElement(img);
v_box.addElement(txt);
//v_box.addEventListener(MouseEvent.MOUSE_DOWN,doDrag);
grid_item.addElement(v_box);
grid_item.id=ent_obj.getID();
grid_item.addEventListener(MouseEvent.MOUSE_OVER,ClickHandler);
grid_item.addEventListener(MouseEvent.MOUSE_DOWN,doDrag);
//giving name to use it for backgroung color highlighting
grid_item.name=ent_obj.getName();
grid_item.doubleClickEnabled=true;
//adding double click listener to change the state and display the
graph
//grid_item.addEventListener(MouseEvent.DOUBLE_CLICK,DisplayGraph);
grid_item.contextMenu=cm;
grid_row.addElement(grid_item);
ind++;
//}
}
grid.addElement(grid_row);
}
And below is the code for the doDrag method which is called when we do a
mouse down
private function doDrag(event:MouseEvent):void
{
var grid_item:GridItem = event.currentTarget as GridItem;
var dragItem:GridItem = new GridItem();
dragItem=grid_item;
var dsource:DragSource = new DragSource();
dsource.addData(grid_item, 'img');
DragManager.doDrag(grid_item, dsource, event, dragItem);
}
On Wed, Mar 30, 2011 at 2:00 PM, Rajesh Yadav <[email protected]> wrote:
> can you please share your code..
>
> On Mar 29, 6:55 pm, madhavi chinni <[email protected]>
> wrote:
> > Hi,
> >
> > I have 2 panels.In one Panel I have GridItems which are created
> > dynamically through actionscript.I want to drag and drop that GridItem
> > into another Panel.But when I am doing that the GridItem is getting
> > completely moved into another Panel.I want the original copy to be
> > still in the first Panel.
> > Could anyone help me on this.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Flex India Community" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/flex_india?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en.