ActionScript 3.0 :: Converting RGB Values Of Color To Uint
Apr 2, 2009I have 3 Numbers representing the RGB values of a color that I'd like to convert into a uint. I'm trying this:
var color:uint = r<<16 + g<<8 + b;
but it will always return 0.
I have 3 Numbers representing the RGB values of a color that I'd like to convert into a uint. I'm trying this:
var color:uint = r<<16 + g<<8 + b;
but it will always return 0.
I'm working with several components that take color as a uint, but the colors I have are in the format of "#161616". I'm not sure what the relation between the 2 types of colors are or how to go from one to another.It doesn't have to be an actionscript solution. I have only a small number of these colors, so can be done manually too.
View 4 RepliesI have a uint that i'd like to create a Color object out of so I can manipulate the tint as desired.
Code:
public static const red_dark:uint = 0xe80505;
How can I create a Color object out of the above uint?
[URL]
How to get RGB color values out of the color picker component?
trace (cp.selectedColor);
returns something like:
16750950[code]....
I am looking for RGB, for example, 0.5 0.5 0.5, for a gray color.Is there a chance the RGB parameters are hidden somewhere or is there a conversion function at least?
how to get the HSV values from a uint-hex-value?
View 6 Repliesfor instance distance values,and temperatures For instance say I have a string containing some unknown inches value And the inches sign can either be the proper double prime OR double quotes. So, I'm guessing as a first step I would search for double prime or double quotes preceded by a number value, then parse out and convert this number value. But this doesn't seem foolproof for instances when it is actually a doublequote, NOT an inches sign
View 1 RepliesI'm trying to simulate the coriolis effect and have managed to create a drawing application that lets the user draw on a rotating movie clip. However, I would like to now create an animation that automatically draws a line onto the movie clip which ends up being curved, but I can't figure out how to convert the x, y coordinates of the pixels on the stage to the corresponding x, y values of the movie clip. Here's what I have so far:
[Code]...
Up until CS4 the Colour effects dialog box was incredibly powerful. These 8 little fields were never the most intuitive, and it took a lot of fiddling before I realised their true power: the first column basically controls the contrast of an asset - and the 2nd column controls the brightness.Using these experimentally, you can acheive inverted colours, high contrast effects and colourising effect far superior to tints(see image).Well, you USED to be able to - when you could put high numbers in those fields.But the CS4 version of these controls caps any entered values to 100% and 255 respectively.It seems that it is only an effect of the interface - as I can cut and paste clips with the old settings from CS3 into CS4 and they display correctly.Is this an oversight on Adobe's part, or is there another explanation for the loss of a great design feature?
View 5 RepliesWe have an hsb- color wheel (.png) and we have create a circle which is rotating on the color-wheel. It should grab the color on the wheel, but there is the problem --> It doesn't. We try to make it with the getPixel function and flash traces some numbers, but the wrong ones. In addition there is a rectangle which gets the (wrong) values and shows them as a color.
function mouseDownHHandler(e:MouseEvent):void {
sButtonH.startDrag(false, rechteckH);
/ROTATION
stage.addEventListener(Event.ENTER_FRAME,rotate);
function rotate (e:Event){[code]....
I'm trying to make an array with different color values. My problem is that when I do...
teamColor[i] = currentColor...
All color values in my array turn into the currentColor. (I would upload more code, but that would be a massive mess, considering that I have code everywhere with references from movie clips that are as far as 3 layers deep. However, this would be irrelevant anyways (probably), because I tested this with color values on my main timeline, without any references to or from anything deeply nested). I would like to add that I tried adding strings in there and that the strings remained their original, intended, value, while the color exhibited the same phenomenon.
I changed my code by creating separate variables for each color instead of putting the variables into an array (not what I really wanted to do, but it works). My code looks like this:
if (teamColor != 0) {
this["team"+teamColor+"Color"] = new ColorTransform(0,0,0,1,currentColor.redOffset,currentColor.greenOffset,currentColor.blueOffset,)
teamColor = 0
namebox.addboxes()//function in a movieclip
}
TeamColor is now an int that is changed based on which box a user clicks from a movie clip that has a dynamically generated name, based off of what the variable value in a loop was when it was created.
(E.G: 'tempboxname[ttns].name = i;')
teamColor is then equal to that name when the user clicks it. I have another movieclip with colors in it and the above function is called to check if any teamColor change has occurred, and if it has, act accordingly. (The idea of having teamColor equal to 0 is so that if the user clicks twice, nothing changes. I other conditionals for other colors, all within the same function). That is how I fixed me code. It's not what I wanted, because it's not an array (meaning a seemingly infinite number of teamColors, and thus, teams) but it'll do for me.
I am having a color array with values like 0x2EFE2E, 0xFFFF00, etc. but when i am trying to trace the values in the array, it prints something else like 95455. I think these are some converted values. But i tried using parseInt(val, 16), uint(val). None of these works. Basically, i just want to take values from this array and assign it to particleColor (a uint) and use like this:
[Code]....
I have an MC with the instance name "building". I want to be able to change the RGB color values of this MC with three buttons for example. for example, one button would change the RGB values to 60 89 159 another button would change the RGB values to 50 251 59 another button would change the RGB values to 22 21 59 And, when the button is clicked, the new RGB color value should fade in without the old values fading out.
View 3 RepliesI'm facing a strange little problem trying to transfer values from an XML file to my main Flahs document class.[code]
View 5 RepliesLet's start with the following XML:
Code:
<swatches>
<swatch>
<swatchName>Plaid</swatchName>
<swatchColors>
<color>black</color>
[Code] .....
I want to return a list of the <color> values without having any duplicates.
I am doing a simple combobox example. Now my requirement was, i want to differentiate the combobox values with some colors. I dont know how to do this. can you guys pls help me out on this. Suppose for ex: if my combobox data value exceeds 200 i want to display the items in "red" else i want to display in "green".
<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate the Halo ComboBox control. -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
[code]....
I have the following XML
[Code]...
I am able to get <styling> as a XML but I cannot figure out how to parse the style object in order get the color, fontFamily fontSize attribute values. I am also unable to access the lang attribute value <tt xml:lang="en">
[Code]...
difference between int, uint and num... when would it be better to use one and not the other type thing?
View 8 Repliesi want my uint to be 0,1, or null.
it appears i cannot assign NaN to a uint, but i can with a number. why is that?
Code:
var num:Number;
trace (num) //NaN
var u:uint;
trace (u); //0
I want an undefined place holder for the uint. In my case i suppose I'll use the number 2 and try to remember it means NaN to me.
Does anyone know how to cast a string into a uint?[code]...
But i keep getting an error stating that there is a mismatch in variable types or i get a value of '65280' when I trace myUint.I understand that uint is a positive integer but i need to accept a string for the colour value and need to convert it to a string for use.
I've imported a color value via XML. Now I would like to convert that String to a uint
PHP Code:
var color1:String = "0x00FF00";
var color2:uint = uint(color1);
trace(color2); // outputs 65280
How do i convert this string into a uint
I am trying to encode certain values that I receive from keyboard event. Basically I want to check if a certain key combination has been pressed or not, so for that I am converting the key codes into sequence/pattern and store it in an object and a value(function) against each code sequence. Now I have to use four bytes and in first byte(MSB) I've to store shift, alt, ctrl respectively and in the last(LSB) I have to store the keycode of the key pressed.
Here is the code:
private function m_encodeValue(key:String, Ctrl:Boolean = true, Alt:Boolean = true, Shift:Boolean = false):uint {
var encodedValue:uint;
encodedValue = uint(Shift) << 2 | uint(Alt) << 1 | uint(Ctrl);
encodedValue = encodedValue | (uint(key.toUpperCase().charCodeAt(0)) << 24);
return encodedValue;
}
How to get r, g, b from uint pixel? I mean separate variables
View 2 RepliesI am new to the concept of Bitwise operations, and was messing around with some examples today. Everything seemed clear up until the point I tried to make a function to perform a circular bitshift on a uint:
private function rotateLeft(value : uint, shift : int) : uint {
if ((shift &= 31) == 0)
return value;
return (value << shift) | (value >> (32 - shift));
}
I was trying to shift a colour value (e.g. 0xFF0000) and expecting something along the lines of 0x0000FF, when in actual fact I was getting 0xFF000000 (which is correct, due to the length of a uint) - the most significant bytes are for the alpha value.
Is there an easy way to multiply a color that is stored in an uint? Basically what I would like to do would be applying a colorTransform-Object (like ColorTransform(1.2,1.2,1.2,1,0,0,0,0))to the uint and get the new value in return, but it will not work. Will I have to convert it into RGB first or am I missing something here?
View 2 Repliesam doing a simple combobox example. Now my requirement was, i want to differentiate the combobox values with some colors based on a condition. Suppose for ex: if my combobox data value exceeds 200 i want to display the items in "red" else i want to display in "green". i need solutions for this requirment.
<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate the Halo ComboBox control. -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
[code]....
Array of color id-s represents a 3D Array of values. I've represented each value with a color(Blue is 1, Red is 2 and Green is 3). So for the example the array for the image would be[code]...
Now, I have an array of predefined shapes/objects. I'd like to replace the grouped colors with the shapes that I have. I'd like this to follow the rule of finding the largest shape first and then down to the smallest one. [code]...
i have a button, with instance name lightblue_color. I am assigning a color to its color field like this: lightblue_color.transform.colorTransform.color = 0x65ffff; then i am adding an eventlistener to the button like this: lightblue_color.addEventListener(MouseEvent.CLICK, ChangeColor); Then, in the function: public function ChangeColor(evnt:MouseEvent):void {trace(evnt.target.transform.colorTransform.color);} It prints 0. Why is that? Shouldn't it print 0x65ffff or do i need to do some type conversions?
View 2 RepliesI'd like to implement the following logic:
function setMyValue (myVar:int = undefined):void
{
if (myVar == undefined)
{
[code]....
So if the value is supplied, use it. If not, generate it. Seems simple enough.Problem is that AS3 doesn't like this. 'undefined' gets coerced into '0', so myVar is never undefined. I've tried variations with NaN, null, etc, but nothing has worked.
Flex complains if I want to create an object from a library symbol with linkage: 1180: Call to a possibly undefined method [linkage name]. So to avoid this, I create a class for that symbol, in this case extending BitmapData using Flex's new ActionScript Class feature. Flex create that class for me and the constructor looks like this: public function CustomBitmapData(width:int, height:int, transparent:Boolean=true, fillColor:uint=null)
[Code]...
var n:Number = 1;
trace("n is Number:" + (n is Number)); //true
trace("n is int:" + (n is int)); //true
trace("n is uint:" + (n is uint)); //true
[Code]...
They all true! in actionscript, how to tell whether the type of a number if Number or int or uint?