10 Replies Latest reply on Dec 10, 2008 11:41 AM by rekhad

    how to startdrag/stopdrag a movieclip which has textfield

    rekhad
      please help me with the following code.

      I can not drag the movie clip which has a input text field.I want to type a number in it and than drag it on the screen

      button_btn.onRelease=function():Void{
      _root.attachMovie("text_mc","input_mc",this.getNextHighestDepth(),{_x:70,_y:150});

      } //input_mc is a movie clip instance which has input textfiled named input_txt
      input_mc.onPress=function():Void{
      startDrag(this);
      }
      input_mc.onRelease=function():Void{
      stopDrag();
      }
        • 1. Re: how to startdrag/stopdrag a movieclip which has textfield
          Rothrock Level 5
          Okay the first question to ask yourself is how will you (or Flash) know when a click is for a drag and when it is for selecting text or entering text?

          Since there is no way to just know you have to design your project with some way for Flash (and the user) to distinguish the two identical actions.

          You could draw some kind of border or handle outside the textbox so that would be the way to drag and a click inside would be to edit.

          You could maybe find some way to signify that the editing is done. And then change the textfield to a non-selectable dynamic text box. Then it would be draggable.

          There might even be some clever way of if they hold the mouse down for a specific period of time Flash will recognize that we have entered drag mode instead of edit mode (or vice versa).

          All of these tricks rely on you deciding how to communicate the idea of "now I want to edit" versus "now I want to drag."
          • 2. Re: how to startdrag/stopdrag a movieclip which has textfield
            rekhad Level 1
            I have made a rectangle and drawn the textfield on itbut still not woking ..If I select the rectangle out the textfield I should be able to drag it but its not allowing me to drag it
            Any thoughts?
            • 3. Re: how to startdrag/stopdrag a movieclip which has textfield
              Rothrock Level 5
              Not really. First I would change your statement to:

              this.startDrag();

              And then I would try it without the text field to see if you can get it working without the added complication. After that I'm not sure.
              • 4. Re: how to startdrag/stopdrag a movieclip which has textfield
                rekhad Level 1
                Yes I am able to drag the movie clip instance without the textfield but with textfield i can drag it but cant edit (that is of no use to me).
                either I can drag the rectangle on which I have the text field or edit the textfield not both???
                • 5. Re: how to startdrag/stopdrag a movieclip which has textfield
                  Rothrock Level 5
                  Ah sorry. The rectangle behind the text box has to be its own movie clip. Then you apply the onPress and onRelease to that and tell them to drag the _parent clip.
                  • 6. Re: how to startdrag/stopdrag a movieclip which has textfield
                    rekhad Level 1
                    thanks I will try this way..
                    • 7. Re: how to startdrag/stopdrag a movieclip which has textfield
                      rekhad Level 1
                      I created a parent movie clip that has a rectangle mc and text field movie clip on top of rectangle mc.I attcahed the parent_mc on root and tried to drag/stop it again I am not able to edit my text field.The code is ......

                      button_btn.onRelease = function():Void {
                      _root.attachMovie("parent","parent_mc",10,{_x:80,_y:100});
                      //rect_mc.attachMovie("mc_text", "text_mc", 11,{_x:50,_y:100});
                      parent_mc.onPress = drag;
                      parent_mc.onRelease =dragEnd;

                      }

                      function drag() {
                      this.startDrag();
                      }
                      function dragEnd() {
                      this.stopDrag();
                      }
                      • 8. Re: how to startdrag/stopdrag a movieclip which has textfield
                        rekhad Level 1
                        can some one help me ?
                        Has anybody tried making a movie clip made of input textfield which is (the movie clip) draggable as well as editable.I am able to
                        do just one thing either drag it or edit it???
                        • 9. Re: how to startdrag/stopdrag a movieclip which has textfield
                          Rothrock Level 5
                          I don't understand your code. You are attaching a movie called "parent" in the libarary and renaming it "parent_mc." That seems like a bad idea because it is likely to look confusing with _parent. So I would give those better names.

                          Next you have commented out attaching something called "mc_txet" which you rename "text_mc" (again confusing, but not as confusing as the parent thing) to rect_mc.

                          Then you attach event handlers to parent_mc. So I'm not really clear on all the things you are trying to do. What you need to do is set aside your current project and start with a brand new document, figure out how to make this work, and then work it back into your existing project. This works for me:

                          1. Brand new document.

                          2. Draw a filled rectangle and convert it to movie clip. Callt he clip, "Background" and give the instance name "background"

                          3. Over the background instance draw an input textfield the field must be smaller than the background art. Give it the instance name, "theInput"

                          4. Select both the background instance and theInput textfield. Convert to symbol. Name the symbol "TextInputer" and name the instance "textInputer"

                          5. Select the frame and put the code shown below.

                          6. It works.

                          7. You could then make the TextInputer exportable for actionscript and use attachMovie and soforth and so on.
                          • 10. Re: how to startdrag/stopdrag a movieclip which has textfield
                            rekhad Level 1
                            Thanks for the reply.
                            In my code parent and mc_text are linkage indentifiers not the instance names.My instance name is parent_mc.
                            I will try working with your code and see how it goes with my project.Thank you very much