Actionscript 3 :: Convert Negative Into Positive?
Jun 1, 2010
i'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?
View 3 Replies
Similar Posts:
Nov 13, 2007
Is there a way to convert a negative number into a positive using actionscript?
View 5 Replies
Jan 19, 2007
Whats 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
View 2 Replies
Nov 9, 2009
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 Replies
May 12, 2009
I 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?
View 5 Replies
Feb 10, 2009
How can I create random numbers (negative and positive) ?Math.random() only produces numbers between 0 and 1.
View 2 Replies
Jul 9, 2009
I 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]....
View 1 Replies
Jul 6, 2009
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 Replies
Feb 7, 2011
How do you generate a Number that is randomly postive or negative?
View 3 Replies
Aug 29, 2006
How would one produce a random number, ranged from say, -100 to 100?
View 3 Replies
Mar 11, 2009
How can I generate random negative and positive numbers?
math.random generates only positive ones.
View 3 Replies
Jun 2, 2010
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?
View 1 Replies
Jul 16, 2011
Is 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).
View 4 Replies
Oct 13, 2009
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?
View 1 Replies
Jul 20, 2009
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.
View 5 Replies
Dec 12, 2011
Does flash have any native function (maybe in the math library) to convert a number to positive. ie[code]...
View 2 Replies
Jul 17, 2011
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]....
View 6 Replies
Mar 14, 2012
I have a var that measures the distance my movieclip moves from its starting postion. the problem comes when it moves left on my stage and the distance var i created becomes negaitive.is there a way to make my var always positive, or find the absolute value of my var? here is my code
powerX = (JnowX - JstartX);the goal is to keep powerX positive
View 3 Replies
Jun 22, 2011
When I'd like to know the angle between two vectors, sometimes I get negative values (radian or degree). How do you convert them so I always get positive values? Flash seems to have a strange system for calculating angles. I used the following code for doing this, but sometimes I get negative values.
Code:
public function rangedAngleBetween(otherVector:EuclideanVector):Number {
var firstAngle:Number;
var secondAngle:Number;
var angle:Number;
firstAngle = Math.atan2(otherVector.position.y, otherVector.position.x);
[Code] .....
View 2 Replies
Aug 21, 2009
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?
View 5 Replies
Jan 21, 2010
create a random subtraction equation where the result will always be positive? For example, my current scripting will return something lilke 3-6=-3. I don't want equations like this- only postive answers
//random numbers//1.function randomNumbers(min:Number,max:Number) var Results:Number=Math.floor(Math.random()*max)+min; return Results;}
//2.new_mc.addEventListener(MouseEvent.CLICK, showRandomnumber);
[code]....
View 5 Replies
Dec 29, 2011
Im using swipe on my android app and would like to define the boundary. But the container is a LOT bigger then the stage and will reach a negative value. How would I setup my if statement for this?
View 13 Replies
Jan 25, 2009
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;
View 4 Replies
Aug 23, 2009
i have a label object.The background is in a color (set by user)The background color is in the format HTML (#FF4466 by example)I want to change automatic the color of the text inside, but i want the color make the text visible ! don't want a red font on red background!so i thought about the negative filter we have in picture program like photoshop, paintshop..etc. This effect return the opposite color
View 2 Replies
Apr 11, 2010
I want to make a text highlight in flex textArea but its htmlText doesn't support <font bgcolor='#FFFF00'> part of my text </font> so I'm searching for a font witch is the opposite of Courier new, when I embed it in flash, and write with that color I get highlight effect for that part of my text , as I type <font family="negativeOfCourier" color='#FFFF00'> part of my text </font>
View 2 Replies
Jun 10, 2011
Is there any Fastest way for this line?
ballAngelRadianVector = -ballAngelRadianVector;
And also this:
ballDegree = fee - ballDegree ;
View 1 Replies
May 4, 2011
I can get the cube root of a number by setting the index to a third:
ActionScript Code:
Math.pow(27, 1/3)
In this case though, the result is NaN
ActionScript Code:
Math.pow(-27, 1/3)
Why doesn't flash just assume that the result I am after is the simple result of -3? Also, how can I get around this?
View 4 Replies
Jun 6, 2008
I need to check if a number is negative and if so, trace "true" and if not "false".
View 2 Replies
Feb 19, 2010
how to format a dynamic text in "negative"? I mean for example white characters on black "box".
View 2 Replies
Oct 18, 2009
As far as I know, you can't refer to an array using negative indices in actionsscript, can you? I know it's possible in C, C++ and D, but not in actionsscript - to my knowledge. See here's my problem:
Code:
for (var i = 0; i<menucount; i++) {
xpos += menuitems[i-1]._width/2+miborder+menuitems[i]._width/2;
[code].....
View 4 Replies