A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Frustration!

  1. #1
    Junior Member
    Join Date
    Mar 2001
    Posts
    16
    I have a problem, my car won't start. Also, I need to know how to make this function:



    function changeScale () {

    // Set the target
    target = link1.target;

    // Store the physics variables
    physics = [0.25, 0.9];

    // calculate speed using physics
    xSpeed = ((target-link1._xscale)*physics[0])+(xSpeed*physics[1]);
    ySpeed = ((target-link1._yscale)*physics[0])+(ySpeed*physics[1]);

    // move the ball
    link1._xscale+=xSpeed;
    link1._yscale+=ySpeed;
    }

    Which changes the scale of a movie clip, making it look bouncy, work for multiple movie clips, not just "Link1".
    The .swf will be on my website soon, under links.
    Pleeeeeease help 'cause I'm dumb. Thank you.

    - Some kid
    [Edited by NeoNova85 on 07-16-2001 at 12:47 PM]

  2. #2
    Senior Member
    Join Date
    Sep 2000
    Posts
    467
    just add a loop action like this:


    function changeScale () {

    for (p=1,p<=10,p++) {

    // Set the target
    target = link[p].target;

    // Store the physics variables
    physics = [0.25, 0.9];

    // calculate speed using physics
    xSpeed = ((target-link[p]._xscale)*physics[0])+(xSpeed*physics[1]);
    ySpeed = ((target-link[p]._yscale)*physics[0])+(ySpeed*physics[1]);

    // move the ball
    link[p]._xscale+=xSpeed;
    link[p]._yscale+=ySpeed;

    }
    }


    this will do the function for all targets named link1, link2, link3 untill link10


    ^1letser
    [Edited by ^1letser on 07-16-2001 at 01:08 PM]

  3. #3
    Junior Member
    Join Date
    Mar 2001
    Posts
    16
    Ah, that helps me a great deal even though that's not exactly what I want to do. I wanted to be able to call the function from each movie clip and have it perform that function, not on each of them in a sequence, since it needs to be done each frame. Now I know that I can use link[x] to specify which link I want the function to work on. Thanks.

    - Some kid


  4. #4
    Senior Member
    Join Date
    Sep 2000
    Posts
    467
    ah oké, you can do that like this (I think)

    place this function on a movieclip (say _root.control)



    function changeScale (name) {

    // Set the target
    target = name.target;

    // Store the physics variables
    physics = [0.25, 0.9];

    // calculate speed using physics
    xSpeed = ((target-name._xscale)*physics[0])+(xSpeed*physics[1]);
    ySpeed = ((target-name._yscale)*physics[0])+(ySpeed*physics[1]);

    // move the ball
    name._xscale+=xSpeed;
    name._yscale+=ySpeed;
    }



    now on every movieclip you want to call the function from:

    name = "_root.path-to-this-movie-clip";
    _root.control.changeScale(name);



    ^1letser

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