Search:
Calendar:
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Subscribe:
Enter your email address to subscribe to this blog.
Archives By Subject:
Action Script (2) [RSS]
Adobe (33) [RSS]
AIR (7) [RSS]
Ajax (3) [RSS]
Buzzword (1) [RSS]
CFUG (42) [RSS]
ColdFusion (70) [RSS]
Flash (6) [RSS]
Flex (40) [RSS]
Frameworks (3) [RSS]
Free Software (2) [RSS]
FXUG (22) [RSS]
General (35) [RSS]
JpgMetadataReader (3) [RSS]
jQuery (1) [RSS]
Mac (2) [RSS]
Off Topic (13) [RSS]
OpenSource (14) [RSS]
PaperVision (10) [RSS]
Spry (2) [RSS]
Transfer (1) [RSS]
Adobe (33) [RSS]
AIR (7) [RSS]
Ajax (3) [RSS]
Buzzword (1) [RSS]
CFUG (42) [RSS]
ColdFusion (70) [RSS]
Flash (6) [RSS]
Flex (40) [RSS]
Frameworks (3) [RSS]
Free Software (2) [RSS]
FXUG (22) [RSS]
General (35) [RSS]
JpgMetadataReader (3) [RSS]
jQuery (1) [RSS]
Mac (2) [RSS]
Off Topic (13) [RSS]
OpenSource (14) [RSS]
PaperVision (10) [RSS]
Spry (2) [RSS]
Transfer (1) [RSS]
Tags:
action script
adobe
air
ajax
cfug
coldfusion
flash
flex
frameworks
free software
fxug
general
jpgmetadatareader
mac
off topic
opensource
papervision
spry
Recent Entries:
Top Posts:
- [19131] Paper Vision 3D Sphere - Carousels on Steroids!
- [11223] Simple Dynamic Cursor Example in Flex2: With source code
- [10710] Simple PaperVision3D Blurring example : source code
- [10699] Simple PaperVision3D Blurring example
- [10535] PaperVision3D/Flex2 Carousel v0.2
- [10320] Carousel v0.2 - source code
- [10320] Saving images from Flex using ColdFusion: Simple Example with source code
- [9850] PaperVision Carousel0.3 - one step closer to the master plan!
- [8471] PaperVision3D is good for cubes! - a "geek" gift
- [7862] Simple Effects on a Form - Flex Example
Recent Comments:
- PaperVision3D/Flex2 Carousel v0.2
Arindam said: http://www.citroen.co.uk/... see the above links how can I create this kind of slider? If ... [More] - Paper Vision 3D Sphere - Carousels on Steroids!
Reflexion Graphic said: Nice job ! [More] - Getting Red from my color
David said: @Promethe: Thanks for the comment. Jason uses that way too in his example. working with number as n... [More] - Getting Red from my color
Promethe said: guys... seriously: var myColor : uint = 0xef556ef; var myRed : uint = (myColor >> 16) & ... [More] - Getting Red from my color
David said: @Jason: Thanks for the example! I never like working with numbers-to-strings-to-numbers. I'll pull y... [More]
Top Commenters:
- [8] Campbell
- [8] Ben Nadel
- [6] Mark Flewellen
- [6] Steve Bryant
- [4] Raymond Camden
- [4] barry.b
- [3] John Whish
- [3] Peter Bell
- [2] Cory
- [2] carlos
My Links:
RSS:
Getting Red from my color
I have a situation where I want to manipulate colors in flash.
The idea is that the colors will cross fade nicely from one shade to another.
While you can define colors like this: 0xef556ef
that is stored as a unit data type.
Looking at the above string, it's 8 char in length.
The first two "0x" tell flash to treat this string as a hexadecimal value.
the next two "ef" are the red value, the next two "55" are green and the last 2 "ef" are blue.
Given the above value, I wanted to get the red shade of it, and only the red shade.
This is what I came up with:
var myColor : uint = 0xef556ef
//convert the color to a string on a hex base and get the first 2 chars with "0x" at the front
var redValueString :String = "0x" + myColor.toString( 16 ).substr(0,2);
trace( redValueString );
//convert the sting to the int value
var redValueInt : int = int( redValueString );
trace( redValueInt.toString() );
//convert the color to a string on a hex base and get the first 2 chars with "0x" at the front
var redValueString :String = "0x" + myColor.toString( 16 ).substr(0,2);
trace( redValueString );
//convert the sting to the int value
var redValueInt : int = int( redValueString );
trace( redValueInt.toString() );
This does give me the result, which is good, but I'm no flash pro, so is there a better (right?) way to do it?
Feel free to tell me if there is!

http://blog.shortfusion.com/index.cfm/2009/12/17/S...
I never like working with numbers-to-strings-to-numbers.
I'll pull your example apart and use it ;-)
var myColor : uint = 0xef556ef;
var myRed : uint = (myColor >> 16) & 0xff;
Jason uses that way too in his example.
working with number as number is always better. I just didn't know how to do it, hence this post ;-)