Gel "play" button
// forked from makc3d's The bug
package {
import flash.display.Sprite;
[SWF(backgroundColor="#3F7F")]
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
var myButton:AS2Sprite = new AS2Sprite ("button");
myButton.x = 232; myButton.scaleX = 2;
myButton.y = 232; myButton.scaleY = 2;
addChild (myButton);
// http://ericlin2.tripod.com/swftoas/myButton.txt
var clip:AS2Sprite, matrix:Object, colors:Array, alphas:Array, ratios:Array;
with (myButton) {
clip = createEmptyMovieClip("d1", 1);
with (clip) {
matrix = {a:33.15, b:0, d:0, e:33.15, g:-0.6, h:-0.05};
colors = [6776679, 8816262];
alphas = [83.921568627451, 0];
ratios = [173, 234];
beginGradientFill("radial", colors, alphas, ratios, matrix);
lineTo(-0.55, -15.55);
curveTo(5.85, -15.55, 10.25, -12.35);
curveTo(14.6, -9.2, 16.05, 2.3);
curveTo(17.45, 13.75, -0.55, 15.55);
curveTo(-7.05, 15.55, -11.6, 11);
curveTo(-16.15, 6.4, -16.15, 0);
curveTo(-16.15, -6.5, -11.6, -10.95);
curveTo(-7.05, -15.55, -0.55, -15.55);
lineTo(0, 0);
endFill();
blendMode = "multiply"; // ;)
}
clip = createEmptyMovieClip("d2", 2);
with (clip) {
matrix = {a:37.55, b:0, d:0, e:37.55, g:-0.2, h:4.8};
colors = [14024663, 6418177, 1942528, 18944];
alphas = [100, 100, 100, 100];
ratios = [0, 88, 162, 239];
beginGradientFill("radial", colors, alphas, ratios, matrix);
lineTo(11.25, -2.15);
curveTo(11.25, 2.7, 7.8, 6.2);
curveTo(4.3, 9.65, -0.6, 9.65);
curveTo(-5.5, 9.65, -8.95, 6.2);
curveTo(-12.45, 2.7, -12.45, -2.15);
curveTo(-12.45, -7, -8.95, -10.5);
curveTo(-5.5, -14, -0.6, -13.95);
curveTo(4.3, -14, 7.8, -10.5);
curveTo(11.25, -7, 11.25, -2.15);
lineTo(0, 0);
endFill();
}
clip = createEmptyMovieClip("d3", 3);
with (clip) {
lineStyle(0.05, 0, 50.196078431373);
moveTo(11.25, -2.15);
curveTo(11.25, 2.7, 7.8, 6.2);
curveTo(4.3, 9.65, -0.6, 9.65);
curveTo(-5.5, 9.65, -8.95, 6.2);
curveTo(-12.45, 2.7, -12.45, -2.15);
curveTo(-12.45, -7, -8.95, -10.5);
curveTo(-5.5, -14, -0.6, -13.95);
curveTo(4.3, -14, 7.8, -10.5);
curveTo(11.25, -7, 11.25, -2.15);
}
clip = createEmptyMovieClip("d4", 4);
with (clip) {
matrix = {a:19.65, b:0, d:0, e:10.95, g:-0.55, h:-9.95};
colors = [16777215, 16777215, 2829099];
alphas = [96.078431372549, 0, 100];
ratios = [0, 255, 255];
beginGradientFill("radial", colors, alphas, ratios, matrix);
lineTo(8.85, -9.95);
curveTo(8.85, -7.85, 6.1, -6.3);
curveTo(3.3, -4.75, -0.55, -4.75);
curveTo(-4.45, -4.75, -7.2, -6.3);
curveTo(-10.05, -7.85, -10, -9.95);
curveTo(-10.05, -12.2, -7.2, -13.7);
curveTo(-4.45, -15.25, -0.55, -15.25);
curveTo(3.3, -15.25, 6.1, -13.7);
curveTo(8.85, -12.2, 8.85, -9.95);
lineTo(0, 0);
endFill();
y = 1.5; // ;)
}
clip = createEmptyMovieClip("d5", 5);
with (clip) {
beginFill(0, 50.196078431373);
lineTo(6.2, -1.85);
lineTo(-5.15, -8.15);
lineTo(-5.15, 4.25);
lineTo(6.2, -1.85);
lineTo(0, 0);
endFill();
}
}
}
}
}
import flash.display.Sprite;
import flash.geom.Matrix;
class AS2Sprite extends Sprite {
public function AS2Sprite (name:String) {
this.name = name;
}
public function createEmptyMovieClip (name:String, depth:uint):AS2Sprite {
return addChildAt (new AS2Sprite (name), depth - 1) as AS2Sprite;
}
public function beginGradientFill (type:String, colors:Array, alphas:Array, ratios:Array, m:Object):void {
for (var i:int = 0; i < alphas.length; i++) alphas [i] *= 0.01;
/* matrix is tricky
http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001281.html says:
a b c
d e f
g h i
ericlin uses a, b, d, e, g, h... hmmm
ok, ericlin's php file has this:
$a=$matrix2->scaleX*32768/20;
$b=$matrix2->rotateSkew0*32768/20;
$d=$matrix2->rotateSkew1*32768/20;
$e=$matrix2->scaleY*32768/20;
$g=$matrix2->translateX/20;
$h=$matrix2->translateY/20;
$log="var matrix={a:$a,b:$b,d:$d,e:$e,g:$g,h:$h};";
let's see as3swf now:
https://github.com/claus/as3swf/blob/master/src/com/codeazur/as3swf/data/SWFMatrix.as#L28
new Matrix(scaleX, rotateSkew0, rotateSkew1, scaleY, translateX, translateY);
*/
graphics.beginGradientFill (type, colors, alphas, ratios, new Matrix (
m.a * 20 / 32768,
m.b * 20 / 32768,
m.d * 20 / 32768,
m.e * 20 / 32768,
m.g, // why no * 20 here ?
m.h // why no * 20 here ?
));
}
public function beginFill (color:uint, a:Number):void {
graphics.beginFill (color, a * 0.01);
}
public function endFill ():void {
graphics.endFill ();
}
public function moveTo (x:Number, y:Number):void {
graphics.moveTo (x, y);
}
public function lineTo (x:Number, y:Number):void {
graphics.lineTo (x, y);
}
public function curveTo (x:Number, y:Number, ax:Number, ay:Number):void {
graphics.curveTo (x, y, ax, ay);
}
public function lineStyle (t:Number, color:uint, a:Number):void {
graphics.lineStyle (t, color, a * 0.01);
}
}