Operators Problem
I'm currently doing a project for trigonometric where user will key in a number for an angle, and it will generate it's SINE, COSINE and TANGENT.
Code: // used for translating between angle units trans = Math.PI / 180;
// position of origin
sin_angle = Math.sin(Number(_root.angle)*trans); cos_angle = Math.cos(Number(_root.angle)*trans); tan_angle = sin_angle/cos_angle;
//simplify the number to 4 digit only sinA = Number(Math.round(sin_angle*100)/100); cosA = Number(Math.round(cos_angle*100)/100); tanA = Number(Math.round(tan_angle*100)/100); After this, there will be 3 textfield for user to key in the answer, sin_ans, cos_ans and tan_ans.
I've use this script to check for the answer
Code: on (release) { //checkAnswer 1 if (_root.sinA == _root.sin_ans) { trace("sin = true"); } else { trace("sin = this is very wrong"); } //checkAnswer2 if (_root.cosA == _root.cos_ans) { trace("cos = true"); } else { trace("cos = this is very wrong"); } //checkAnswer3 if (_root.tanA == _root.tan_ans) { trace("tan = true"); } else { trace("tan = this is very wrong"); } } It work nicely with a certain number but not all. Even tough user key-in the correct number, but the output still turn to be false.
I wish to know why and what's my problem. Sorry, i'm still a Noob in actionscript.
Thanks in Advance. Stephen
FlashKit > Flash Help > Flash ActionScript
Posted on: 02-18-2005, 03:39 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Pb With Operators
hi, i have the following variables:
nb_con1
nb_con2
these variables have got a value (i check this with a dynamic field that print the values)
i'm trying to make this:
var nb_conx=nb_con2-nb_con1;
if (nb_conx==1) {
writer.start();
}
but the result of nb_conx is always 0...why? i'm becoming crazy soon...
thx for your help
Help With Operators
In PHP I can do this with strings:
if (src) { status2 = src; } else { status2 = "0"; }
if (src > "") { status2 = src; } else { status2 = "0"; }
They don't seem to work. How can I check to see if a string contains something?
John
OPERATORS Question
what´s the difference between:
if (variable == true) {
}
and
if (variable = true) {
}
and the same with:
if (variable == false) {
}
and
if (variable = false) {
}
String Operators
hey, i was wondering what the script would be to rip a certain string from another string.
ex. i have name=movie.mpg, i want variable extension to equal .mpg based on the name and then a third variable named title which would be just movie. so basically
my guess w/o syntax:
name="movie.mpg"
extension=name.split(???)
title=name subtract ".mpg"
so u can kinda see my idea? well thanks in advance for any help. also an explanation of the ne, lt, le, gt, ge operators and what they do. thanks.
Bitwise Operators
Could someone explain to me what increment or decrement bitwise operator is? What are some uses for it and why is there always an "i" in it, can it be changed for something else or does it have to be an i?
Darn Operators....please Help
It seems i have a problem, i just learned variables and expressions in flash 5, so having a VERY basic knowledge of it, i decided to make a little "store" to practice this new knowledge.Well here is my dilema:
dollars = 0;
dollarx = 100 * dollars;
cents = 0;
total = dollarx + cents;
Thats what i have in my actions...(this shows the default total for the store, and says that every dollars should be multiplied by a hundred....6 dollars x 100 = 600 + 89 cents = $6.89. that is why i multiply it by a hundred, i know no easier way) Well anyway, to get back on topic, if dollars = 6 and cents = 89 the total variable would = 689 which, obviously, is not a dollar value....How would i go about making the 689 into $6.89? Being a newb i thought this would work:
total = "$" & dollarx "." & + cents;
But unfortunately it doesnt, is there another way to write it?(Yeah i know this question is idiotic...to all you master flash artists)
Comparison Operators
Hi Everyone,
I am about this... Any clues???
I am loading a text file into a dynamic textfield named "text"
I am trying to check if "text" is empty
if (_root.text ne ""){
_root.gotoAndPlay("end");
}else{
_root.gotoAndPlay("start");
}
Right now I am using 'ne' because it works when I use this, (and I know that it is deprecated) BUT, when I use '!=' it doesn't work.
Someone please shed some light as I don't want to have to use any deprecated items.
Thank you!
Variables And Operators
What am I missing with operators evaluating variables here? When the value is explicitly named, it works fine. When the value is referred by variable name, it always selects the "if' statement.
Why does this function work correctly:
function comPare() {
if (percent2comp >= 10) {
percent_comp = percent2comp;
} else {
percent_comp = percent_comp;
}
}
While this one does not:
function comPare() {
if (percent2comp >= percent_comp) {
percent_comp = percent2comp;
} else {
percent_comp = percent_comp;
}
}
Thanks
Overriding Operators
Hi!
Is it possible in Flash 8 to override operators (like in C)?
Take for example the flash.geom.Point class...
var a:Point = new Point(10, 20);
var b:Point = new Point(5, 10);
var c:Point = a + b // instead of a.add(b);
trace (c) // traces (15, 30)
Thanks, bye!
Operators In Variables
Hi,
Using Flash MX v. 7
I'm have a lot of trouble with operators in variables.
e.g. _global.howmany = firstamount + secondamount +third amount
I always get the answer NaN
Does anyone know of a tutorial for naming variables and using operators (+ - x /) within them?
Thanks a lot in advance
[F8] Problems With Operators
Hi I have troubles with a multiplication i´m using an input text and i want to multiply the value of that input text for 7 and display the result in a dinamyc text, but the result is Nan instead of a number, why??
this is the code that i´m using
on (release) {
kmx = Number(km)* 7;
nextFrame();
}
kmx <--- dinamyc text
km<--- input text
thank you
E4X Access Operators.
I've got a feeling that I've completely misunderstood what E4X does. After reading the chapter in Flash AS3 Programming it looks like you do
anElement.someChild.(@id="specificId") to access a specific element.
However if I have this
<mx:XML id="testXML" >
<stuff>
<item id="one" data="data one" />
<item id="two" data="data two" />
<item id="three" data="data three" />
<item id="four" data="data four" />
</stuff>
</mx:XML>
And then I do this :
Alert.show(testXML.item.(@id='three').toXMLString( ), 'ah-ha');
What I see is this :
<item id="three" data="data one"/>
<item id="three" data="data two"/>
<item id="three" data="data three"/>
<item id="three" data="data four"/>
So the expression 'testXML.item.(@id='three')' has not selected an item based on it's id - which is what I was expecting - instead it's edited all items.
Can anyone point me in the direction of an explanation?
What Are Bitwise Operators And How/why Do You Use Them?
Hi there, i came across these things called bitwise operators. After some research i didnt get any further than the fact that they alter bits directly.
Then i read something on shifting bits and stuff, and that this would be more efficient it this got me confused.
Can you use them to optimize your code?
Can someone give some examples of this, like a function and his alternative (using bitwise operators)?
Custom Operators
I was wondering if there was a way to make custom operators in Flash. I'm trying to make a function that will add the x and y coordinates of two vectors.
va=[x1,y1]
vb=[x2,y2]
vc=va+vb=[x1+x2,y1+y2]
Code:
function Vector(x, y)
{
this.x = x;
this.y = y;
}
Vector.prototype.plus = function(v2)
{
this.x += v2.x;
this.y += v2.y;
}
var green=0x00CC00;
var black=0x000000;
var thickness=.5;
//Draws a line from vector a to vector b
function DrawLine(va,vb)
{
var Line:MovieClip = this.createEmptyMovieClip("Line",getNextHighestDepth());
Line.lineStyle(thickness,colour,100);
Line.moveTo(va.x,va.y);
Line.lineTo(vb.x,vb.y);
}
var va = new Vector(10,40);
var vb = new Vector(60,60);
var vc = new Vector(60,60);
vc.plus(va); // i would rather be able to use vc=va+vb;
trace("va=("+va.x+","+va.y+")");
trace("vb=("+vb.x+","+vb.y+")");
trace("vc=("+vc.x+","+vc.y+")");
var colour = black;
DrawLine(va,vb);
var colour = green;
DrawLine(vb,vc);
Once I figure this out I'll make a vector manipulation class and I can continue with my work.
Any help would be much appreciated!
Using Variables And Operators
I'm trying to dynamicly load multiple images to a Movie Clip on the stage. Where I am having trouble, is when I position different sized images one under another.
What I have done is, assign a variable for the position for the _y of the next image.
eg. var spacing:Number = 0;
Since I'm loading the images from a XML file, I've included the height for each image aswell. This is where I am having trouble
eg. spacing += myxml.childNodes[i].childNodes; OR
spacing = spacing + myxml.childNodes[i].childNodes;
trace(spacing);
Say for example, the image I am loading is 400px high, 'spacing' then appears to be 0400 and not 400. After I load the second image, which is 500px high, spacing appears to be 0400500 and not 900.
Any help is appreciated, Thank you.
irok
Working With E4X Operators
I'm trying to pick out the full "player" profile (xml..profilename) information about the player when the name matches eventPlayer - but all I am getting is "True" or "False" - What am I doing wrong?
ActionScript Code:
XML Structure:<?xml version="1.0" encoding="ISO-8859-15"?><map><player_profiles><profile quote=""> <xpos></xpos> <ypos></ypos> <profilename></profilename> <profilelocation></profilelocation> <headline></headline> <article></article> <results></results> <thumb></thumb> <image></image> <flag></flag></profile></player_profiles><eventsTitle> <eventsTitleName> <name></name> <event> <name></name> <xpos></xpos> <ypos></ypos> <players> <player></player> <player></player> <player></player> <player></player> </players> <tab></tab> <tab></tab> <tabDetails></tabDetails> <tabDetails></tabDetails> <flag></flag> </event> </eventsTitleName> </eventsTitle></map>
ActionScript Code:
function testButtonClick(event:MouseEvent) {
for (var i:uint=0; i<xmlList.eventsTitleName.event.length(); i++) {
for (var p:uint=0; p<xmlList.eventsTitleName.event[i].players.*.length(); p++) {
eventPlayer = xmlList.eventsTitleName.event[i].players.player[p];
for (var j:uint=0; j<xml..profilename.*.length(); j++) {
trace(xml..profilename[j].(name == eventPlayer));
}
}
trace("========");
}
}
What Are Bitwise Operators And How/why Do You Use Them?
Hi there, i came across these things called bitwise operators. After some research i didnt get any further than the fact that they alter bits directly.
Then i read something on shifting bits and stuff, and that this would be more efficient it this got me confused.
Can you use them to optimize your code?
Can someone give some examples of this, like a function and his alternative (using bitwise operators)?
Bitwise Operators
I would like to start using flag-like properties in some of my classes that work in a similar way to the static Array properties:
Array.CASEINSENSITIVE or 1
Array.DESCENDING or 2
Array.UNIQUESORT or 4
Array.RETURNINDEXEDARRAY or 8
Array.NUMERIC or 16
One or more of those values can be passed to the Array.sort() method using the bitwise OR operator...
ActionScript Code:
myArray.sort( Array.NUMERIC | Array.DESCENDING )
My question is: Given that the value passed to the sort() method will be a single number, how can you tell which Array.parameter values were used?
Hope that makes sense. I'm still not up-to-speed on all of this bitwise operator stuff.
Dependancy Using =| Operators
Hi All,
I have created a fruit/slot machine using actionscript.
On there are wild cards as will as typical win lines.
To check for a win I have the following code
} else if (leftReelResult=='melon'|'wildCard'&middleReelResult=='melon'|'wildCard'&rightReelResult=='melon'|'wildCard') {
trace('winner');
}
If You spin 3 x Melon the win is fine. If you spin wildCard x Melon x Melon the win is fine.
If however you spin:
melon x wildCard x melon or
melon x melon x wildCard
The win function is not called.
Can anybody help me to get the right code in here?
Big Thanks,
Dabush.
(HELP) Bitwise Operators
I've just started learning about Bitwise Operators for Actionscript, so
this book is getting into 32-bit integers (binary). I don't understand
how to translate binary into base-10 numbers.
(i.e. 0000 0000 0000 0000 0000 0000 0000 0011 = 3)
Below is a formula that the book gives using the "&" bitwise operator. Can anyone please explain, or point me in the right direction so I can figure how they came to this conclusion. If I am unclear of my problem, please let me know.
//Here is the formula
x = 1234
y = 4567
z = x & y;
(answer: z = 210)
All help is greatly appreciated!
Operators Are Reversing Their Function
In writing any simple 'if than' statement my operator is acting in the reverse of what it is supposed to.
The following code comes out true when the cursor IS in the designated area and it certanly should not be true. Why is this happening?
// determin the location of mouse
x_pos = _root.grid._xmouse;
y_pos = _root.grid._ymouse;
// Make grid come on then mouse is over box
gridon = 0;
if (x_pos>=0) {
gridon = gridon+1;
}
if (x_pos<=580) {
gridon = gridon+1;
}
if (y_pos>=0) {
gridon = gridon+1;
}
if (y_pos<=126) {
gridon = gridon+1;
}
if (gridon != 4) {
tellTarget ("_root.grid") {
gotoAndPlay ("start on");
}
}
Math Operators In Expressions
How can I make a math operator, such as a plus sign (+) appear within an expression?
For instance, I have assigned random values for variables a, b, and c. Now I want variable d to appear as a math problem WITH the plus sign rather than evaluating it, so that it looks like:
d = (random value of a)+(random value of b)+(random value of c)
I welcome your suggestions!
Thanks,
Ashley
Left Side Operators
Okay, I know that in Flash 5 the following was okay:
eval("/:var1" add "/:var2") = /:varWhatever;
But in MX I get the error:
Left side of assignment operator must be variable or property.
I've never read anything about remedying this. Any suggestions? I'm sure it's something stupidly simple
Unary Operators Within Arrays
What is the simplest way to have the following expression (embedded in the array) solved: [4, "+", 5, "-", 6, "/", 9]
I am working on a genetic algortihm problem, and I need to be able to calculate the vlalue of equations that get built in the arrays. I've obviously tried parsing the literals to integers, but I can't do that with the operators, which seem to stay concatenators outside of the array, even when surounded by ints.
For example, in the array above, if I try to solve for the first 3 items:
myArray(parseInt[0]) + myArray[1] + myArray(parseInt[2]), I get:
4+5
Why doesn' t the operator add instead of concatenate, since the data types on either side are ints?
I would rather not have to write numerous operator detection functions to do the calculations.
Thanks,
Ira
Mathematical Operators... GRRR
i'm designing a children's maths game that basically centres around "if" statements and playing a certain .swf file dependant on the player's answer. my problem is that i need to play a certain .swf if the player's answer is wrong by 10 or more and i can't get the syntax right. confused? here it is
on(release){
if (_root.yourAnswer == _root.answer+10 ||
_root.yourAnswer == _root.answer-10 ||
_root.yourAnswer == _root.answer<-10 ||
_root.yourAnswer == _root.answer<+10) {
(loadMovie("gutterball.swf", "_root.checkMat"));
the 's are where i run into problems. how do i get it to play that .swf if the answer is wrong by 10 or more?
Switch Statements And && Operators
Hey, just updating this code that I am using which requires two variables to be equal to something that is set at runtime. Previously I was using:
Quote:
if (variableA=="person1" && variableB=="random"){
authentication()
} else if (variableA=="person2" && variableB=="testing"){
authentication()
}
The only difference is that I have about 15 else ifs.
Anyway, I decided that I want to use a switch statement, and can't get the and operators to work.
Basically what I want to achieve is to have a switch statement that requires two variables to be something, then activate a function if they are equal.
Cheers
P.S. any help will be much appreciated
Mathematical Operators Grrrrr...
i'm designing a children's maths game that basically centres around "if" statements and playing a certain .swf file dependant on the player's answer. my problem is that i need to play a certain .swf if the player's answer is wrong by 10 or more and i can't get the syntax right. confused? here it is
on(release){
if (_root.yourAnswer == _root.answer+10 ||
_root.yourAnswer == _root.answer-10 ||
_root.yourAnswer == _root.answer<-10 ||
_root.yourAnswer == _root.answer<+10) {
(loadMovie("gutterball.swf", "_root.checkMat"));
the 's are where i run into problems. how do i get it to play that .swf if the answer is wrong by 10 or more?
Integrating Variables Into Operators
hi all!
could anyone give me a hint on how the syntax for the following task should look like?
(timeline-position equals number of the song to be loaded, but I don't know how to integrate the previously read variable into the following command...)
trigger = _root._currentframe;
_global.Behaviors.Sound.song"trigger".mp3.start(0, 1);
doesn't seem to work...
thanx in advance. el que...
Insert Spaces Around Operators
I'm using Flash 9, CS3, on a Mac. In my preferences, under Auto Format, I have "insert spaces around operators" checked, but when I press Auto Format in the ActionScript window it doesn't work. Is there a work around?
Thanks!
Comparison Operators - Wildcard?
Hey Folks,
I am working on some search functionality, and want to be able to create a statement that will compare a string to see if it is included in a larger one. For instance, the user could search for "Bread" and I would want the results to include ["Bread Pudding","Wheat Bread","Cornbread"]. Something like that is proving tough for me,but I bet there is a magic piece of knowledge that I am not finding. Anyone got it?
Using Operators (<=) To Determine Score
I'm having trouble with this logic. I have a variable on Frame 1 _global.myVar=0 With each successful answer that value increases by 1. At the end I need to evaluate the score and send to a movie clip that will play a message related to their success in the quiz.
What is wrong with my code below:
if (_global.myVar= (<=3)){
tellTarget("/message") {
gotoAndPlay('poor')
}
if (_global.myVar= (>=4<7)){
tellTarget("/message") {
gotoAndPlay('good')
}
if (_global.myVar=(>=7)){
tellTarget("/message") {
gotoAndPlay('excellent')
}
Text File Containing Operators What The Right Syntax
hello everybody,
i need to write some arithematic in a text file that is loaded but the swf cant read ( + % x ) it only reads ( - )has anyone an idea how can i write these operators so that the swf can read it right.
Using Operators To Evaluate Dynamic Variables
I'm building a Learning Management System that includes Flash objects that pass variables back and forth to a mySQL dB.
One of the data pieces I'm passing/getting is a course completion number that is created by the triggering of a function that adds variables set as the user goes through the LMS course (hereafter the aggregate).
Everything works well and I'm getting data back and forth to the dB without any problems. My problem is this:
I need to tell the course completion variable to post the higher of the number retrieved from the dB or the aggregate number created by the function. So if the number retrieved from the dB is higher or the same as the aggregate generated number, the retrieved number is retained. If the aggregate number is higher than the retrieved number, the aggregate number is posted to the dB. The functions are triggered by the button that posts the data to the dB.
Whew! So here is the Actionscript:
//Create the comparison variable by adding the aggregate variables
function addUp() {
percent2comp = co1mp+co2mp+co3mp+co4mp+co5mp+co6mp;
}
//Compare the aggregate variable to the variable set by the dB
function comPare() {
if (percent2comp >= percent_comp) {
percent_comp = percent2comp;
} else {
percent_comp = percent_comp;
}
}
This returns the correct result when the value of the aggregate is higher, but returns the lower value to the dB when the aggregate is lower.
Can anyone troubleshoot this with me?
Thanks
New To FlashAS, Comparison Operators Don't Work As I'm Used To
Hello all
My first post!
I have some experience of Lingo and other scripting languages.
I recently got FlashMX 2004 / 7.0.1, which I'll be using to make interactive demostrations of interface concepts.
I've come across ActionScript weirdness that doesn't comply with my understanding of logic.
Example, I have the following code in a script that converts numbers to strings (0 to "0.0", 1.1 to "1.1", 9 to "9.0" etc.):
if (cvalue <1) {
// less than 1, add zeroes to front
numastext = "0." + numastext;
}
Now, in actionscript, if cvalue IS 1 the above code within the if{} is executed. How the hell is that possible ? If cvalue==1, why is code within condition cvalue <1 executed ?
Apparently I'm missing something major here, it's definitely something I don't understand.
Quick Question Re: Operators And If Statements
just need a little help.
i want to compare 10 numeric values, and assign them new variable names in ascending order.
what it the easiest way to do this...?
not like this i assume
ActionScript Code:
if(gigDat1 < gigDat2 && gigDat2 < gigDat3 && gigDat3...){
gigOrd1 = gigDat1}
else (if gigDat...
Storing Logical Operators In Variables
hey there,
Instead of writing out a conditio twice is it possible to pass the logical operators || or && through a variable?
Code:
a= true;
b = true;
c = operator || or &&
if (a c b) {
//
}
Is this even possible?
thanks,
ward
Trouble With Array Access Operators
Hello all:
I have been trying to pick apart this long string to see why it does not change the rollover color. I replaced the string with these array operators but things fell apart and stopped working. I did confirm with a couple of trace statements that the content inside the operators yields the correct string names.
----------------
(new Color(_level0.gridFrame.gridObjects[_level0.objectName + _level0.objectLevel]["lines_" + _level0.objectName + _level0.objectLevel])).setTransform({ra:0, rb:21, ga:0, gb:64, ba:0, bb:146});
----------------
I have been staring at this thing for more time that I care to admit. Any help would be greatly appreciated.
Thank you!
- Garrett
Dynamically Appending Logical Operators
I just can't seem to find the correct syntax to dynamically add boolean filters to a logical operator. Top code is 1 checkbox selected. Second code is 1 and 2 checkbox's selected.
I have about 6 checkboxes and there are 21 combinations of off / on scenarios that I don't want to hardcode. Is there any way to insert the operator?
thx
if (i > 10 ){
play();
}
if (i > 10 && gNum > 50){
play();
}
Comaparison Operators: Testing Equality Of Multiple Variables
hello all.
i was wondering if there is a short hand way of testing that multiple variables have the same value... regardless of what that value may be. in the simplest terms i want to test
If VarA = VarB = VarC then do something.
What I am currently doing is:
if ((VarA == VarB) and (VarB == VarC)){
then do something;
}
My way works... but it is not practical if you have a bunch of vars.
Is there a way to do this without getting into a loop?
thanks
meglomor
[F8] Eval, Array Access Operators And Advanced Relative Pathing
I don't remember where, but I think I read that using eval() rather than array access operators was a bad idea. In most cases I've found that the array access operators are easier to use and a more smooth solution, but what if you wanted to target something from inside an object that isn't on the timeline, like a listener? For example, where mcListener is a listener attached to a MovieClipLoader:
PHP Code:
mcListener.onLoadInit = function(target_mc) {
with (eval('clip'+i)) {
_x = 25;
_y = 25;
_alpha = 50;
}
}
On line 2, eval('clip'+i) works fine. But neither clip[i], this.clip[i] or this['clip'+i] work. I could use the full path, but this could be problematic if I wanted to load the movie into another.
Is eval() a crude way to handle this? Is it one of those functions that will be deprecated soon? What's the best way to path relatively from things like tweens and listeners?
Mobile Devices, Platforms, Operators And Flash Lite.. Beginners Questions
hi, couldnt decide here to post it so i posted same question in mobile development forum. hope i didnt break any rules.. anyway Im very new to developing flash for mobiles and although I browsed lots of websites and this message board, still have few questions.
ok, having flash cs3 I can develop application for mobile. It opens device central to let me choose device I want to develop for. Development seems pretty much straightforward. It seems to work in emulator when testing application, problem is how to transfer it to my mobile device and I do not understand what is the difference between operating systems, platforms, and operators.
ok, what i know is..
Every device has operating system in it, most popular as far as I know is symbian OS, although theres windows mobile and bunch of others.
Now, how do I know what is operating system of my mobile? if its on the list on adobe website, or listed in adobe central its clear, but sometimes adobe central specified N/A? is it not available or sth? If I know operating system of my mobile device do I need to know anything else to develop flash lite for it? is operator or platform of any importance?
Ok next.. operator would be something like verizon in us, british telecom in uk, or telstra or optus in australia right? different operators can install different platforms for same device, so for ex. motorola 3v could have brew installed by verizon in us, and in australia could have different platform installed? Please let me know if my understanding is correct.
Next.. platform is simply additional software installed on top of operating system that we can use to develop applications for devices utilizing this platform. Then we dont have to develop for specific operating system but as long as platform is installed on particular mobile our application would run with no problems. Is that right?
Also I have mobile bought in china, its motorola razor 3v. In adobe device central it has no operating system specified (N/A), platform is Brew and i think provider is verizon. Can I play flash on it? As it was bought in china i guess it hasnt got much to do with verizon and Brew so now I'm confused again.
Please let me know if anything I said makes sense or I'm totally lost. So far thats all i figured but have many more questions in my mind and hope you guys would be able to help me so thank you very much in advance for any help.
ps sorry if there is already answer to my questions in any of the previous posts and i missed it somehow, did my best to find out as much as possible before posting
Keycodes And "if" Statements And Operators, Oh My
I need to create a rather advanced "if" statement.
It has to do with keycodes. On keyup I want the script to advance, but only if a number key is pressed. In a nutshell it will work like this. If you hit a key, Flash will check if it's a number by seeing if it falls in the range of allowable keycodes, if it is then the script advances. The keycodes for the regular keyboard numbers start at 48 and end at 57. The keypad number codes start at 96 and go to 105.
My very rough guess looks something like this:
onClipEvent (keyUp) {
if (Key.getCode() is between 48 and 57 or 96 and 105) {
then advance the script
yadda...
yadda...
yadda...
}
}
The trouble is I have no idea how to create this seemingly simple line of code. Would anybody be so good as to help me with it?
Thanks in advance,
Jason
Operators "if +1 Or -1 But Not Undefined"
Hey guys,
Im trying to put an if statement together that executes "if +1 or -1 but not undefined".
Basically if an earlier specified var, is greater in value or less then before. Im building a destop ap that draws these vars in from the web, and the problem is, when I use <>, > works fine ...but if I use < ...then my if statement executes if the vars are returned as undefined (eg if the server times out or net connection drops).
How would you guys go about putting this statement?
Phew....this has been a little difficult to explain, if anyone confused or needs anymore info please ask
Zaid
Conditional Operators "? :"
Hi there!
I just ran into this little problem which is pretty superficial, but i simply dont know the answer to it.
I want to replace several simple 'if' statements with conditional operators (? : ), but there is no ELSE statement.
Right now i have a solution as defined below, but it's pretty ugly...
Is there a standard way to define this?
Code:
public function addDays(daysAdded:Number):DateDeluxe
{
/*
if ( daysAdded == undefined )
{
daysAdded = 0;
}
*/
daysAdded = (daysAdded == undefined) ? 0:daysAdded;
etc...
I was thinking more about something like this:
Code:
daysAdded = (daysAdded == undefined) ? 0;
But it seems that this isnt valid code.
Greets and eternal infamy for those that can help me ;-)
Flashkiddy!
[F8] The "and" And "or" Operators Are Deprecated?
Hi,
I stayed browsing a book today, and readed something that confused me...
The writer told that the logical operators "and" and "or" are deprecated in AS 2.0, and that we always should use || and && instead.
That's true???
I have used "and" and "or" instead || and && because it makes the code more readable, but suddenly I got worried about what will happen to my existing projects if I need to recompile it in future Flash versions...
Any comment about that???
|