A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: randomization

  1. #1
    Junior Member
    Join Date
    Nov 2004
    Location
    Philadelphia
    Posts
    19

    randomization

    i need to know how make a line of an adjustable length(something that i can set manually) and how to make it randomly appear and disappear on differnt y coordinates.

    can anyone help. thanx,

    jeff

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    A line is defined by it's starting coordinates and ending coordinates.

    x1,y1 ---> x2,y2

    It is unclear from your question which of these coordinates you want fixed, and which you want randomized.

    Let's say you want a horizontal line that begins at x1=10, and has a manually specified length, and a random y position. Then you would do this:

    code:

    x1 = 10;
    x2 = x1 + desiredLength;

    y1 = random(Stage.height);
    y2 = y1; // since y2 == y1, the line is flat

    _root.lineStyle(2,0,100);
    _root.moveTo(x1,y1);
    _root.lineTo(x2,y2);


  3. #3
    Junior Member
    Join Date
    Nov 2004
    Location
    Philadelphia
    Posts
    19
    thank you, its a start for what i want to do overall. Greatly appreciated!

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