ActionScript 3.0 :: Compare A Single Variable To A Group Of Variables?
Dec 3, 2009
I'm trying to cut down the amount of code I type to complete a project. Using things like ?: and &&= over the typical if statements. Is there a way to compare a single variable to a group of variables? example...
var1==var2 || var1==var3 || var1==var4 ? doSomething : doSomethingElse;
is there a short way to check if var1==var2,var3,var4?
View 9 Replies
Similar Posts:
Jun 28, 2007
I have been able to successfully build an xml video player that can play videos that all have a unique description attribute but I would like to have the user click on a title and it play through multiple videos while that one title is highlighted. Here is the code that I have so far:
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function() {
[code].....
View 4 Replies
Oct 11, 2006
Im working on a quiz that have 4 questions with 3 options each.Example:
Q1 Which actionscript forum has the coolest viewers?
A: Actionscript.org
B: Kirupa
C: Stylegala
Now, if the surfer choose more A options than B or C he gets one result message, if he choose more B options than A or C he gets another result message. how do I compare more than one variables?
View 4 Replies
Sep 9, 2009
Compare a string to a variable name. Is there anyway you can do that?[code]...
View 1 Replies
Feb 18, 2011
I have four checkbox and store the value in the Array. So if check all the boxes than I have an Array which have value = 1,1,1,1
I want to compare that with a variable which has same value 1,1,1,1
If the both value is same than it will display correct feedback.
var user_response:Array = ["0", "0", "0", "0"];
var correct_answer = "1,1,1,1"
Here is the code
if (user_response == correct_answer ){
trace("Correct");
}
else {
trace("Incorrect");
}
I keep getting "Incorrect" even if I had selected all checkboxes.
View 3 Replies
Jun 28, 2011
I have written some code to read and compare variables and then to jump to a particular frame based on the results (pretty simple stuff). It works fine when I use a button to trigger the code but I want it to happen automatically.
I have tried using the OnEnterFrame thingy but it doesn't work and I tried just placing the code on frame 1 and letting it do its thang but that didn't work either....
I'm using the .swf in a third party program and using the API for that program to supply the values.
here is the code:
_parent.InitializeExternalVars();
var m_varStrEndSlide;
function display(){
[Code]....
View 0 Replies
Nov 17, 2009
Is this possible?, it evaluates to false, and I need that evaluates to true
This are my variables:
_root.compTecSelec1="Dominio del idioma ingl�s";
_root.compTecSelec2="Manejo de hornos";
[code]......
View 1 Replies
Feb 22, 2011
I'm doing a little weather web app in flash.So i read an xml feed and copose an array of data from it.[code]Now what i would like to do is to find and trace the entry in mydate array which have a a value that approach the most to "currenthour" variable (which is my current time i'm getting upper).For exemple if currenthour = 11.In the case that i have myhour array equal to 5 , 10 , 14 , 20.The best match will be myhour[1].
View 2 Replies
Nov 28, 2011
Comparison of number or string is understandable. But how come when in flash AS3.0, we do :
var a:TextField = new TextField();
var b:TextField = new TextField() ;
[Code]....
Is their some Application-wide ID, that flash gives to each component instance. Or is it compairson of the strings ( comparing the whole path of each component )
View 3 Replies
May 22, 2010
I am trying to compare a user inputted string to a variable already created. When I do this with int it works fine but when I try changing it to strings I can't get it to work.
[Code].....
View 3 Replies
Mar 8, 2009
I have at least 15 or so events/dates each with a button to show further details... as i need the mc for each event to play out if visible, rather than repeat the code below for every event (omitting the current event number)... is there a simple way to use the same code below but with a range of event numbers, with the exception of the current event (that i don't mind typing in). [code]...
View 2 Replies
Oct 14, 2006
load multiple variables from a single text document into one main dynamic text field. If it is possible could someone post an example for me i would appreciate it a lot
View 6 Replies
Aug 25, 2004
I am working on a script that loads variables into flash from a single .txt file, I need away to count the number of variables that are loaded from this file and wanted to know if there is any code in actionscript for doing this.The .txt file will be updated with new variables every now and gain, some may be removed so its important that the actionscript can accomidate these changes.
View 2 Replies
Apr 9, 2008
I have to update a form that's currently using the Vars property of Input Text fields to post every variable (even the ones that we don't want) to a CGI script. But I'd like to move the code forward, and get rid of some of these deprecated features; so I'm looking for an elegant solution to posting the desired variables to a CGI script, rather than every single one.
View 1 Replies
Oct 28, 2010
How to initialize and make condition for 2 variables in single for loop in Flex let keep i and j are two variables
View 2 Replies
Oct 13, 2003
could anyone help me modify the code for these checkbox components? right now, the SUBMIT button checks which ones of the checkboxes are checked and gets their label, then writes the appropriate labels in a dynamic text box.[code]For the program I am doing, I need to have a maximum of 6 checkmarks and each one of the checked label must go into its own variable. (see gray part of the swf) I would also like the labels to appear in the right order, right now it's inversed.
View 1 Replies
Oct 13, 2003
right now, the SUBMIT button checks which ones of the checkboxes are checked and gets their label, then writes the appropriate labels in a dynamic text box.
// HERE IS THE CODE FOR THE Checkbox Components-----------
// Array of the instance names of the checkboxes
myCheck = [one,two,three,four,five,six,seven,eight,nine]; // Function
[code].....
View 1 Replies
Jan 7, 2010
how to set variable time for a single timer, like I first setup this timer:
private function timer():void{
var randomTimer:Timer=new Timer(time,0);
randomTimer.addEventListener("timer", somefunction);
[Code].....
So how can I influence the time inside the timer? Do I create a global timer, remove the listener and recall the timer function? Would this work since the timer has already been declared, I a re-declare a timer?
View 1 Replies
Aug 14, 2009
I've got some MC's in my library that have radiobuttons in them -- all of this created at design time -- and pull them onto the stage dynamically. My question is how do I get the selectedData from the group? The setup is like this: In a MC called pageOne, I have a group of buttons with a group name of Q1, Q2, etc. I pull the MC onto the stage like this:
[Code]...
Do I need instance names on each of the buttons and add listeners to all of them?
View 4 Replies
Dec 22, 2009
I have a text file called testa.txt,In it it reads simply var2=value1When I test the code the text file loads properly.I have two dynamic text boxes. (This is all in a single frame for the whole movie on one layer)One text box dyn_text displays what it should: value1The second text box dyn_texta is supposed to tell me if what the value of dyn_text = value1 or not (is true) (YES or NO)dyn_texta is always telling me NObut I can't get it to work.Could you please tell me how to fix this?Code here:
Code:
myData = new LoadVars();
myData.onLoad = function(){
[code]........
View 7 Replies
Nov 6, 2009
Is there a way to group a bunch of movie clip instances into a single variable? Reason is, I have a lot of movie clips acting as buttons that I have added to event listeners. All of the movie clips with do the same functions and I have a few different functions created.
For example. How can I change this
Code:
mc_aitkin.addEventListener(Event.CHANGE, changeAlpha);
mc_anoka.addEventListener(Event.COMPLETE, changeAlpha);
mc_aitkin.addEventListener(MouseEvent.MOUSE_OVER,hoverOver);
mc_anoka.addEventListener(MouseEvent.MOUSE_OVER,hoverOver);
[Code].....
View 3 Replies
Jul 26, 2010
This is hard to describe in a sentence, so i'll write some false code: (with incorrect syntax, of course)[code]...
Is it possible to do something like this, where I pass the name of the data Type that I want it to create and it does it within the function? And I know that with this simple example it isn't necessary to do it this way, but in the full program this would save some time and make the code more efficient.
View 7 Replies
Jul 12, 2009
I am looking for a class that functions similar to JPEGEncoder from as3corlib, but instead of encoding a JPEG, I want to take a dynamic drawing the user has made (with animation) and output an SWF file that the user can download and playback on his/her computer.I understand how to create an SWF and store user variables that control the playback, but I want to make it all contained in a single SWF file.
View 1 Replies
Jan 25, 2009
Is there a way to reference multiple movieclips using a single variable name? For example,I'm making a side-scrolling game, and there's going to be many platforms, and I have some code that tells the player not to fall through these platforms, but I don't want to copy and paste the same "platform" code every time I add a new platform.
View 3 Replies
Jan 27, 2011
My movie is basically complete and consists of simple movie clips as buttons, these listen out for specific states and when these conditions are met a function is run which generally either plays a movie clip or runs a prevFrame loop.For some reason, although the mouse over and out conditions are working correctly the mouse down condition causes the variable to flip through 3 states which causes the panel im trying to show to basically run through 5 frames and then reverse for a single frame.I'm literally banging my head on my desk for a solution and my manager is starting to look at me a bit funny. Has anyone experienced anything like this before? Heres me code
Actionscript Code:
// import classes import flash.events.MouseEvent;// enable button mode for movie clipsmc_red.buttonMode = true;// Create variablesvar red_rewind:Boolean;var
[code]......
View 2 Replies
Aug 27, 2010
The dictionary use strict equals(===) for key comparison, how to change the comparison, so I can use my standard for comparison, for example, I have a class named Student:
class Student{
var id:int;
var name:String;[code]....
I want Dictionary use id to compare if the two keys are equal, not use strict equal(===) to compare if the key is the same.
View 2 Replies
Oct 17, 2010
I have some code here for some falling leaves. I was wondering how it can be altered so there is a delay between a group of leaves falling and the next group falling? also to slow down at the end of the fall? [code]
View 9 Replies
Jul 19, 2009
for (var i=1; i<=arrayCount; i++){
var temp:String = "editremove_mc";
temp += i;
[code].....
View 2 Replies
Jun 16, 2010
So my problem is when I use this code in php:"&some=var1=aa&var2=bb&&";I would like to receive to flash:trace(myvars.some);var1=aa&var2=bb&But it won't work because flash thinks that always when there is & its new variable.So if I try to trace I get var1=aa
View 0 Replies
Aug 3, 2011
Is it possible to store multiple variables of different types inside 1 object. It would be ideal to have a separate property for each variable, but not required. Is there a way to do this?
View 2 Replies