A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: random motion with reflection

  1. #1
    Member
    Join Date
    Sep 2000
    Posts
    52
    Hi, I am trying to have an object float around in a random motion, with a reflection.

    I found the randome movement code somewhere, and tried making it work with the reflection. It works on the x, but not y ... it makes the reflection keep rising and rising untill it goes behind the object.

    Please tell me what im doing wrong, TIA

    onClipEvent (load) {
    width = 5
    height = 5
    accelFactor = Math.ceil(Math.random()*4) + 2;
    newX = Math.round(Math.random()*width);
    newY = Math.round(Math.random()*height);
    }

    onClipEvent (enterFrame) {
    currentlocx = this._x;
    currentlocy = this._y;
    differencex = newX-currentlocx;
    differencey = newY-currentlocy;
    accelx = differencex/accelFactor;
    accely = differencey/accelFactor;
    this._x = this._x+accelx;
    this._y = this._y+accely;
    _parent.reflect._x = _parent.reflect._x+accelx;
    _parent.reflect._y = _parent.reflect._y-accely;
    if (Math.round(this._y) == Math.round(newY) && Math.round(this._x) == Math.round(newX)) {
    newX = Math.round(Math.random()*width);
    newY = Math.round(Math.random()*height);
    accelFactor = Math.ceil(Math.random()*4) + 2;
    }
    }

  2. #2
    Member
    Join Date
    Sep 2000
    Posts
    52
    bump

  3. #3
    psx = new Moderator();
    Join Date
    Jan 2001
    Posts
    923
    Hey -
    this line:
    _parent.reflect._y-accely;

    should be
    _parent.reflect._y+accely;



    Psx

  4. #4
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    Actually, why don't you send me da file, I'll fixe it in 1 sec. but I need to see how the clips are placed..

    webmaster@key-one.it

  5. #5
    Member
    Join Date
    Sep 2000
    Posts
    52
    psycholonex .... if i change the - to a + .. then it will move in the same exact motion as the main object.. i need the reflection to have oposite motion in the y axis


    Keyone.i... thanks, ill email it

  6. #6
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    I actually hope I did what you wanted...I suddenly thought I haven't....just tell me if it's like that

  7. #7
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    ...so I get it I have to reflect the bottle on the floor right?

  8. #8
    Member
    Join Date
    Sep 2000
    Posts
    52
    yea

  9. #9
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    ..looks like it's working to me, what are you exactly asking me to do? (it actually moves fine, if you take it's _alpha off you can see it "reflecting" the bottle correctly..)

  10. #10
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    I GOT IT....ok, now I understand! hehehehehehe
    should have told me it takes a LONG time to go up...
    this is probably a rounding problem, I'll check this out.

  11. #11
    Member
    Join Date
    Sep 2000
    Posts
    52
    thought i mentioned the fact that it takes a while

  12. #12
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    Ok, I couldn't actually figure out what was wrong...but it was surely a problem related to the decimals of the x and y coordinates....

    Anyway I changed the reflection now...it refers to the shadow y position....just move it up or down and the reflection height will change accordingly..

    Hope this is ok now
    And the next time make it clear...just say "Hey! this is NOT what I wanted!".



    cheers.

  13. #13
    Member
    Join Date
    Sep 2000
    Posts
    52
    ok... did you send the file back?... i didn't receive anything yet


  14. #14
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    I'm sorry...I can be so stupid sometimes.....(by the way, my email is not working now....f______g italian providers...they are really bad.)

    http://pasodesign.com/extra/reflect.fla

    cheers!

  15. #15
    Member
    Join Date
    Sep 2000
    Posts
    52
    If you cant fix it... just go around it.... thanks!


  16. #16
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    Is it ok like this?
    Actually you should make the image of the bottle from beneeth..so that you get a photo-realistic reflection...that would be very, very cool
    I like the overall effect of the thing anyway

    Cheers

  17. #17
    Member
    Join Date
    Sep 2000
    Posts
    52
    yes, the way you did it is ok.

    I originally was planing to use the image for the reflection, but because the original picture is taken at an angle that it is, if I flip it, it doesn't look right. So im debating if I should try to play with the image in photoshop and use that 2nd image as a reflection, or I should leave it in vector for the filesize sake.

  18. #18
    Product Designer keyone.it's Avatar
    Join Date
    Aug 2001
    Location
    Rome, Italy.
    Posts
    1,625
    best thing is you get a second shot of the image....filesize is going to stay low anyway....those photos are really small

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