Demo:
click on the dogs head.
First Of All:
Open swishmax 4 and set your movies width and height.
Step.1
you will need a body_mc and a head_mc two seperate movieclips.
simply name the head movieclip head and add the following code to Scene_1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | onFrame (1) { bobbing_range = 30; nodding_range = 20; bobbing_hit = .5; nodding_hit = .1; bobbing_damp = .99; nodding_damp = .985; bobbing_angle = 0; nodding_angle = 0; bobbing_force = 0; nodding_force = 0; head_origin = head._y; head.onEnterFrame = function(){ if (bobbing_force){ this._y = head_origin + Math.sin(bobbing_angle)*bobbing_force*bobbing_range/2; bobbing_angle += bobbing_hit*bobbing_force; bobbing_force *= bobbing_damp; } if (nodding_force){ this._rotation = Math.sin(nodding_angle)*nodding_force*nodding_range/2; nodding_angle += nodding_hit*nodding_force; nodding_force *= nodding_damp; } } head.onPress = function(){ bobbing_angle = nodding_angle = 0; bobbing_force = nodding_force = 1; } } |
thats it, press ctrl+t to test your movie.
|
|
download: Nodding_dog (413.32KB) added: 29/01/2011 clicks: 28 description: nodding dog script, swishmax 4 |
Social Connect
Login with one of the following.Enter your WordPress.com blog URL
http://.wordpress.com
Proceed