ActionScript 2.0 :: Change Number To Negative?
Jan 25, 2009how to turn a variable number from positive to negetive using AS2? eg:
Code:
myVar1 = 40;
//use code to change to negetive number
myVar1 = -40;
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 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.
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]....
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]...
Is there a way to convert a negative number into a positive using actionscript?
View 5 Replieshow 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 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).
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 RepliesCode: 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 was just working in a Flash file, and an mc was in the top left, with an x vale of around 12px.I copied and pasted that mc into another file, and when I looked back at the first file, the x value was 448.6px.
View 3 RepliesI was wondering if there is way to replace the checkNumber() function with a more flexible code. That will allow the user to change the amount of images in a folder.
Lets say i have 7 images in a folder (gal1) that im showing in a simple gallery.
What i wish to do is to be able to add or delete or change the number in the images in the folder without having to change the acctual code.
if(imageNumber==7) is rather hard, how can i make this more flexible to allow for the changes?
Code:
next1_btn.addEventListener(MouseEvent.CLICK, nextImage);
var imageNumber:Number = 1;
function checkNumber();void{
[Code].....
I have 3 buttons that increase/decrease the var 'StressPercent' and this in turn shows the new number in a 'Stresslevelbox' text box. How do I now add an EventListener for when the 'StressPercent' var changes?
Code:
var StressLevelbox:TextField = new TextField();
StressLevelbox.text = "Stress";
StressLevelbox.x = 10;
[Code]....
I want to change the text of a dynamic text box based on the frame number. [code]...
View 4 Replieshow to convert it to 0 and also if the number wsa 9, convert it to 1, and if it was 8 it gets converted to 2.. and so on.. where if it was 0 it would then be 10 Is there a formula? The 0 to 10, and 10 to 0 may not be possible but that's ok.
View 1 Replieshow can I add number to a current variable in actionscript. My variable has data coming though php(numeric data) so I want to create an if statement to say this:
If the data number(let's use 5) is equal to 5+any number then do something.
Should be pretty simple but I can't seem to figure it out right now, how can I say "any number" with code?
ActionScript Code:
if(myVar == myVar+1){
//do something;
}
Thing is the + number is uknown... so + 1 may not work cause the number may be higher than 1.
I'm stuck on this annoying bug of Flash:to animate a character i have different graphic symbols of hand positions inside a single container graphic symbol; that way instead of having to swap different symbols while animating and tweening, i just have to change the number on the "single frame" input box on the properties of the symbol.
It worked fine a few sessions ago, but now it won't let me change the frame number if there's a tween before that keyframe; tha keyframe isn't participating on any tween, and may even have some frames between the previous tweening one. The only way it will change is if i remove the first tween or add a blank keyframe between them, wich of course isn't an option when animating... i know it would work if i add a new layer and continue there, but it'll add a lot of mess to the already busy timeline.
The strange thing is that it remains working on some frames, from the previous session, and if a cut and paste them i can change the frame number freely; but if i try to build a secuence from scratch, it won't let me, even on a new document.
the variable Im interested in is numSound which at the moment is a random number between 1 and 5, but it repeats too much and a sequence would be fine. I know very little actionscript and nothing I have tried works,the code, or what seems the relevant code, is
Code:
private function randRange(min:Number, max:Number):Number
{
[code].....
Simple question i can trace all elements from xml but how to trace 5 or 15 or any number (that you enter to input text field) of random elements from xml file
View 2 RepliesI wrote a code that's suppose to change the number in a synamic text whn I press a button,What did I do wrong?
Object(root).currentNum=1;
Object(root).pageNum.text = Object(root).currentNum;
Object(root).arrowLeft.addEventListener(MouseEvent .CLICK, arrowLeftClick);
function arrowLeftClick (e:MouseEvent):void{
Object(root).currentNum-=1;
}
I want to change this bit of code
var numSound:Number = randRange(1, 5);
which I presume creates a random number between 1 and 5, to just a simple sequence of 1 to 5, or alternately, random would be ok if there was a way to preventing it from repeating numbers
basically I have an array that stores some var(int/numbers). And when I loop through the array changing the numbers of the var, at the end the number seems still unchanged. You would have a better idea of what I'm talking about base on the below code.
private var _numArray:Array = new Array()
private var _no1:int
private var _no2:int
[Code]....
I need a text box to change height according to an externally loaded number.
ActionScript Code:
homeText = new LoadVars();
homeText.onLoad = function(success) {
if (success) {
[Code]....
This should set _root.contentMain.home_txt (the text box) to 400 height right?
Why is it not changing the height to 400?
trace (nmbr); does show 400
I would like to make a dynamic button on a website I am working on. I would like one button to update a variable, and another set of buttons to add 1 or subtract one from the variable I have buttons on the left side of the page for some bands that load conent into an empty movie clip.
The website: [URL]
I would like to set up some forward and backward arrows above that content on the right, so users can also scroll through the content in order. So if someone loads the content for soul asylum, and click the back arrow, it goes back to the Wailers, and if they click the forward arrow, it goes to Swollen Members. So there is an order of pages: 1. Wailers, 2. Soul Asylum, 3. Swollen Members, 4. Passafire, 5. Beats Antique, 6. SFM Kind of an order of importance. The idea is if somebody starts by clicking #3 Swollen Members, my application will know that it is on #3 and the arrows will go to #2 or #4.
Is there a way for the main artist buttons on the left to reset a variable for the current slide? So if someone clicks on the Swollen Members picture button, a variable called currentselection equals 3 And then when the forward arrow is clicked, it will ad 1 to the current selection and load movie #4
So in VB the main Swollen Members button would be something like: im currentselection as int = 3 Which would reset the current page as 3
Then the forward arrow would have code like:
Dim Nextselection as Int
Nextselection = & currentselection +1 & ".swf"
And the button in flash would be something like:
on (release) {
loadMovie("Nextselection", "rightcontent_MC")}
Which would load 4.swf the slide for passafire.
So how would I do this in action script 2.0?
I have flash create an empty movieclip, screen_1, then attach 4 different colored movieclips to the empty one: box_1, box_2, box_3, box_4.Now I am trying to change the position of one of the boxes with the number of the box as a stored variable. So say:
boxNum = 1
this["screen_1.box_" + boxNum]._x = this["screen_1.box_" + boxNum]._x +1600
I can get this to work on the main movie clip.. but not on the movieclips inside of it.
I wrote a code that's suppose to change the number in a dynamic text when I press a button,<br>What did I do wrong?
Object(root).currentNum=1;
Object(root).pageNum.text = Object(root).currentNum;
Object(root).arrowLeft.addEventListener(MouseEvent .CLICK, arrowLeftClick);
function arrowLeftClick (e:MouseEvent):void{
Object(root).currentNum-=1;
}
now it's only showing me the number 1.