Pure code AS3 spinning loading animation

While working on the video player, I wanted to show spinning loading animation while buffering, and since I decided that the whole thing will be pure code, with no library assets, I had to code this animation – just the kind of things I like.
It didn’t take long, and I decided to share it – why not?

So here it is:

loader animation with action script 3 code

What you need to do in order to use it is add two functions:


import LoadAnim;
...
private var myAnim :LoadAnim;
...

public function showAnim():void
{
myAnim = new LoadAnim(0x333333); // animation color
myAnim.x = stage.stageWidth / 2;
myAnim.y = stage.stageHeight / 2;
addChild(myAnim);
}

public function hideAnim():void
{
myAnim.stopAnim();
removeChildAt(1);
}

Download the class here, enjoy : )

    • Chris
    • January 7th, 2011

    Great, Thank you!

    • andrew
    • August 3rd, 2011

    thanks… exactly what I was looking for… changed the implementation functions so implementation is a little easier (for others that are copying and pasting)

    public function showAnim(_x=stage.stageWidth / 2,_y=stage.stageHeight / 2):void
    {
    myAnim = new LoadAnim(0×333333); // animation color
    myAnim.name=”myAnim”;
    myAnim.x = _x;
    myAnim.y = _y;
    addChild(myAnim);
    }

    public function hideAnim():void
    {
    myAnim.stopAnim();
    if(myAnim!=null && contains(myAnim))
    {
    removeChild(getChildByName(“myAnim”));
    }
    }

    • adi
    • August 3rd, 2011

    Cool, thanks Andy

    • Uyangaa
    • December 12th, 2011

    thanks a lot

  1. No trackbacks yet.

 

Bad Behavior has blocked 14 access attempts in the last 7 days.