ActionScript 3.0 :: While() Loop With Condition For Each Value In An Array?
Jul 15, 2009
Just wondering...s it possible to create a while() loop with as condition comparing a value against all items in array?e.g.
ActionScript Code:
while(myValue == for each(var i in myArray)) {
//Do Something
[code]........
View 3 Replies
Similar Posts:
Jan 21, 2012
Is it possible to use a for loop within an if condtional statement? I have been trying but just get errors no matter what I do. I have a series of buttons that pop up in a window and I want to make it so a click anywhere outside of the buttons will close the pop up window. I have been doing this by running a hitTest that checks if any of the buttons are being touched one at a time. It works, but it seems overly tedious, especially since there are a lot of buttons. I do not want to put the hitTest on the background of the window because it will cause the mouse cursor to turn into a hand even when it is not over one of the actual buttons.
If the for loop can't be within an if condition, then maybe there is a better way to use the hitTest code, but I couldn't figure that out either. Here's a simplified version of what I have now (it works, but is too much code..):
[Code]....
View 6 Replies
Mar 9, 2011
i tried to use setInterval() and Timer function, but it doesn't work
Code:
for(i:Number=0; i<100; i++){
if(i%2 ==0 ){
trace("--------");
[code]....
View 5 Replies
Oct 11, 2010
I have a loop in a function which condition depends on some variables a,b,c and d. I would like to change that condition depending on where the function is called from. Would it be possible to assign those conditions to a variable (string maybe)?
Like this
function varcon():void{
while (conditionVar){
a=...
[Code]....
View 4 Replies
Nov 9, 2011
I'm wrestling with an issue right now and I'm hoping for some help, and more so, I'm hoping I can explain my problem. With the thought of a "fill in the blank/drag and drop/string replacement" interaction, here's how my swf works:
I have a various movie clips that can be dropped on various movie clips.When one movie clip is dropped on another, the corresponding __#__ within myTitle.text will be replaced with a string that is related to the movie clip that was just dropped: i.e. myTitle.text becomes 'This is the most annoying [thing]...'Per that example I just mentioned, in the code below, my for loop searches for __1__ and moves the hTarg movie clips accordingly.Once a __1__ is replaced with the associated string I mentioned, the indexOf the __1__ becomes null because it no longer exists in the string, and the following startRect(s) below also become null.
So, my question is: How do I continue to loop through my for loop if the first index is null? I hope this makes sense, and I'm hoping someone can ituit what I'm trying to do based of my lousy explanation. If more clarification is needed, let me know and I will do my best to further explain.
[Code]...
View 5 Replies
Feb 12, 2011
I need to loop a flv file in flash if a condition is true.
So I tryed to add a listener but id doesn't work.. Code below:
textBox.addEventListener(FocusEvent.FOCUS_IN, focusInListener);
var connection:NetConnection = new NetConnection();
var stream:NetStream;
var video:
Video = new Video(200, 200);
var metaObj:Object = new Object();
[Code]...
View 2 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 2, 2011
I would like to remove objects from my array if they do not meet the condition. But I haven't been able to get the result i want.
[Code]...
View 5 Replies
Jul 10, 2011
What I want is: when the "hero" touches an enemy, all enemies should be removed. The problem is that when the hero touches an enemy it only removes that enemy. This only happens when its inside of an "if" condition. I made another example using buttons and worked perfect. let me show you the examples: in this case I made a button to create some movie clips inside an array:
ActionScript Code:
i = 0
myArray = []
boton1_btn.onPress = function(){
[Code]....
in the dieEnemies() function it only remove the one enemy the hero is hitting. What should I do to make all enemies being removed?
View 4 Replies
Sep 12, 2009
I have a BD return by PHP without problem : I have "all_good" and "no_good" If the variable change my condition don't change ..... why
[Code]....
View 3 Replies
Sep 25, 2009
I want to loop through an array and use the array value to reference a variable.
The Setup:
(For illustration only. Not actual script)
My MCs:
triangle_mc
square_mc
[Code]....
View 1 Replies
Aug 25, 2011
ActionScript Code:
var answerArray:Array = ["3", "2", "5", "3", "2"]; //these are the correct answers
var answeredArray:Array = ["3", "1", "1", "3", "2"]; //this is an example of what the user
[code]....
View 3 Replies
Jan 20, 2011
I have this flash movie I've been working on for awhile. I've received in these forums. I have my file set to load an array of swfs. Now, though, I'm wondering how to keep it from looping. At the end of the last swf, I want the movie to go to the last swf and then just stop. Here is my code:
[Code]...
View 9 Replies
Nov 11, 2009
I have this map I'm creating in Flash. You click on a state, then you can click on an icon to view a tooltip/popup of some information. What I was trying to do was instead of creating new functions and event listeners for every different icon is to use a for loop...but it's not going so well.[code]...
View 2 Replies
Jun 21, 2010
I've a container file which loads an array of SWFs. The code is as follows:
var request:URLRequest;
var loader:Loader= new Loader();
stage.addChild(loader);
var myMovies:Array=["../flash/movie1.swf","../flash/movie2.swf", "../flash/movie3.swf"];
var movieNum:int=0;
var mcExternal:MovieClip;
[Code] .....
This works fine - the array is loaded and plays through once... What changes are needed to get it to loop through the array.
View 2 Replies
Oct 6, 2010
how can i set an array by using a loop.. the array is contains by a data that i read from database.. so the length of carry depend of the length of data in my database..
i try to use
for (var i:int = 0; i < xxx; i++) {
products = [p[i]];
}
i never read data from database in as3.. so if i want to use the data in database for this loop,what should i do?
View 2 Replies
Feb 16, 2008
if you could run a loop in an array?
I'm having to make an array that has each value increase by a 10, like 10, 20, 30, etc. is there an easier way to put in those values without adding them 'manually'?
and I have another question that is related. For this same project, on the stage there will be a text box and the user will put in a number--how can that value be run through the array? like say I input the number 500, how does it find it in the array? is there a passed id, a listener and a broadcaster?
View 2 Replies
Apr 29, 2009
i got stucked in a problem in actionscript 2.0
there is a 2d array - arr[12][13]
how can we start a loop to copy the value(using for loop) in manner:
a1=arr[0][0]
a2=arr[0][1]
a3=arr[0][2][code].....
View 5 Replies
Sep 15, 2009
I have an array like this:
Code:
var myData = new Array();
myData["name"] = "John";
myData["Age"] = 35;
What is the syntax to loop through and get the key and value? I have tried for each and for in but they just give me the value of "John" or "35", how can I get the key e.g. "Name" and "Age"?
View 2 Replies
Feb 8, 2012
Is there a simple equivalent to what I used to do in AS2 to add a bunch of new objects to the stage and throw them into an array so they can easily be referenced? I'm finding this more difficult than it used to be.
Old code:
ActionScript Code:
mc_array = new Array();
for(i=0;i<5;i++){
[code]....
View 6 Replies
Jan 29, 2009
Consider an array with x number of elements (of type Object) where some of the elements might be undefined.I use a for-each loop to access all the elements of the array that is not undefined (since it simply skips the undefined elements).But I also want the index of that particular element.The only option I can see is to use indexOf(). But it feels a bit like looking for water on the other side of the river so to speak.
When looping through long arrays each frame, is there a change indexOf() might slow it down? or does the for-each loop somehow know what index it's dealing with?
View 19 Replies
Apr 5, 2010
I am quite new to AS3 and I am having trouble adapting my knowledge of Java to this new language i am trying to make a simple grid in which i could work on each individual square seperately(changing their colour for example). To do so, I created a 2D array,hoping it would allow me to work with some kind of coordinates system. I initialised the array using while loops and for some reason, this does not let me access the array outside the loops.[code]The two last lines are causing the problem, instead of turning the last square red, they return the following error: TypeError: Error #1010: A term is undefined and has no properties.However, when placed inside the loop, there is no problem and the whole grid turns red.
View 3 Replies
May 3, 2010
I need to find a way to search through an array of grades and find grades that fall into levels such as[code]...
View 14 Replies
Jul 27, 2011
I like to use array.length in my for loop to keep my code cleaner to read. Is there any huge downside to this? For example will it speed up things greatly if i store the length in a var one time?
View 22 Replies
Sep 30, 2011
Is it possible to to loop contents in an Array? Something like this?
for (var s:Number = 1; s<21; s++) {
var me = ["tfNm"+(s)];
var mcB = ["_root.gmb_mc."+me+".tf"];
var mcC = ["_root.gmbb_mc."+me+".tf"];
//trace (mcB)
var mcA:Array = [mcB, mcC, _root.F5];
/////
}
View 10 Replies
Dec 15, 2009
Below I have an array that works but it is far too long and I am thinking there is a far easier way to generate the same result using a loop but I just can't get my head around it at the moment. The array is as follows:
var CardDeck = new Array();
CardDeck[0] = new C1();
CardDeck[1] = new C2();
CardDeck[2] = new C3();
CardDeck[3] = new C4();
CardDeck[4] = new C5();
CardDeck[5] = new C6();
[Code]...
View 2 Replies
Jun 22, 2010
There's 3 boxes I'm indexing through with a timer. They disappear in sequence. How do I make them reappear?
boxes disappear in sequence 1-3
var pink:Array = ["","boxInstance1","boxInstance2","boxInstance3"];
var timer:Timer = new Timer(555);
timer.addEventListener(TimerEvent.TIMER, onTimer);
[Code]....
I'm not to particular about the sequence they disappear and appear, but it need to keep going in a loop.
View 3 Replies
Dec 7, 2011
So I have an array, which consists of xml-values. I want to check a node from each array entry. I've tried reaching xml-values as such:
var eventArtists:XML;
for each (xmlEvent in arEvents)
{
[code].....
View 1 Replies
Jan 22, 2009
do anyone know how i can loop an array of images that I load external and each last for 5 seconds
View 2 Replies
Dec 13, 2009
is there anything changed in actionscript in flashbuilder 4? i'm new to as3.... why is following for loop not assigning value to array ?i tried in various ways, but could not get it
Code:
<fx:Script>
<![CDATA[
[code].....
View 2 Replies