ActionScript 3.0 :: Using The "or" Operator In Switch Statements
Jul 9, 2009was wondering if there was any way to implement the "||" operator for switch statements.. in the case of an "if" statement, this is how it would be:
[Code]..
was wondering if there was any way to implement the "||" operator for switch statements.. in the case of an "if" statement, this is how it would be:
[Code]..
In this example, is there anyway to fade in and out 'mcContactAmer' and 'mcY' as well as place them at specific coordinates, other than externally load them as swfs? This is the only thing holding me back from moving forward on this project and my boss would like to move forward,
View 3 RepliesI have been seriously investigating on using switch statements in this case to solve my problems, which I seem to see output showing up in clickHandler3 executed properly. However, I don't think scenario_save() has been doing anything, since I could not see the Alert.show statement been disclosed in the switch(pop2), and neither is any of the lines been written like I expected, but I do see the Alert.show in the switch(x) by executing the Alert. I have marked the sections using comments, and I wonder if I am allowed to use nested switch statements over another in Actionscript.
[Code]...
In this example, is there anyway to fade in and out 'mcContactAmer' and 'mcY' as well as place them at specific coordinates, other than externally load them as swfs? This is the only thing holding me back from moving forward on this project and my boss would like to move forward,This is what my code looks like:
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.geom.Point;
[code].....
I have 3 input text boxes and I want to display a different part of an XML file to display (in a different textbox) depending on what input textbox has been selected.
I have achieved this by using 3 separate functions and it works fine but I want to use a switch statement within one function to achieve the same result. So the user will click on a textbox which calls the function and switches depending on the textbox to load the text from an XML file.
I don't know if using a switch statment in this way is even possible to do.
Code looks like this:
var req:URLRequest = new URLRequest("Manual.xml");
var loader:URLLoader = new URLLoader();
var manual:XML;
[Code].....
the flash autoformat destroys my code... And i use it all the time .. my switch and for statements doesnt work anymore after autoformat, it adds ';' where it shouldnt..
View 14 RepliesIf the subject isn't entirely clear, it's because I'm not sure how to describe what I want to do. What I have currently is a large group of ComboBox components which trigger an event handler, which uses a Switch...Case statement to determine the selection, and then uses another Switch...Case to figure out which ComboBox actually called it so the function called can use the appropriate arguments. The way I have it written has bloated the code, so I'm wondering if there's a shorter way to do this.
[Code]...
If they get a question wrong in my quiz ( weakest link) the money clip goes to zero and it goes onto the next question. If they get it right the money clip advances and they go onto the next question. I want to include each time that it should only go onto the next question if all questions have been asked. SO i want an extra if clause in both sections, saying if current question is more than 11 go to '#game over"The questions are saved in the frame of the quiz
_root.qArray = new Array("question: A;B;C;D")
_root.qArray.push("Question?:A;B; C; D")
There are 11 questions.At the moment at the section with choosing answers I have
function selectAnswer(n) {
// correct
if (answers[n] == correctAnswer) {
_root.money.nextFrame();
[code].....
What I'm trying to do is create a program that, depending on 2 variables, multiplies another variable by a static number. Heres the code I have so far:
[Code]...
I want this on an MC:
[AS]
i = 0;
switch(thing){
case 0:
[code]....
Basically what I'm wondering is, will I lose the value of i in the first switch once I'm out of the switch? Can the second switch read the 1st switch?
Im trying to create a program that, depending on 2 variables, multiplies another variable by a static number. A friend suggested I use case/switch instead of if/else statements,which is what I was using before.
[Code]...
Looking for an operator in AS 3.0 that will work as a like or contains operator. Trying to create a search field that looks for a value (keyword) when a person types in a question in the text box.When it finds this key word it will then play a video. So if they type in "What are your training options?" It will look for train and play an flv file for our training courses.
View 3 RepliesI am going though a tutorial were I need to us an or operator its showing it as two vertical lines? How do I input that? I can't find anything like it on my keyboard and in the book it just mentions that the two lines represent the or operator and not how to even put in in the code?
View 3 Replieswhy doesn't this work?
[code]...
basically in english, i'm trying to say that:if color is equal to purple or orange or brown then do this, else if color is equal to red or pink or green, then do this.the error the above code is having is that, no matter what _root.currentSection is, it always goes to the first if statment, so leads me to believe i'm using the || operator wrong.
I'm trying to get flash to randomize an arithmetic operator from a set of operators, i.e.operators = + - * / etc and I want flash to randomly pick one from the list!How do I do this? I looked at the random tut on kirupa but I don't know how to make it work with anything other than numbers!
View 12 RepliesI'm trying to check to see if all the other movieclips on the stage are on frame 1.If they are, then on release of this button go to and stop on frame 2 of a specified movieclip. If any of the conditions in the if statement are false (any of the movieclips are not on frame 1) then I want to send all of the movieclips on the stage to frame 1 and then send the specified movieclip to frame 2.The code that I am using is below.I have placed this code on the instance of the button and all the movieclips and button are on the main stage.[code]
View 1 RepliesIm doing a tutorial in a book that moves a car from one end of the screen to the next by buttons.When you release a button it moves the car 10 pixels more down the X axis.The code confuses me and I want to understand it Please Help!
Here is the code:
// stop the cars traveling
stop();
// callback for onPress event on 'back' button
back_btn.onPress = function() {
// move my car -10 pix
[code]...
Why does the - sign and + sign appear before the = instead of after?Is this a logic operator(-= or +?Why doesn't putting the - sign or + sign after the = work?
Is there any simple way to use a plus or minus operator in AS2? To give this context, lets say I want to randomize a speed, higher or lower, on event (passing a certain x or y value) (like a ball bouncing around in a bounding box,but create some random rebound angles).I'm essentially asking if there's anoperator for the symbol '�' in AS2...
View 3 RepliesFrom a position on an Array of sector Sprites on an 11 x 11 grid, I am trying to "sense" what Child occurs at nearby sector Sprites. I felt certain I could use something like this
if (sectorArray [currentSector - 11].getChildAt is MovieClip) {
//do stuff
}
but it doesn't seem to work. I changed my visibility settings to true, thinking the false visibility might be a problem, but no result.
why doesn't this work?
[Code]...
basically in english, i'm trying to say that: if color is equal to purple or orange or brown then do this, else if color is equal to red or pink or green, then do this. the error the above code is having is that, no matter what _root.currentSection is, it always goes to the first if statment, so leads me to believe i'm using the || operator wrong.
How can I prevent concatenating when using the addition operator? totalCost_txt.text = (firstCost_txt.text + secondCost_txt.text)I can replace the "+" with any other operator and it works. (huh?)
View 3 Replieswhat the %= operator does in simple terms?Like for example what is it doing in the code below:
var durationSecs:Number=Math.floor(meta.duration);var durationMinutes:Number=Math.floor(durationSecs/60);
durationSecs %= 60; durationMinutes %= 60;
I would like to use a simple if statement.
if(filenametext!=".jpg"){
}
else{ bla bla bla}
[code]......
Is is possible to convert a string (i.e. "+") to an operator which I can use for a mathematical statement?
View 4 RepliesI want to fill color based on condition so I used conditional operator for the checkbox. But it's shows the error Implicit coercion of a value of type String to an unrelated type Array. What did I do wrong ? How can I dynamically change the color of a checkbox ?[code]...
View 2 RepliesIsn't there some way to combine two images together using the xOr operator? I realize I can step through pixel by pixel, but with all the graphics options available to Flash, I am reluctant to take such a ham-fisted approach. How can this be accomplished efficiently?
var pixel1:uint;
var pixel2:uint;
var xorMergedPixel:uint;
[Code]....
I've faced such situation. I've used to program in C#, and such code:
[Code]...
was asking both, condition1 and condition2 to be true (the case when they both are giving false and the end-result is true, could be achieved in other way). In Flex, same code would perform "some actions" if the both conditions are false. I just was wondering if is there any chance to make it break after finding first false in a queue, or I have no choice and should write nested if's?
How can I define a custom operator - for example equality operator - for a custom class?
View 1 Repliesi have a movieclip "button51". And within button51 I have opponent1.i m writing button51.(getChildByName("opponent" + indexHorizontal)as MovieClip). gotoAndStop(2);but it throws a runtime error -TypeError: Error #1123: Filter operator not supported on type stapu_fla.opponentNumbers_2.at Main / selectMode().Basically I want to change frame of a movieclip which is inside another movieclip using getChildByName for the inside mivieclip name.. Pls help
View 4 Replieshow can I shortcut the syntax on multiple operands using the "or" operator? Does each statement have to be explicitly written out? [code]Also, if I have to write a looooooooooonnnnnng line of AS like in the code window above, can I just go to the next line without Flash crying about it or does it all have to stay on the same line (not wrapped...)?
View 2 Replies