View Full Version : Bobblehead animation
tacall
09-30-2002, 11:46 PM
I don't even know if this is possible, but...
I am wanting to take a head of a person, larger than the body, and place it on a different body. Then on 'mouseover' make the head bounce like a bobblehead doll. Random bouncing would be best. Then stop on 'mouseout'.
I have looked extensively and not found anything like this. The closest thing I found was a .gif animation that only went up and down.
I would likt to do it in flash because i think it would work much better, smoother, and would add the interactivity.
If anyone has seen a tutorial on this, please point me in the right direction. And if not, can anyone figure it out? I am not a programmer and am just learning about Flash.
Thanks in advance,
Todd
pixelwit
10-01-2002, 07:45 AM
ActionScript.org has almost everything.
Did you try searching for "bobblehead"?
-PiXELWiT
http://www.pixelwit.com
tacall
10-01-2002, 04:41 PM
... and didn't find anything.
I searched under bobblehead and bouncing, and no matches were found. I also looked through the tuts and found nothing, that i know of, that would be similar.
pixelwit
10-01-2002, 04:51 PM
Hmmmmm... well that's mighty peculiar because when I search for "bobblehead" I get these results: http://www.actionscript.org/forums/search.php3?action=showresults&searchid=151084&sortby=lastpost&sortorder=descending
That should help you some.
-PiXELWiT
http://www.pixelwit.com
20 Ton Squirrel
10-01-2002, 06:13 PM
I suspect KONSPIRACY is afoot!
That was, indeed, a neat bit of code PW.
tacall
10-01-2002, 07:00 PM
It appears I searched the wrong area.
Now how would I use this "bit o' code," and a very neat bit o' code it is, to produce a bobblehead on a static person?
I realize I am a bit over my head on this project, however I am learning as I go, using the tuts to expand my knowledge.
Todd
pixelwit
10-01-2002, 07:55 PM
Thanks Squirrel, glad you liked it. :)
To use the code:
Draw a circle.
Convert it to a MovieClip.
Right click it.
Select "Actions".
Paste code in Actions panel.
Test movie.
Click the circle.
Your on your own from there.
Hope it helps,
-PiXELWiT
http://www.pixelwit.com
jevans
11-16-2006, 07:54 PM
Hi PixelWit,
If you happen to read this, could you tell me if an instance name is required on my MC for this Bobblehead code to work?.
Or perhaps my problem has something to do with Flash 8?.
I'll be damned if I can get this to work.
Thanks for your time, Jason.
pixelwit
11-17-2006, 11:01 AM
To get the old code to work in Flash8, I had to set the Flash Publish settings to the version 5 player.
Here is a more modern version of the same effect which works in Flash8 without any hassle:
//
//
function makeBobble (clip, xDist, yDist, xSpeed, ySpeed, decay){
clip.xDist = xDist; // How far the clip moves left and right. (Pixels)
clip.yDist = yDist; // How far the clip moves up and down. (Pixels)
clip.xSpeed = xSpeed;// How fast the clip moves left and right. (0 to Math.PI)
clip.ySpeed = ySpeed;// How fast the clip moves up and down. (0 to Math.PI)
clip.decay = decay; // How quickly the clip slows down. (.01 to .99)
if(clip.startX == undefined){
clip.startX = clip._x;
clip.startY = clip._y;
clip.xRad = 0;
clip.yRad = 0;
}
clip.onEnterFrame = bobble;
}
//
function bobble(){
with(this){
xDist*=decay;
yDist*=decay;
xRad += xSpeed;
yRad += ySpeed;
_x = startX + Math.sin (xRad)*xDist;
_y = startY + Math.sin (yRad)*yDist;
if(Math.abs(xDist)<.2 && Math.abs(yDist)<.2){
onEnterFrame = null;
}
}
}
//
function makeRandomBobble(){
var xD = Math.random() * 90 + 10;
var yD = Math.random() * 90 + 10;
var xS = Math.random() * Math.PI/4;
var yS = Math.random() * Math.PI/4;
var dK = Math.random() * .1 + .9;
makeBobble(this, xD, yD, xS, yS, dK);
}
//
createEmptyMovieClip("MyClip", 10);
with(MyClip){
_x = 275;
_y = 200;
lineStyle(100, 0xFFDD00);
lineTo(.5, 0);
lineStyle(24);
moveTo(-18, -15);
lineTo(-18.5, -15);
moveTo(18, -15);
lineTo(18.5, -15);
lineStyle(5);
moveTo(-30, 10);
curveTo(0, 45, 30, 10);
}
MyClip.onPress = makeRandomBobble;
//
//
-PiXELWiT
http://www.pixelwit.com[/as]
jevans
02-01-2007, 07:29 PM
Thanks PixelWit,
You are a magician. Thanks very much for that, if you don't mind I have one more question for you.
What if a person wanted the head to bobble just one time after the head slid onto the stage and with no click of a button.
Thanks again for your time.
Regards, Jason.
jevans
02-01-2007, 10:29 PM
For anyone interested this will do it:
//
//
function makeBobble (clip, xDist, yDist, xSpeed, ySpeed, decay){
clip.xDist = xDist; // How far the clip moves left and right. (Pixels)
clip.yDist = yDist; // How far the clip moves up and down. (Pixels)
clip.xSpeed = xSpeed;// How fast the clip moves left and right. (0 to Math.PI)
clip.ySpeed = ySpeed;// How fast the clip moves up and down. (0 to Math.PI)
clip.decay = decay; // How quickly the clip slows down. (.01 to .99)
if(clip.startX == undefined){
clip.startX = clip._x;
clip.startY = clip._y;
clip.xRad = 0;
clip.yRad = 0;
}
clip.onEnterFrame = bobble;
}
//
function bobble(){
with(this){
xDist*=decay;
yDist*=decay;
xRad += xSpeed;
yRad += ySpeed;
_x = startX + Math.sin (xRad)*xDist;
_y = startY + Math.sin (yRad)*yDist;
if(Math.abs(xDist)<1 && Math.abs(yDist)<1){
onEnterFrame = null;
}
}
}
//
function makeRandomBobble(){
var xD = Math.random() * 20 + 10;
var yD = Math.random() * 20 + 10;
var xS = Math.random() * Math.PI/2;
var yS = Math.random() * Math.PI/2;
var dK = Math.random() * .1 + .9;
makeBobble(this, xD, yD, xS, yS, dK);
}
//
MyClip2.onEnterFrame = makeRandomBobble;
;
//
//
PixelWit..thanks again for your help around here.
Regards, Jason.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.