dcsimg
A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: Is this easiar than I think??

  1. #1
    Senior Member
    Join Date
    Mar 2002
    Posts
    300
    I want to draw lines that will grow throught different frame intervals, for example I just was a line to begin at (0,0) and finish at (0,500) but the problem is I want to see the animation of the line drawing on the screen. I tried to scale the item but the line strethes starting from the middle. Is there anyway to do this, any help would greatly be appreciated.


    Cheers.

  2. #2
    avatar free
    Join Date
    Jul 2002
    Location
    UK
    Posts
    835
    You could show off and use the new lineTo() dynamic drawing tools in flash mx, but i don't know much about them yet, so i'll stick with the good old scale...

    I assume when you made a mocieclip with just a line in it and used a bit of code to scale that? The one that scaled from the centre? If it is scaling from the centre then the most likely problem is that the MC's registration point is on the middle of the line.

    Try making a MC and put a horizontal line in it, 500px long like you said. Make sure the left most point of the line is touching the cross in the middle of the MC. (Set the lines x and y positions in the properties box to 0,0)

    On the main stage drag on this MC, to position (0,0) like you said, give it an instance name, and add the code either on this MC or in an eventhandler function somewhere...

    e.g.

    Code:
    onClipEvent (load)
    {
    this._xscale = 0;
    }
    
    onClipEvent (enterFrame)
    {
    if (this._xscale < 100)
    {
    this._xscale += 5;
    }
    if (this._xscale > 100)
    {
    this._xscale = 100;
    }
    }
    change the number 5 to make it go faster or smaller...

    P.S. or you could just use a shape tween animation

  3. #3
    Senior Member
    Join Date
    Mar 2002
    Posts
    300
    Yes I tried what you said and it worked in one way but not the other. It no longer stretches from the middle. The problem is the width of the line begin to grow. Can somone help with this or explain how I can use the LineTo command to show a line drawing animation.

  4. #4
    Member
    Join Date
    Jan 2001
    Posts
    49
    _root.createEmptyMovieClip("drawer", 1);
    _root.drawer.startx=yourstartpoint;
    _root.drawer.starty=yourstartpoint;
    _root.drawer.endx=yourendpoint;
    _root.drawer.endy=yourendpoint;
    _root.drawer.lastx=yourstartpoint;
    _root.drawer.lasty=yourstartpoint;

    _root.drawer.onEnterClip=function(){
    _root.master.drawer.clear();
    lineStyle(1, 0xEEEEEE, 100);

    moveTo(startx,starty);
    lineTo((endx-lastx)/2,(endy-lasty)/2);
    lastx=(endx-lastx)/2;
    lasty=(endy-lasty)/2;
    }

  5. #5
    Senior Member
    Join Date
    Mar 2002
    Posts
    300
    Thanks for the code, not sure how it works though...where do I place this code??? I tried copying and pasting the code placing it in frame 1 of my movie and I got nothing. I replaced the values with other values. Please help

  6. #6
    Member
    Join Date
    Jan 2001
    Posts
    49
    1st keyframe was right...

    you have to change the values of the variables

    yourstartpoint (_x and _y where you want to start the line)
    endpoint etc...

  7. #7
    Senior Member
    Join Date
    Mar 2002
    Posts
    300
    Here is my code, not sure what I am doing wrong.

    _root.createEmptyMovieClip("drawer", 1);
    _root.drawer.startx=100;
    _root.drawer.starty=100;
    _root.drawer.endx=300;
    _root.drawer.endy=300;
    _root.drawer.lastx=100;
    _root.drawer.lasty=100;

    _root.drawer.onEnterClip=function(){
    _root.master.drawer.clear();
    lineStyle(1, 0x000000, 100);

    moveTo(startx,starty);
    lineTo((endx-lastx)/2,(endy-lasty)/2);
    lastx=(endx-lastx)/2;
    lasty=(endy-lasty)/2;
    }

  8. #8
    Member
    Join Date
    Jan 2001
    Posts
    49
    sorry, one mistake:

    _root.master.drawer.clear(); should be _root.drawer.clear();

    i copy/pasted this from another movie of me, so the referencess where mismatched

  9. #9
    Senior Member
    Join Date
    Mar 2002
    Posts
    300
    I opened flash and copied and pasted the following code into a keyframe ...and I get nothing...I changed the master to drawer just like you had stated...what else am I doing wrong....
    thanks

    _root.createEmptyMovieClip("drawer", 1);
    _root.drawer.startx=100;
    _root.drawer.starty=100;
    _root.drawer.endx=300;
    _root.drawer.endy=300;
    _root.drawer.lastx=100;
    _root.drawer.lasty=100;

    _root.drawer.onEnterClip=function(){
    _root.drawer.clear();
    lineStyle(1, 0xEEEEEE, 100);

    moveTo(startx,starty);
    lineTo((endx-lastx)/2,(endy-lasty)/2);
    lastx=(endx-lastx)/2;
    lasty=(endy-lasty)/2;

  10. #10
    Senior Member
    Join Date
    May 2001
    Posts
    1,838
    Instead of making a line from stroke, you can make a line symbol from a rectangle of fill with height 3 pixel, width 100; Then the stretch of _xscale will not affect height of this symbol.

    Then code it as jonmack suggested.

  11. #11
    Senior Member
    Join Date
    Mar 2002
    Posts
    300
    any example code as I am not sure the above code works, any help again would be greatly appreciated. What I am trying to achieve is a animated like so

    |----------------------
    |
    |
    |
    |
    |
    |
    |
    |
    |

    The line starts from the top right and continue to the top left, then proceeds down. I want to show the animation of this line drawing

  12. #12
    Senior Member
    Join Date
    Mar 2001
    Posts
    237

    simplest answer is always best

    you don't have to use code unless it serves a purpose... so why don't you just tween it? as someone said: go with the rectangle with a fixed height... and just tween the width from 0 to 100 or whatever.


  13. #13
    Senior Member
    Join Date
    Mar 2002
    Posts
    300
    How do I set a rectangle with a fixed width to be tweened later????

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center