-
drag and drop with input text
I want to drag and drop an input textfield where the user than can enter their name so to speak but put it anywhere they want.
so far i can just drag and drop everything but when you convert the input text the whole of it becomes drag and drop and you cant input . . .anyway around this?
-
Prid - Outing
It was a bit tricky, but I somehow managed to make a working script
Actionscript Code:
onClipEvent(load){ checker = false; }
onClipEvent(enterFrame){ if(checker == false){ my_txt.onKillFocus = function(){ checker = true; } } else { this.onPress = function(){ if(checker != false){ startDrag(this, false); } delete onPress; } this.onRelease = function(){ stopDrag(); checker = false; delete onRelease; } } trace(checker); }
What I have done, is to make a Input Text Field, and converted it into a Movieclip. And I've put the code above, on the movieclip. Notice the my_txt - it's the Instance name (not Variable name) of the Input Field inside the movieclip, change it to your text Instance Name.
This code will make someone write whatever they want in the textfield, and when clicking outside the text field, they can then drag it. If they want to edit it again, they simply need to click at it again. So, everytime you type something in there, and click outside, clicking again will result in dragging it, and if you stop dragging it after dragging, the text field will be writable again. Don't understand me, try it for yourself, and you'll see what I mean
Hope this helps you
If you want another method, I can see if I can make it
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
Prid - Outing
Okay, so I've been like trying to make a much more enhanced version of my code above, and it sure took alot of time, but I finally managed to do it, almost - the font is still red once double-clicked, but doesn't change color until you click on the Text:
Actionscript Code:
onClipEvent(load){ checker = false; validate = false; double = false; double_check = false; colors = false; function double_click(){ double = false; clearInterval(this); } }
onClipEvent(enterFrame){ if(checker == false){ delete onPress; delete onRelease; my_txt.onKillFocus = function(){ checker = true; } my_txt.onSetFocus = function(){ colors = true; } } else if(checker == true) { colors = false; this.onPress = function(){ if(double == true){ double_check = true; colors = true; } if(checker != false && double == false){ startDrag(this, false); } } this.onRelease = function(){ stopDrag(); double = true; clearInterval(time); time = setInterval(double_click, 100); if(double_check == true){ checker = false; double_check = false; } } } if(checker == true){ onMouseDown = function(){ if(hitTest(_root._xmouse, _root._ymouse, true)){ myColor = new Color(this); myColor.setRGB(0xFF0000); } } } onMouseUp = function(){ if(!hitTest(_root._xmouse, _root._ymouse, true)){ myColor = new Color(this); myColor.setRGB(0x000000); } } if(colors == true){ myColor = new Color(this); myColor.setRGB(0x00FF00); } }
Replace this code with the previous post's code, on the Movieclip.
What this will do: It will first make the text field writeable, so that the player may change the name at first, and when clicked outside of textfield's area, you can drag the textfield. To make it writeable again, you have to double-click
Hope this makes your Flash more wicked
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
Hi Nig,
It would be great if you can share the full code.
I am also in the need of same functionality. I have tried with your code, which you have posted, but couldn't get through..
Thanks for help..
Rishi
-
I am using Flex Builder 4.6 for the development.
-
Prid - Outing
Hi,
that is the full code, but I have no experience with Flex Builder and don't know how it functions (and the code was targeted for Flash), so I'm sorry but I can't help you any further
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|