Jump to content
Search Community

HeartBeat animation

BabaBlackSheep test
Moderator Tag

Recommended Posts

I need help in creating heartbeat animation with sound.

I have attached fla with al resources images,sounds etc.

I need heart beat to be controlled via variables/functions.So i can make it beat faster or slower.

 

Ref:

Reference animation can be seen at Here.

Heart 5 of 9 to be precise.

 

*Beat frequency (X&Y)
*Beat amplitude (X&Y)
*Beat-sound sync factor (X&Y)

 

heartbeat.zip

Link to comment
Share on other sites

I would recommend just experimenting for awhile with scaleX and scaleY tweens with ease:Elastic.easeOut.

var speed = 0.2; //seconds

TweenMax.to(heart, 1, {scaleX:1.2, scaleY:1.3, ease:Elastic.easeOut, repeat:-1, repeatDelay:speed)

I'd also recommend shelling out the 5 bucks to see exactly how he did it. 

Link to comment
Share on other sites

How can i update var speed later after i initialize tweenmax ?

 

In code below i would like beatFaster function to update var speed_repeat and var speed_heart of tweenmax

package
{

    import flash.display.MovieClip;
    import com.greensock.*;
    import com.greensock.easing.*;

    public class heart extends MovieClip
    {
        private var speed_repeat:Number;
        private var speed_heart:Number;
        private var tween:TweenMax;
        public function heart()
        {
            // constructor code

            speed_repeat = 0.4;
            speed_heart = 1;
            setPosition(100,100);
            tween = new TweenMax(this,speed_heart,{scaleX:1.2,scaleY:1.3,ease:Elastic.easeOut,repeat:-1,repeatDelay:speed_repeat});
        }
        public function setPosition(X:Number,Y:Number):void
        {
            this.x = X;
            this.y = Y;
        }
        public function beatFaster():void
        {
            speed_repeat = speed_repeat -.1;
            tween.updateTo({repeatDelay:speed_repeat}, true);
        }
    }

}
Link to comment
Share on other sites

Also How can I use random value for scaleX and scaleY with repeatDelay:?

scaleX:function() doesn't work so i could return random value.

 tween = new TweenMax(this,speed_heart,{scaleX:function(){return 1.2 },scaleY:function(){return 1.3 },ease:Elastic.easeOut,repeat:-1,repeatDelay:speed_repeat});
Link to comment
Share on other sites

If you're still working on the random scale, you might try something like this?:

tween = new TweenMax(this,speed_heart,{scaleX:randomScale('x'),scaleY:randomScale('y'),ease:Elastic.easeOut,repeat:-1,repeatDelay:speed_repeat});

function randomScale(type){
  if (type === 'x') {
    return 1.2 // return a randomised X value
  } else {
    return 1.3 // return a randomised Y value
  }
}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...