ActionScript 3.0 :: Use A For Statement To Create An If Statement
Jul 12, 2010
what I'm trying to do is create an else if argument for each object in an array based on a user set number
Code:
for(var i:int=0; i < numberOfElseIfs; i++){
GENERATE AS3 CODE
}
to which I want it to GENERATE THE FOLLOWING CODE:
Code:
}else if(baskets[i].used == false){
baskets[i].used = true;
drawButton(i);
}
the problem is obviously that the compiler reads this code rather than understanding I'm trying to regenerate the code within the for loop...does that make sense :S? So basically I need as3 to read the code between the for statement as if it is going to echo that out later. Is this even possible?
View 4 Replies
Similar Posts:
May 14, 2009
Having a few problems with what I thought was a simple if statement. Here is the code:
[Code]...
I can't quite figure out the small problem with the code. It seems to just bypass the first requirement of the if statement when I do type in the proper input and go straight to the else statement.
View 7 Replies
Aug 31, 2011
if (variable == 1){
//code
//Execute this code.
} else if (variable == 2) {
//code
[Code]...
I dont want to copy the code from the first into the second and the first and second into the third.
My mind isn't working and there is probably an extremelly simple way to get this working.
I know I could used functions but for some reason it stops the instance referencing working: _root["bullet"+j] doesnt work in a function.
View 7 Replies
Oct 10, 2008
The Flash movie contains 2 Text files, one Component button, and 1 component checkbox.The purpose of the application is to load an XML file(works)Populate 2 text fields with information from the XML file(works)Compare the two text fields, if they contain the same information then the checkbox, via AS is told to be selected. (Heres the problem);
Heres the code:
Code:
runCode_btn.onPress = function() {
data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.onLoad = function(success) {
[code]....
The idea behind this app is that its an electronic form. The user fills it out, the information is then sent to a newly created XML file, months later the open the XML file in flash, and Flash fills out text fields and check and or unchecks Checkboxes based on the XML data.CheckBoxes are mandatory.But I don't see how I'll be able to use them if i can't create and condition statements based on the loaded Data.
View 1 Replies
Mar 30, 2011
why this code won't work
[Code]...
I'm sure you can put if statements inside other if statements, seriously I can't figure it out
View 4 Replies
Sep 22, 2010
I need to write an if statement inside an if-else statement. But no matter how I write it it keeps giving me a syntax error.The syntax error is "1083: syntax error: else is unexpected".[code]No matter how or where I place the braces, it keeps giving me errors.
View 13 Replies
Dec 10, 2011
I can create an if statement for # of selected items. However, how can I create an if statement for even.label? I have various labels and would like to create if statements based on if the text in my "labels" match up.
ActionScript Code:
function handle_checkbox_change(event:KcheckboxEvent):void {
trace("value before change : " + event.from);
trace("new value : " + event.to);
[Code].....
View 2 Replies
Dec 12, 2011
create conditional statement that will tell, that if time is 0 and enterframe event didn't played, we will trace in output window ("event didnt started")
View 1 Replies
Sep 22, 2010
I have a script which is giving me a lot of trouble since I have no idea how to write another "if statement" inside another if-else statement. I keep getting errors, I guess I don't know where to put the braces exactly...
example:
if(bla == bla) {
<------------how would I write another if statement here?
}else if (bla == bla){
}
View 3 Replies
Oct 5, 2011
Is there a way to create an if statement that executes two different loops?
For example, If I was trying to make game with a button that when clicked creates random objects falling down and when the objects are destroyed, creates random objects floating up. I haven't seen anything online, but I'm wondering if anyone know. Is it possible or should I just create two different listeners?
View 3 Replies
Feb 23, 2011
I have an arrays of swf files that are going to be loaded.I want to create IF statement that when the loadSWF reach to last SWF file (question7.swf) it tweens the alpha of hidden btn.
something like this.
ActionScript Code:
if (e.target.content == qArray[6]+".swf" )
{
TweenLite.to(end_btn,0.5, {alpha:1});
}
This is to give a general idea of the full code
ActionScript Code:
var questionbox:MovieClip = new MovieClip();
questionbox.x=0;
questionbox.y=10;
[code]....
View 0 Replies
Apr 19, 2004
is there a way to create an if statement that would load a movie clip after a different movieclip is loaded.
i have text_mc and scroll_mc. I dont want scroll_mc to load unless the content is loaded into the text_mc.
I tryed to make an if statement sort of like a something used for a preloader but I must have been off just a bit because it was not working. I dont even know if it possible.
View 7 Replies
Apr 19, 2004
is there a way to create an if statement that would load a movie clip after a different movieclip is loaded.i have text_mc and scroll_mc. I dont want scroll_mc to load unless the content is loaded into the text_mc.I tryed to make an if statement sort of like a something used for a preloader but I must have been off just a bit because it was not working. I dont even know if it possible.
View 7 Replies
Dec 18, 2011
I have a movieclip on the screen called "mc_bg". Within this movieclip are 7 movieclips called "barrier1" through "barrier7".From main.as I want to be able to do this call:
for (var i: int = 1; i < 3; i++ ){
trace("got here")
trace(mc_bg["mc_barrier" + String(i)])
[code]....
View 1 Replies
Jun 18, 2010
For a game I am making I want to create an "if" statement that waits for the right arrow key to be pressed and for the global variable "movement" to equal 0. I used the code below:
if (Key.isDown(Key.RIGHT) && (_global.movement = 0)) {
When both those statements are true, I wanted the object to move to the left at the variable "speed". the entire code I used is below:
if (Key.isDown(Key.RIGHT) && (_global.movement = 0)) {
_x -= speed;
}
When the game is played I know that the "movement" equals 0 through the debugger tool, and when I press the right arrow key, the object does not move.
View 1 Replies
Feb 15, 2011
I've created next/back buttons to navigate to various frame labels on the timeline. There is a "main menu" frame that contains menu buttons to take the user to other frame labels on the timeline. However this "main menu" frame has an FLV playing and needs to be "stopped" when navigating to another frame label. I have the code for this.
What I am inquiring about is this:Do I need to create an "if statement" in the next/back button code telling Flash that if the user clicks on the next/back button while on the "main menu" frame, to stop the FLV also?
View 4 Replies
Jan 25, 2010
I have 2 identical email forms in a flash website. One is on a page that goes to one person and the other is on a page that goes to another person. The first one works fine, but when I copy and paste the AS3 for the second form I get a series of errors that there are duplicate functions, etc. I am new, what I have to change in the following AS3 to get the second form working?[code]...
View 9 Replies
Jun 11, 2009
Is it possible to use a if statement with a eventlistener in it?
eg
if(myBut_btn.addeventlistener(MouseEvent.CLICK)){
[code]....
View 2 Replies
Nov 9, 2010
So I've been reading a lot today about the with statement performance, readability and stuff like that but i'm still not sure whether i should or should not use the with statement in AS3.
Using the with statement seems the same as creating local var which would carry the reference.
View 4 Replies
Jun 24, 2009
I am sending my header location to some variables in flash from my php page.For example when i am in the homepage then the header is:
&from=sitemap&product_id=1
What i want to do is tell the flash to go to one frame if it is the homepage and to another for any other value of products_id.What i have in my actionscript is this:
Code:
var prod_num = product_id;
if(prod_num == 1){
gotoAndStop("s1");
} else{
gotoAndStop("s2");
}
It is getting the product_id....but for some reason it always goes to frame name "s2".
View 5 Replies
Feb 16, 2003
ive got an array of cards 2-10 plus jack, queen, king, ace and i'm pulling members from the array at random--in order to score it, i decided to check the first character of the string and see if it returns a number or not.if it's a number, add the number to the score, but if it returns 'NaN' (not a number) then it will just add 10 to the score--so even tho NaN is defined as a variable in flash, somehow my if statement 'char==NaN' isn't working...
PHP Code:
[code]....
View 4 Replies
Mar 17, 2009
I'm using a for-statement to add a series of movieclips.
for (var i:Number = 0; i<10; i++) {
attachMovie("myMC", "myMC"+i, this.getNextHighestDepth());
}
Inside the movieclips I have some code. In this code I need the index-number of the movieclip. I'm staring the code off with: var indexr:Number = _root.i; The for-statement is so fast that all the movieclips get number 9 in the index-variable! Is there any trick to manage this, like can I get the index from the name in some way? Or do I have to work around it in some more or less complicated way?
View 2 Replies
May 18, 2002
Is it possible to have more than one condition on an if statement?eg. if something is black and if it is 40cm then do the following..both conditions must be fulfilled before the action can occur.
View 3 Replies
May 21, 2009
How would you use an if statement to say if you're on a certain frame do this.
if(frame is # 2){
something = true
}
if(frame is # 1){
something = false
}
View 2 Replies
Jul 15, 2009
I'm about to start a game/quiz project where the user must click several buttons, one after another (though not in any special order) to answer a question:[code]Is this the right approach and way to add variables in an if statement?
View 1 Replies
Jan 29, 2010
I have been asked by a local web development company to code some flash banners for use with there banner ad site they are doing. I have been sent a banner to add the actionscript and also the actionscript as well. What I have is a fla doc with a button that covers the whole banner. Then on the banner I have this actionscript:-
this.masterButton_but.onRelease = function(){ if (root.Hyperlink != null){ getURL(root.Hyperlink); }else if(root.clickTag != null){ getURL(root.Hyperlink); }else{ getURL("http://www.greatrun.org/Events/Event.aspx?id=3"); } }
When I test it the compiler errors and says in the description "Statement must appear within on handler".
View 1 Replies
Jun 22, 2010
on my main timeline i have a movie clip called "screen" within that i have a dynamic text box for inputing a number. var for text box is txt_1
on the same timeline i have another mc called "animation" withing that i have a mc called "prizes" there are 2 animations in the prizes movie clip that are supposed to run based on the if statement...i have an action assigned to the prizes as below:
//this.onEnterFrame = function () {
if (_root.screen.txt_1 == "11111") {
prizes.gotoAndPlay('prizes1');[code]........
but this is not working...basically i want to say that is the text that was inputed was "11111" play the first prize animation inside the "prizes" mc, and if its "22222" play the second prize animation in the "prizes" mc.what am i doing wrong?
View 7 Replies
May 2, 2011
i am working on a project where i am using the attach movie to load a clip from the library..
Actionscript Code:
regionListener.change = function(){ attachMovie(_level0.frameName + cbRegions.value,"clip",2);
Now i need to hide the sample_mc that is already on stage only if a clip is loaded... on the else statement sample_mc should be visible again..So...i dont know how to say that in AS2 language...
Actionscript Code:
If clip is loaded , sample_mc._visible = false; else sample_mc._visible = true;
View 5 Replies
Mar 12, 2009
I keep getting the "statement must appear within on handler" error when I try to add a gotoAndPlay event to my button...
View 3 Replies
Dec 16, 2008
Does it exist in actionscript a between statement? If I would search for a value that is more than 2 but less than 4. Is there like a >2<4 statement I could do?
View 1 Replies