Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-31-2007, 03:37 AM   #1
Registered User
Join Date: Jul 2007
Posts: 3
Default Help with dragging TextFields


I am trying to figure out the best way to drag dynamic TextField objects. You can't use startDrag() directly on text so I've been messing around with trying to put the text inside a Sprite...no luck though. Here is an example of one thing I was trying. The rectangle was just a visual and something to drag. It is the closest thing I have to working. I am definitely missing something here. I'd really appreciate a kick in the right direction on dragging text around.

package {
	import flash.display.*;
	import flash.events.*;
	import flash.text.*;
	public class ExampleApplication extends Sprite {
		var MyText:TextField = new TextField();
		var MyRectangle:Sprite = new Sprite();
		public function ExampleApplication() {
			MyText.text = "Hello.";
			MyText.x = 30;
			MyText.y = 20;
			MyText.selectable = false;
      		MyRectangle.graphics.drawRect(0, 0, 100, 50);
			MyRectangle.x = 50;
			MyRectangle.y = 75;
			MyRectangle.addEventListener(MouseEvent.MOUSE_DOWN, pickup);
			MyRectangle.addEventListener(MouseEvent.MOUSE_UP, place);
		public function pickup(event:MouseEvent):void {

		public function place (event:MouseEvent):void {
parallax is offline   Reply With Quote
Old 07-31-2007, 06:22 PM   #2
Registered User
Join Date: Jul 2007
Posts: 3
Default More info...please help.

I also tried to create a sprite that contained a TextField in the display list with a transparent rectangle on top of it in the display list. To test it, I made the alpha value .25 so it wasn't totally transparent. When I added the event listeners to the sprite, and invoke startDrag(), it let me drag the translucent rectangle, but the text stayed put. I'm confused. Please help.
parallax is offline   Reply With Quote
Old 07-31-2007, 07:02 PM   #3
Registered User
Join Date: Jul 2007
Posts: 3
Default Got it working...here's how

I put the text in a sprite and used event.currentTarget.startDrag() instead of event.target.startDrag(). The currentTarget property seems to eliminate the selection of the inner child objects.
parallax is offline   Reply With Quote

Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Printjob cuts out multiline textfields outside of scrollrect Tailgunner ActionScript 3.0 1 06-21-2007 11:32 AM
Listing objects (TextFields, MovieClips etc) created in authoring time? str3ber ActionScript 2.0 1 05-02-2007 08:26 AM
dragging a movieclip but when not dragging click to run function pixelwhore ActionScript 1.0 (and below) 3 03-30-2005 08:24 PM
Masking textfields w/ AS miknsh5 ActionScript 1.0 (and below) 9 04-16-2004 09:30 AM
for-in over TextFields? [mx-any] Mortimer Jazz ActionScript 1.0 (and below) 11 09-18-2003 12:52 PM

All times are GMT. The time now is 01:41 PM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.