2 Replies Latest reply on May 22, 2007 5:48 AM by dfm_

    line line line

    jjminjj
      i start learning for flash action script.
      ----------------------------------------------
      i have mc1,mc2 when i click mc1 the line following mouse and when click mc2 the line stoping.And we can move mc1,mc2 with line anywhere.
      :-)
      ------------
      somebody can guide for me.
      thanks.
        • 1. Re: line line line
          jjminjj Level 1
          this.createEmptyMovieClip("node1",1);
          node1.lineStyle(1,0x000000,100);
          node1.beginFill(0xFD0B0B);
          node1.moveTo(20,30);
          node1.lineTo(50,60);
          node1.lineTo(20,60);
          node1.endFill();
          node1._x = 100;
          node1._y = 200;

          this.createEmptyMovieClip("node2",2);
          node2.lineStyle(1,0x530B45,100);
          node2.beginFill(0xFF00FF);
          node2.moveTo(20,20);
          node2.lineTo(40,20);
          node2.lineTo(40,40);
          node2.lineTo(20,40);
          node2.endFill();
          node2._x = 300;
          node2._y = 150;

          //-------------------------------create button-------------------
          this.createEmptyMovieClip("myButton1",this.getNextHighestDepth());
          myButton1._x = 400;
          myButton1._y = 20;
          var fillType:String = "linear";
          var colors:Array = [0xFAD4DB, 0xEC748B, 0xC13A59, 0xA81230];
          var alphas:Array = [100, 100, 100, 100];
          var ratios:Array = [0, 126, 127, 255];
          var matrix:Object = {matrixType:"box", x:0, y:0, w:80, h:30, r:90/180*Math.PI};
          myButton1.createEmptyMovieClip("buttonBkg",myButton1.getNextHighestDepth());
          myButton1.buttonBkg.lineStyle(0,0x820F26,60,true,"none","square","round");
          myButton1.buttonBkg.beginGradientFill(fillType,colors,alphas,ratios,matrix);
          myButton1.buttonBkg.lineTo(120,0);
          myButton1.buttonBkg.lineTo(120,30);
          myButton1.buttonBkg.lineTo(0,30);
          myButton1.buttonBkg.lineTo(0,0);
          myButton1.buttonBkg.endFill();
          myButton1.createTextField("labelText",myButton1.getNextHighestDepth(),0,5,myButton1._widt h,24);
          myButton1.labelText.text = "Drawing Mode ";

          myButton1.onPress = function() {
          myButton1.labelText.text = "Drawing Mode On";
          };
          ------------------------------------------------
          ------------------------------------------------
          now i have 2 mc.(node1 and node 2)
          when we click button.it,s status = on
          -when we click node1 the line follow mouse anywhere and stop when we click node2 .Now node1 and node2 can not move anywhere.
          when we click button.it's status = off
          -node1 and node2 can move anywhere with line.
          ---------*****-----------
          somebody can guide for me :-)
          thanks.
          • 2. Re: line line line
            dfm_ Level 1
            i feel lazy to write your AS code
            but tips

            get _root._xmouse and _root._ymouse and use them to create line.
            Use _root.onEnterFrame or listener onMouseMove (i think is sth like that). When click stop button you can delete _root.onEnterFrame or listener object, when clicked start create new ones.