Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Create Draggable Input text

New Here ,
Dec 09, 2007 Dec 09, 2007
I Made a Draggable Inputtext but when I drag it I can not write into it ,I try to put a button beside input text and put the Drag action in the button ,it works fine but ,is there any way to make the Draggable Input text by itself without the button beside it
TOPICS
ActionScript
544
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 09, 2007 Dec 09, 2007
>>I Made a Draggable Inputtext but when I drag it I can not write into it ,I
>>try
to put a button beside input text and put the Drag action in the button ,it
works fine but ,is there any way to make the Draggable Input text by itself
without the button beside it
<<

Right, probably you put the input text into a movie clip and then assigned
onPress and onRelease events? Then the mc containing the text absorbs the
mouse events so your input field can't get the focus. You can get around
this fairly easily using a mouse listener that just moves the field with the
mouse. I have an input text field with an instance name of dragText, and the
code below is on frame 1. Note in the MouseMove test I am also testing to
see if the control key is down - I added this to allow the mouse to still
function normall to select text for editing, but move the field when control
is down.


var mouseListener:Object = new Object();
mouseListener.onMouseDown = function() {
this.deltaX = _xmouse - dragText._x;
this.deltaY = _ymouse - dragText._y;
this.dragging = true;
};
mouseListener.onMouseUp = function() {
this.dragging = false;
};
mouseListener.onMouseMove = function() {
if((_xmouse >= dragText._x) && (_xmouse <= dragText._x + dragText._width)
&& (_ymouse >= dragText._y) && (_ymouse <= dragText._y + dragText._height)
&& this.dragging && Key.isDown(Key.CONTROL)){
dragText._x = _xmouse - this.deltaX;
dragText._y = _ymouse - this.deltaY;
}
};
Mouse.addListener(mouseListener);




--
Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 09, 2007 Dec 09, 2007
Thank you for your help Dave,
you are the man
can i get the name of the Draggable Text Daynamicly form the mouse event i.e when the mouse Press down tell me the name of the instnace
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 09, 2007 Dec 09, 2007
Thank you for your help Dave,
you are the man
can i get the name of the Draggable Text Daynamicly form the mouse event i.e when the mouse Press down tell me the name of the instnace
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 09, 2007 Dec 09, 2007
Thank you for your help Dave,
you are the man
can i get the name of the Draggable Text Daynamicly form the mouse event i.e when the mouse Press down tell me the name of the instnace
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 09, 2007 Dec 09, 2007
LATEST
I take it you want to move more than one text instance? I'd throw the code
in a class, then make an instance for each text field you want to move.


class com.blurredistinction.MoveText
{
private var myMouse:Object;

function MoveText(dragText:TextField)
{
myMouse = new Object();

myMouse.onMouseDown = function() {
this.deltaX = _xmouse - dragText._x;
this.deltaY = _ymouse - dragText._y;
this.dragging = true;
};
myMouse.onMouseUp = function() {
this.dragging = false;
};
myMouse.onMouseMove = function() {
if((_xmouse >= dragText._x) && (_xmouse <= dragText._x + dragText._width)
&& (_ymouse >= dragText._y) && (_ymouse <= dragText._y + dragText._height)
&& this.dragging && Key.isDown(Key.CONTROL)){
dragText._x = _xmouse - this.deltaX;
dragText._y = _ymouse - this.deltaY;
}
};

Mouse.addListener(myMouse);
}
}


Then in Flash:

var m1 = new com.blurredistinction.MoveText(dragText);
var m2 = new com.blurredistinction.MoveText(dragText2);



--
Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines