ActionScript 2.0 :: Convert A Negative Number Into A Positive?
Nov 13, 2007Is there a way to convert a negative number into a positive using actionscript?
View 5 RepliesIs there a way to convert a negative number into a positive using actionscript?
View 5 Repliesi'd like to negate a number and would like to know if there's a built in method that will convert a negative number to a positive OR a positive into a negative, depending on the number.
i know about Math.abs(), but that only seems to convert negative into positive. is there a method that will do both?
How do you generate a Number that is randomly postive or negative?
View 3 RepliesHow would one produce a random number, ranged from say, -100 to 100?
View 3 RepliesIs there a direct way how to turn a negative number to positive using bitwise operations in Actionscript 3? I just think I've read somewhere that it is possible and faster than using Math.abs() or multiplying by -1. Or am I wrong and it was a dream after day long learning about bytes and bitwise operations?
What I saw was that bitwise NOT almost does the trick:
// outputs: 449
trace( ~(-450) );
If anyone find this question and is interested - in 5 million iterations ~(x) + 1 is 50% faster than Math.abs(x).
Does flash have any native function (maybe in the math library) to convert a number to positive. ie[code]...
View 2 RepliesWhats the best way to flip variable:Number polarity from + to - and back.Is there an actual method, or do you just assign the var to itself...eg...
speed = 5;
speed = -speed
Is there a way to test if a number is negative or positive.I have some clips that position themselves on and off the stage. IF one moves in the other moves out the same direction the other is moving in. This also works the same in reverse. I'm trying to do this by checking the current clips position and see if its a negative or positive number. If its a positive then I can move it onto the stage and move the other off in the same direction. Maybe there is another way of doing this but I thought if I could check its value and see if its negative or positive it would be a start.
View 5 RepliesI am creating a roulette type game that calculates the winning number based on the rotation of the main wheel. I am using if/else statements to determine the winning number based on the rotation. I am tracing the rotation in the output panel. I would like my rotation to go from 0-360, but the output panel traces 0-180 then it starts counting from "-180-0"
The wheel can spin multiple times. how to keep the numbers positive from 0-360 and not have to write my if else to accomodate the negative numbers?
How can I create random numbers (negative and positive) ?Math.random() only produces numbers between 0 and 1.
View 2 RepliesI have a function set up to determine the speed of the mouse, if the mouse is moved to the left it is returned as a variable in a negative number. I also have a function to make a movie clip scroll along, at the moment if you set the speed to 3 it will move to the left. So a positive number will move the movieclip to the left So you can see my predicament because the numbers are opposite, is there way of reversing one of them?
Here it is in short
[Code]....
Is there a way to change the style of Flex Chart according to the values.For example, in column chart, set green for positive value and red for negative value?
View 1 RepliesHow can I generate random negative and positive numbers?
math.random generates only positive ones.
I have an object that I want to be able to recognize in AS3.There's a port of OpenCV for AS3 already, that works with Haars cascades, so now I need to create a cascade of my object.
From what I've read, I'll have to create an XML of several images (positive and negative), but I can't find a program that'll do that for Mac OS X.
Is there anything I can use that'll generate that XML on Mac OS X?
I'm having a problem getting a movie clip to Motion Tween from a positive value to a negative value. I have two movie/buttons on my stage. When you click one the other movie Tweens from a y value of 0 to a y value of 400. That works fine. However, when you click the other button, the movie clip should then Tween from a y value of 400 back to a y value of 0. I cannot get this reverse tween to work.
Code:
// code for positive tween
function movePeople(event:MouseEvent):void {
movePlacesTween = new Tween(pageloaderB, "y", Strong.easeOut, 0, 400, 0.5, true);
}
[Code].....
The second tween never reverses. It just stays in place.
I've also tried the same tweens using the y value of pageloaderB... so tweening from pageloaderB.y to pageloaderB.y+400, which works, but the reverse does not -- pageloaderB.y+400 to pageloaderB.y.
why the reverse tween is not functioning?
check if a negative number is less than another negative number. The if condition logic seems to be in order as far as i can tell but it doesent work for some reason :
Code:
public function minuscheck(testnumber:int):void
{
if (testnumber < -1)
[code]....
Code: Select allimport caurina.transitions.*;
addEventListener(Event.ENTER_FRAME , kop)
function kop(e:Event):void {
dot.x = mouseX ;
dot.y = mouseY ;
[Code]...
What i done there i draw a box and made it to movieclip and instance named it hook and created a invisible dot and called it dot. Then I calculated distance from box to the mouse then i took that number and put it in Math.cos command. And finally i made tweener to change box scale depending what my mouse distance from it.So if my mouse is close the box is big , if far - box is small. Ok, I want to know is there another way to do this ? Cuz , i cant think of other way to change arithmetic positive progression(like 3,6,9,12) to negative progression(like 12,9,6,3) than Math.cos command.
I am building a photo gallery and I want my variable to always be a positive whole number, here's the code for the buttons using UIimage loader etc.
var dinnerImageNum:Number = 1
function forwardImage (evtObj:MouseEvent):void{
//adding to the variable number, dinnerImagenum
dinnerImageNum++;
[Code] .....
How do I make my var dinnerImageNum always equal to or greater than 1?
how to turn a variable number from positive to negetive using AS2? eg:
Code:
myVar1 = 40;
//use code to change to negetive number
myVar1 = -40;
I need to check if a number is negative and if so, trace "true" and if not "false".
View 2 RepliesI'm working on a AS3 project where users will decide whether a random number is whole number or not.There are three boxes (box1, box2, box3), which will display random numbers. Under each box there are two check buttons (for example: bt1 and bt2).There are also two boxes counting correct and incorrect answers (correct1 and correct2). There is a button generating random numbers again (bt_2).The negative random numbers are not recognized by my conditional. Or I don't know how to handle conditional with negative numbers. Positive or negative numbers display the correct check mark? Here is my AS3
//counters
var i:uint=0; // correct answersvar u:uint=0; // incorrect answers
// making check mark invisibleco1.visible=false; // correctco2.visible=false; [code].....
I'm working on a AS3 project where users will decide whether a random number is whole number or not.
There are three boxes (box1, box2, box3), which will display random numbers. Under each box there are two check buttons (for example: bt1 and bt2).
There are also two boxes counting correct and incorrect answers (correct1 and correct2). There is a button generating random numbers again (bt_2).[code]...
I have a stack of 3 Mcs, 1, 2 and 3, one over the other, at the same layer.
I want to make an action, that makes the top level MCs, when clicked, to go under the other 2 MCs, and so on.
Is it possible? I tried to make it, but discovered that it's not possible to define negative depth for a MC.
how or why it is happening??
example:
var myText:TLFTextField = new TLFTextField();
//lots of initialization to myText.
var myFormat:TextFormat = new TextFormat();
[Code]....
The last statement is the one with the trouble
f I trace new Date().toUTCString() I get something like: Fri Aug 12 07:14:06 2011 UTC.perfect. If I trace new Date().getTime() I get some long negative number which is decreasing as I continue to trace it. This is totally unexpected.
View 10 Replieshow can i convert a string ending in a number to a number? lets say i have a string such as somestring3 how can i convert that to a number 3?
View 7 RepliesMy user is using a colourpicker to select the colour. I then want to use that picked colour to change an objects colour via colour transform. But colourTransform wants an RGB version of the colour.
View 9 RepliesI need convert 1 number from dec to hex, use array char, 0123456789ABCDEF, don't use toString(16).
[Code].....
This example use Array, I can change my char, this example code convert RGB color from dec to hex, number bigger 255 can't use, convert 1 number as 1297569443 to hex 4D5756A3.
i have a simple dynamic textbox and want to store the TotalTime-property (= seconds of the video) of my video (flvplayback component) into this textbox. how can this super-easy thing be done?
View 1 RepliesI want to convert a textbox value to numric value and i use a code like this :var n:Number = Number(myTextbox.text);when i trace the variable (n) it gives me 0. although when i trace myTextbox.text , it gives me the right value.
View 1 Replies