skip to main
|
skip to sidebar
lineScript
Cross the line..
Tuesday, March 9, 2010
Learn Actionscirpt Techniques - ColorPicker Gradient
The ColorPicker component displays a list of one or more swatches from which the user can select a color.
By default, the component displays a single swatch of color on a square button. When the user clicks this button, a panel opens to display the complete list of swatches.
// Here is the Source Code
var startHex;
var endHex;
var spacing:int = 25;
var noOfBoxes:int = 13;
function fadeHex(ratio) {
var r = startHex >> 16;
var g = startHex >> 8 & 0xFF;
var b = startHex & 0xFF;
r += ((endHex >> 16 & 0xFF)-r)*ratio;
g += ((endHex >> 8 & 0xFF)-g)*ratio;
b += ((endHex & 0xFF)-b)*ratio;
return (r << 16 | g << 8 | b);
}
function drawSquare(x, y, color) {
graphics.beginFill(color);
graphics.moveTo(x,y);
graphics.lineTo(x+50,y);
graphics.lineTo(x+50,y+50);
graphics.lineTo(x,y+50);
graphics.lineTo(x,y);
}
function colorChange(e:Event) {
var cp:ColorPicker = e.target as ColorPicker;
if (cp==cp1) {
startHex = "0x"+e.target.hexValue ;
} else {
endHex = "0x"+e.target.hexValue;
}
for (var i = 0; i
var ratio = i/noOfBoxes;
var xx = spacing+(i*50);
var yy = 70;
var nowColor = fadeHex(ratio);
drawSquare(xx,yy,nowColor);
}
}
cp1.selectedColor = 0x990000;
cp2.selectedColor = 0x000000;
cp1.addEventListener(Event.CHANGE, colorChange);
cp2.addEventListener(Event.CHANGE, colorChange);
cp1.addEventListener(Event.RENDER, colorChange);
cp2.addEventListener(Event.RENDER, colorChange);
No comments:
Post a Comment
Newer Post
Older Post
Home
Thirukkural
Your browser does not have javascript enabled. To get the code for displaying thirukural in your webpage, go &amp;amp;amp;lt;a href='http://e-infotainment.com/applications/kural'&amp;amp;amp;gt;here&amp;amp;amp;lt;/a&amp;amp;amp;gt;
Categories
AS2.0
(3)
AS3.0
(3)
ActionScript 2.0
(3)
ActionScript 3.0
(5)
ActionScript Techniques
(3)
Bank Passbook
(1)
Bitwise Gems
(1)
Bitwise Operations in C
(1)
Bitwise Operators
(2)
Driving Licence
(1)
Dynamic Change Text Color in Flash
(1)
Math.round()
(1)
Missing
(1)
Nearest Decimal Place
(1)
Passport
(1)
Ration Card
(1)
Round Decimal Places
(1)
அமார்த்திய சென்
(1)
தொடக்கப் பள்ளி
(1)
Blog Archive
▼
2010
(10)
►
June
(1)
►
May
(1)
►
April
(1)
▼
March
(2)
Learn Actionscirpt Techniques - ColorPicker Gradient
AS3 Naming Conventions
►
February
(2)
►
January
(3)
►
2009
(1)
►
December
(1)
my Followers
No comments:
Post a Comment