ActionScript 3.0 :: Switch Statement Used With Multiple Values?
Apr 5, 2011I'm afraid I know the answer but I wanted to check first.
I want to run a single function based on multiple values.
[Code].....
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].....
I've got a little script that scales a video to the stage. The scaleing function has a switch statement to indicate what kind of scaling to apply.
If I declare the case value of the switch statement internally all is fine. However if I load this value from an XML doc, even though the trace indicated the value has loaded, the switch never fires.
ActionScript Code:
/stage variables
var sH:Number;
var sW:Number;
[Code].....
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 Repliesis there any switch statement in actionscript? if there is, how does it look like?
View 3 RepliesI currently have a code of a switch statement for as1- as2.[code]This code is for a dynamic tet with the var 'hint' (No ' ' )But in as3 there is no var and I am having trouble converting it to AS3 coding, can someone show me the correct conversion of the code to make it work with AS3. I will make the instance name 'hint'.
View 7 RepliesI have the following in my script:[code]where eProp is an Array.Tracing the eProp[3], shows the correct number (1 or 2) but the statement always jumps to the default part!In other words: If eProp[3] is 1 or 2, the switch do nothing, jumps to default.[code]What is wrong? AS can't evaluate Arrays? Or I did something wrong?
View 3 RepliesI generally use if statement for conditions. I would like to know the advantages of switch statement over if statement.
View 1 RepliesI am having an issue and cant figure it out..i had this working once but for some reason its not now...here is the [code]...
the trace statements work but no external swf's work.
Can you use ranges in a switch statement
E.g.
case 1 to 5:
case 20 to 30:
or even
case 1 or 2:
how to cycle backwards through cases in a switch statement.
based on it relative position??
Code:
var state=0;
nextB.onRelease=function(){
switch(state)
[Code]......
Working on a game where I load the level details from a XML file. In the XML file I list of the names of characters that I want to show on the screen; i.e. Snoop, Kilerz, Matts, etc.In my FLA file I have MovieClips that are named Snoop, Kilerz, Matts, etc.Currently I do this in my Character function:[code]so I can eliminate the switch statement as I have about 15 characters. When I use the new this[charId] I get the following error (for charId = "Snoop":error: Error #1069: Property Snoop not found on Character and there is no default value.
View 4 RepliesId like to use a switch statement to check if a given value falls between certain values and then based on different values and then perform differently in each situation. I'm hoping i just have a syntax understanding deficit. Here's what i'm trying ...that doesn't work.
Code:
public function landingCheck():void
{
[code].....
I'm trying to use the value from a combo box in a switch case statement but it isn't working
Code:
var switchValue:int = 0;
switchValue = int(cmbColour.selectedItem.data);
switch(switchValue) {[code]....
how can I check the content of an array with a switch statement?
Code:
var array :Array =[0,0];
switch (array) {
[code].....
does anyone know if declaring new variables within a switch statement (inside of case: break actually creates new variables inside those switch statements, or are the variable declarations moved to the top of the function when compiled?
i know that when declaring new variables inside a for or while loop, the compiler declares those variables at the beginning of the function. is it the same for if or switch statements?
This is really hard to explain. Probably because its late and I am now totally confused and lost. Check out this page [URL] I want A, B, C, D, E all drag-able. when D is dragged B should mirror D's position X and Y plus E should follow D's X position, This works, try it. The opposite, When B is dragged, D should mirror B, and E should follow B's X, NOT working
[Code]....
I am trying to create a Flash styled shopping cart to integrate into my website. When the "Add to Cart" button is clicked, i am displaying the corresponding text down the side of the stage. However I need a "Total Price" Dynamic text field to display the Total price of all items clicked!I am new to flash and it's proving very difficult to me, as the only way i could think of doing this is creating Boolean variables with all the items and if "add to cart" had been clicked Boolean = True... But how do I code the addition of prices? and cater for all the variations that are possible?
View 15 RepliesI have a students xml from a database. The student_state column can have a value of "passed", among other values (hence the need for switch statement). When the list_changeHandler function is called, depending on the value of student_state, I want a form to display different fields. So I tried to dynamically create the form in actionscript, but it fails to show up when I run the flex application:
import mx.containers.Form;
import mx.containers.FormItem;
import mx.containers.HBox;[code].....
I'm trying to use switch/case staement instead of if/else but it's not working. Here's the code.
ActionScript Code:
//working code
function checkTarget(drag){[code].............
Is it possible to have switch statement work with hasOwnProperty :
[Code]....
How do you do a range using switch statement in ActionScriptFor example:
score = txtScore.text
switch(score)
{
[code].....
Is there an efficient way to assign the following switch statement to two different buttons (movie clips)?
[Code]...
First time working with numeric comparison,[code]But, the code is not functioning. I don't want to use if .. else construct.
View 11 RepliesHow do you do a range using switch statement in ActionScript For example:
[Code]...
In the following class
Code:
package
{
public class Factory
{
[Code]]....
A break point on the "Okay" line shows that x1 is null but x2 is equal to "<entity id="DRONE" points="100"/>".
If I take the whole block out of the switch statement, both x1 and x2 are equal to the expected xml.
I am working on a video player that will have different Languages. The problem that i am have is that i can get the video to switch but i cant get the video to switch back. I have uploaded the file and here is the code that i have have a problem with.
lang.onRelease = function() {
if play = English)
{
[Code].....
I want to find out which type an object has. Therefore I thought of the 'switch' statement, but how would you do that? The following code does not work, but you will get the point of what I want to do.
Code:
switch (object) {
case is String:
trace("string");
case is Array:
trace("array");
[Code] ....
I've got a little script that scales a video to the stage. The scaleing function has a switch statement to indicate what kind of scaling to apply.If I declare the case value of the switch statement internally all is fine. However if I load this value from an XML doc, even though the trace indicated the value has loaded, the switch never fires.
Code:
/stage variables
var sH:Number;
var sW:Number;
var _contentHolder = new Sprite();
[code]....
3 groups of checkboxes that control visibility. Each group of checkboxes would be controlled by a radio button. That is, when radio 1 is true, the corresponding groups of checkboxes is enabled and the user can click away, making the corresponding movie clips become visible or invisible. The other two groups of checkboxes would be disabled. Then, when radio 2 is true, IT'S group of checkboxes would become enabled, and the others disabled, etc. So I thought I would try using a switch statement and put all movie clips and their corresponding checkboxes in arrays
[Code]...
But obviously it doesn't work. This is my first time working with a switch statement in Flash. Am I missing something obvious or is it a matter of a quoation mark missing or what? I'm not totally sure what belongs in the case () itself.
Sequence of events:2 SWFs running entirely separately load the same library class then load the same XML and save an attribute as a property (PS) of an Object (ob)It's then parsed through a switch statement like this:
PHP Code:
switch(String(ob.PS)){ case 'TW': d='ThumbsW/'; break; case 'TH': d='ThumbsH/'; break;//...... etc
So the classes are idential in both situations, only the loading swf changes.In one case it needs ob.PS to be typed as a string (as shown - else it drops to the default).In the other case it does NOT need ob.PS to be typed as a string!Same class, same switch statement, parsing same data (loaded from XML) yet behaving very differently!