3 Step Animation - Rounded Rectangle
♥0 |
Line 33 |
Modified 2016-05-16 22:11:21 |
MIT License
archived:2017-03-20 02:37:10
ActionScript3 source code
/**
* Copyright WLAD ( http://wonderfl.net/user/WLAD )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/u69S
*/
package {import flash.display.Sprite;public class FlashTest extends Sprite {public function FlashTest() {
///////////////////////////////////////
x = 100;
y = 80;
var frame:int = 0;
var total_frames:int = stage.frameRate * 3;
var val:Number = 0;
var width:Number = 300;
var height:Number = 200;
var r:Number = 0;
addEventListener('enterFrame', function(_:*):void
{
if ( ++frame > total_frames ) frame = 0;
val = frame / total_frames;
graphics.clear();
graphics.beginFill(0xFF0000);
if ( val < 0.333 )
{
r = val / 0.333;
graphics.drawRoundRect( 0, 0, width, height, r * height );
}
else if ( val < 0.666 )
{
r = ( val - 0.333 ) / 0.333;
var diff:Number = width - height;
graphics.drawRoundRect( r * diff * 0.5 , 0, width - r * diff , height, height );
}
else
{
r = 0.5* (1-(val- 0.666) / 0.333);
graphics.drawCircle( width >> 1, height >> 1, r * height );
}
graphics.endFill();
///////////////////////////////////////
});}}}