PDA

View Full Version : spinning around


sneezy
02-28-2002, 10:58 AM
I've created a logo for my company and from this I wont to create a screen saver that moves my logo around the screen bouncing it off the sides. I have the software for the screensaver I just need a few clues with the animation part.

I've included the logo file.

Many thanks in advance!

jimburton
02-28-2002, 11:23 AM
Make the logo smaller and stick this code on top of it:


onClipEvent (load) {
dx = Math.random()*20-5;
// set the initial momentum of the ball
dy = Math.random()*20-5;
}
onClipEvent (enterFrame) {
_x += dx;
// Move the ball along dx and dy
_y += dy;
if (_x<0) {
_x = 0;
// move it back on screen
dx *= -1;
// reverse the horizontal momentum
} else if (_x>225) {
_x = 225;
// move it back on screen
dx *= -1;
// reverse the horizontal momentum
}
if (_y<0) {
_y = 0;
// move it back on screen
dy *= -1;
// reverse the vertical momentum
} else if (_y>200) {
_y = 200;
// move it back on screen
dy *= -1;
// reverse the vertical momentum
}
}


This will be different speed and direction every time it's loaded - alter the onload handler to set a fixed speed/direction...

sneezy
02-28-2002, 01:15 PM
" Make the logo smaller and stick this code on top of it: "

sorry the stick this code on top of it, I'm not sure what u mean.

At first I thought u meant in the first frame on the scene where my movie clip is ( mehdiward logo ) but for some reason it doesn't like onclipevent.

Inside the movie clip i havn't a clue.

Could I have a hint!

farafiro
02-28-2002, 01:29 PM
Just put that code on the MC instance

sfa
02-28-2002, 01:31 PM
when on the main timeline, select the logo(dont double click to go inside it) and paste it in the actionscript window. Basically it has to be on the ouside of the logo not on the inside.

SFA

jimburton
02-28-2002, 01:31 PM
click once on the movieclip so that it's got a blue rectangle around it but you're still in the main timeline.

Open the Actions panel - the second tab should read "Object Actions". Click on that panel and paste the code in (this is easier if you set it to Expert Mode). That's what I meant by "on top" - I admit it could have been clearer!

jimburton
02-28-2002, 01:33 PM
Enough responses for you?

:)

sneezy
02-28-2002, 02:19 PM
Learnt a new thing today expert mode! That was main problem with applying your lovely script!

Thank U have a nice day!