ActionScript 3.0 :: Difference Between Int, Uint And Num?
Nov 3, 2009difference between int, uint and num... when would it be better to use one and not the other type thing?
View 8 Repliesdifference 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 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 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;
}
I 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 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 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?
when I try to type cast something, there r 2 ways to do it:if var integer holds a integer (Uint)
text_txt.text = integer as String;or text_txt.text = String( integer );
but sometimes when I want to pass a value to a function both ways don't work and only one way works, when should I use option 1 and 2???
what are the differences between '.this' and '.stage'?
View 4 RepliesWhat are the main differences between the versions?
View 3 Repliesi am intermediate programmer.but i think that has ended 2 days before when i came across a simple while loop.which i can't figure it out how the stuff works..[code]from 1 - 9 ,that is (1,2,3,4,5,6,7,9);I want to know difference between pre and post additions in the loops.if the first program adds the increment value after each loop , then why didn't it prints the (0) value. and i also want to know that ,Why this methods does not have any difference on for loops....
View 9 RepliesWhat's the difference between if, while and do..while besides the way they are presented?
[Code]...
Both are working, can be used, but I'd like to ask what's the difference between '}' and '};'. Let me know if I asked something very stupid.
View 4 RepliesBut what is the difference between [] and (). I used () in the random letters tutorial and it didn't work. When i used [] it worked.
View 2 Replieswhat's the difference between for example:
var H:int;
var _H:int;
I am trying to load random external SWF's using XML. I'm not having any problems loading JPG files, but the SWF's just won't load. Is there a difference between JPG's and SWF's when loading using loadMovie? Pointers to tutorials or pages in the manual would be great.
Here's a snippet of the code:
[AS]
function firstImage() {
if (p<(total-1)) {
p=random(total);
[Code]....
I was looking for the difference between the different content types in Flash CS3/CS4 - Browser/Screen Saver/Application etc - especially it's capabilities and limitations. Of interest are Standalone player and Application.
View 3 RepliesEach line in the dynamic textbox has 15 characters, and yet you can notice the difference in the length(between each line).
I want to make the length of each line look same if they have same number of charaters.
Suppose I'm building a game where your ship moves with left/right keys.I assign a speed variable which is the number of pixels the ship will move when you press one of the said keys.Currently (on the tutorial I'm following) I have:
Quote:
static const speed:Number = 150.0
Can't I just replace it:
Quote: var speed:int = 150
Also, what's the difference between var a:Number and var a:int? And is there any important reason to add the .0 in 150.0?
I was just wondering what the difference between these two is.
View 1 RepliesWhat is the Difference between macromedia flash and flash cs4. What is the Advantage of Flash cs4. Why Flash CS4 came..?
View 4 RepliesWhat is the difference between set and get functionality?
View 1 RepliesWhat is the difference between FMS 3 and FMS 3.5? Is 3.5 a totally new version or just some kind of service upgrade?
View 8 Replies