ActionScript 2.0 :: Shorten Multiple "if" Statement To "for"?
Jul 23, 2004
How do I shorten this into a "for" statement?
onClipEvent (enterFrame) {
var bttn = "0";
if (_level0.bttn == "1") {
_level0.mask2._y = _level0.btn1._y;
[Code]...
View 2 Replies
Similar Posts:
Feb 9, 2012
How can I shorten this if else statement which just simply counts up? I know there's gotta be a way. I tried a for loop in the middle of it but I couldn't get the syntax right.Basically, it compares a date range that is in an array and then loads the correct banner by date from an xml file. It's part of a scheduled banner system controlled my one xml file. It has to have that else fallback at the end.[code]
View 6 Replies
Mar 29, 2011
I have a code with statements like this
Code:
mc1.onRelease= mcfunction
mc2.onRelease= mcfunction
mc3.onRelease= mcfunction
mc4.onRelease= mcfunction
[Code]....
Is there a way to cut down the number of statements in this case?
View 4 Replies
May 7, 2009
I'm trying to declare a few variables in a for statement using the variable in the for statement. In older flash versions I would use something like this.
Code:
for(a=0;a<10;a++) {
_root["variable"+a] = "Some text "+a;
[code].....
View 3 Replies
May 18, 2005
I want to set multiple conditions for an if statement, but I don't want the conditions to all have to be true, I want to say if (a or b or c or d, etc. is true) then do this. I don't want to say if (a && b && c && d, etc. is true). Is it possible to have an if statement with an "or" in the condition? If so, what's the proper syntax for that?
View 1 Replies
Jul 8, 2009
This is my code
Code:
if (mp1._y != 555) {
new Tween(mp1, "_y", Strong.easeOut, 650, 555, .5, true);
how/where can I ad a second condition like
Code:
mp1._alpha!=100)
to that same statment before that tween plays
View 2 Replies
May 18, 2005
I want to set multiple conditions for an if statement, but I don't want the conditions to all have to be true, I want to say if (a or b or c or d, etc. is true) then do this. I don't want to say if (a && b && c && d, etc. is true). Is it possible to have an if statement with an "or" in the condition? If so, what's the proper syntax for that?
View 1 Replies
Dec 11, 2009
I am trying to do a multiple if statement checking to determine which frame label within a MC (NE) and is located on frame 3 of the main timeline, to display. In the main timeline frame 1, I have declared a new var:
var n_e;
button1.onRelease = function (){
n_e1 = 1;
main timeline go to and stop at frame 3
}
[Code] .....
But it doesn't seem to work, and most of the time it lands up on Ne("2") instead...
View 6 Replies
Apr 5, 2011
I'm afraid I know the answer but I wanted to check first.
I want to run a single function based on multiple values.
[Code].....
View 2 Replies
Oct 27, 2009
I have a conditional statement (if) that I am trying to use contingent on multiple variables being true. So the AS I have right now is:
[Code]...
But when I run that I get the following error message: "Error 1050: Can not assign to a non reference value" What do I need to change so that once 1,2 and 3 have been visited visitComplete is set to true?
View 3 Replies
Sep 5, 2005
I want to make a function that will remove every single mc symbol I've previously attached to a "mask" movieclip. So i created this:
removeAll = function(){
for(a in _root.mask){
a.removeMovieClip();
}
}
I thought if i do that itll remove each "a" it encounters but I guess I'm missing some part of that "for..in" syntax. Not sure how that works.
View 1 Replies
Mar 13, 2002
I have a button that I want to play first one frame label in a movie clip, and then another, depending on a variable.
The problem that I am having is that the movie does not wait for the first part to finish before jumping to the next.
Here is an example of the code
on (release) {
if (_root.busMove.bus == 2) {
_root.busMove.gotoAndStop ("A2beg");
_root.busMove.gotoAndPlay ("Bbeg") ;
}
}
It goes right to Bbeg, flickering briefly over A2beg which will not do!
View 10 Replies
Aug 29, 2009
I have a menu movieclip and an externally loaded swf on my main stage. The menu mc needs to control the externally loaded swf. For example the swf plays and pauses, then when any of the menu buttons are clicked the swf needs to play thru and be removed. currently I am dispatching an event for each button clicked with a switch statement. In the main timeline I need to listen for each of theses events and based on what button is clicked proceed to the correct content frame. How can I listen for different events and run one function that based on which event is registered perform a task with a switch or if statement?
View 4 Replies
Jul 30, 2006
This shouldn't be too difficult. Heres my code:
for(i=0; i<30; i++){
var box[i]:Object = new Object()
box[i].id = [i]
box[i].name = "default"
box[i].location = "default"
box[i].type = "default"
But its not working. I keep getting error messages concerning the var box[i] statement.
View 2 Replies
Dec 12, 2010
Where and how I'd put the rest for the score tracker? I'm going to be making 3 of these multiple choice questions, so what would be the best way I lay that out and transition from one question to another?[code]...
View 1 Replies
Aug 10, 2007
I have some scripts that almost doing same thing, but just different buttons, how should i shorten it down? Cause i would have a lot, damn lot function to write :s*the buttons are not dynamic created so i would be easier to do some other stuff.
Code:
lv1_bsp1.onPress = function() {
shop1();
[code]....
View 1 Replies
Apr 18, 2011
Is there an easy way to shorten the length of a target name? As you can see in the code below I have added "_snd" to "e.target.name".
Let's say "e.target.name" equals "square_1" so the code below returns "square_1_snd", when the square is clicked on.
What I want to know is how do I get "square_snd" to return?
I would think if you can do (e.target.name + "_snd") then you could do (e.target.name - "_1" + "_snd"), to get just (square_snd), but it doesn't work.
I'm sure .split() and .join() is what I need to use but can someone show how to use it in the code below?
Actionscript Code:
var ClassReference:Class = getDefinitionByName(e.target.name + "_snd") as Class; var mySound = new ClassReference(); mySound();
View 1 Replies
May 31, 2003
is there a way to use the 'tertiary operator' to shorten this code?
[AS]if (this._x<0) {
this._x = Width;
}
if (this._x>Width) {
this._x = 0;
[Code]...
View 5 Replies
Jun 17, 2008
ave some lines of code that i would like to shorten.
View 5 Replies
Dec 2, 2010
I have the following code below. Is there any way to shorten it by putting it in a for loop. I want all values to be false, apart from go2 which will be true
Code:
var goArray=[go1,go2,go3,go4, go5];
var go1:Boolean=false;
var go2:Boolean=false;[code].....
View 9 Replies
Jan 31, 2010
I want to shorten this piece of code with conditional logic:[code]But i keep getting this error - TypeError: Error #1009: Cannot access a property or method of a null object reference.
View 4 Replies
Mar 12, 2004
I have a movie clip that is about 80 frames. It just cycles through 4 pictures at 20 frames per pic. I want to use actionscript so I can cut down the number of frames. I thought I could use a while loop to do this. Here is what my code looked like:
[Code]...
View 9 Replies
Sep 30, 2009
my code works, but is way too long, infact to get the result I want it would need to be very very long.Here is *some* of my code, this is for Left. I have 3 other similar bits of code for Up, Right and Down.
on (keyPress "<Left>") { _root.player.gotoAndStop("left"); leftFunc = function () { if (_root.player.hitL.hitTest(_root.everything.hitAll.hitLeft) || _root.player.hitL.hitTest(_root.everything.hitAll2.hitLeft) ||
[code].....
View 7 Replies
Dec 12, 2010
I'm using Fl for the first time and I'm trying to create a slideshow. Everything was going fine until I realized I had spaced out the different image timelines too far to the right. Now that I've moved them all leftward I have these blank ends that make the slideshow end with a long empty nothing. How do I cut those timelines off to eliminate that dead time?
View 3 Replies
Dec 11, 2011
So if you press and hold a button, it does the function once, then waits 0.5 of a second or so then repeats the action quickly. How do I remove the 0.5 of a second wait?
View 3 Replies
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
May 2, 2011
The following doesn't work (although it gives no explicit error), but why not?nd... Is there really no way around it, strictly using the with statement? Forget using for / foreach.
with (object1, object2) {
attribute = value;
method();
}
Why the code above gives no syntax error, doesn't work but is accepted by with?If it's possible, how could we change multiple objects with same attribute using with?
var object1 = { attribute: 3 };
var object2 = { attribute: 2, method: function() { alert('blah'); } };
var object3 = { method: function() {alert('bleh'); } };
[code]....
View 2 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