Adobe Flex

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentAdobe Flex

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old September 24th, 2012, 12:09 PM
arjunlove2k6 arjunlove2k6 is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 2 arjunlove2k6 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 m 59 sec
Reputation Power: 0
Drag and drop is not clear with mouse events

I am trying to get the exact working of drag and drop using mouse events, but stuck at dropping of image at particular index within the stack. Below is my code, which i have tried.

Code:
<mx:Application  layout="absolute" creationComplete="carcan();">
	<mx:Script>
		<![CDATA[
			
				import mx.containers.Canvas;
                import mx.controls.Image;
                
                private var images:Array;
                private var images1:Array;
                private const IMAGE_COUNT:uint = 5;
				private var img:Image;
				private var img1:Image;

				private var img2:Image;
				
				private var points:flash.geom.Point;
				private var offset_x:int;
				private var offset_y:int;
				private var canal:Canvas;
				private var doDrag:Boolean;
                
                [Embed(source='cards/2C.png')]
                private var Image0:Class;
                
                [Embed(source='cards/2D.png')]
                private var Image1:Class;

                [Embed(source='cards/2H.png')]
                private var Image2:Class;

                [Embed(source='cards/2S.png')]
                private var Image3:Class;

                [Embed(source='cards/3C.png')]
                 private var Image4:Class;
                 
                 public function carcan():void
                 {
                 	canal = new Canvas();
                 	canal.setStyle("backgroundColor","blue");
                 	canal.x=100;
                 	canal.y=50;
                 	canal.width=500;
                 	canal.height=400;
                 	this.addChild(canal);
                 	init();
                 }
                 
                 public function init():void
                 {
                  images = new Array(IMAGE_COUNT);
                 	 for (var i:int = 0; i < IMAGE_COUNT; i++)
                        {
                        	 img= new Image();
                        	 img1= new Image();
                                images[i] = this["Image" + i];
                                trace(images[i]);
                           		                        
						img.x=(i*30)+50;
						img.source=images[i];
						img.id="Image"+i;
						canal.addChild(img);
						txt2.text+=String(img.x)+", ";
						
    					
						 img.addEventListener(MouseEvent.MOUSE_DOWN, md);
						img.addEventListener(MouseEvent.MOUSE_MOVE, mm);
						canal.addEventListener(MouseEvent.MOUSE_OUT,smu);
						img.addEventListener(MouseEvent.MOUSE_UP, mu);
						 
	                    }
                        
                 }
                  public function md(event:MouseEvent):void
				{
				
				img = new Image();
					doDrag=true;
					
					  canal.setChildIndex(Image(event.target),images.len  gth-1);
					  
					 img.addEventListener(MouseEvent.MOUSE_MOVE, mm);
					
				}
				
				public function mm(event:MouseEvent):void
				{
					
					
					 if(doDrag==true)
					 {
					 	points = new Point();
					images = new Array(IMAGE_COUNT);
					
					
					img = new Image();
					img = Image(event.target);
					
					points.x=event.target.x;
					points.y=event.target.y;
					points = localToGlobal(points);
					img.x=points.x;
					img.y=points.y;
					 img.alpha=0.7;
					img.addEventListener(MouseEvent.MOUSE_UP, mu);					
					var boundar:flash.geom.Rectangle = new Rectangle(this.x, this.y, 250, 100);
					img.startDrag(false, boundar);
					txt1.text=String(img.x);
					
					 }
				}
             
              
                
				
			
				
			
			
		]]>
	</mx:Script>
	<mx:Label text="Card move"  /><mx:TextInput id="txt1"  x="74" y="-2"/>
	<mx:Label text="Cards Position" x="371"  y="2"/><mx:TextInput id="txt2" x="467"/>		
</mx:Application>

Last edited by arjunlove2k6 : September 27th, 2012 at 02:45 AM.

Reply With Quote
  #2  
Old September 26th, 2012, 11:47 AM
arjunlove2k6 arjunlove2k6 is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 2 arjunlove2k6 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 m 59 sec
Reputation Power: 0
please someone help me in this.

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentAdobe Flex > Drag and drop is not clear with mouse events


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap