[as]loop Out
After discovering this php loop
Code: //ARRAY LOOPING EXPERIMENT BASED ON FOUNDATION FLASH PHP SCRIPT. /* // Now we loop through each entry in our arrays looking for a valid match for ($count = 0; $count < count($usernames) && $matchFound == false; $count++) {
// If username and password matches entry... if ($username == $usernames[$count] && $password == $passwords[$count]) {
// Get the user's message and indicate we've found a match $message = $messages[$count]; $matchFound = true; } } */ I'm attempting to do the same with AS, running into undefined
Code: matchfound = false; var message = new Array("Fun", "Love", "Laugh"); var user = new Array("Alice", "Shelia", "Cathy"); var pass = new Array("Disco", "Tango", "Samba"); for (var i = 0; i<user.length && matchfound == false; i++) { if (users == user[i]&& password == pass[i]) { } trace(users[i]); } Can I do this?
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 02-28-2005, 07:56 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
How Do I Define The Greatest _x Position Based On A Loop, Assuming I Know The Last Element Of The Loop?
Hello,
This may be complicated,
I've a loop that creates emptyMovieClips
then I use one function to onRollOver _xscale them += 10
Now I want to move another movieClip based on the greatest _x position of my previously _xscaled elements, how do I do that?
example
for (var i = 0; i<my_array.length; i++) {
_root.menu_.createEmptyMovieClip("btn"+i, i+1);
}
//
_root.menu_["btn"+i].onRollOver = function() {
this._xscale += 10;
//
MY_DRAGER._x = HIGHT._x;
}
Can this be done?
Thanks,
I Would Like My Sound Loop To Continously Loop Without Looping Over Itself When I Repeat My Images.
I have a sound loop moving along with my flash images. When the flash images finish and I send it back to frame 1, my sound doubles. How can I play my sound loop once, but allow my images to continously loop.
Is there away to just run one loop of sound, and let the image aspect continue to loop.
I would like my sound loop to continously loop without looping over itself when I repeat my images.
Make One Element Loop Without Making Enitre Movie Loop?
i'm trying to make one element continue looping without making the entire movie loop... here's what i mean..
i have a layer that i've name actions which i've asigned a stop(); to at the end of the animation. but i want the red pulsating dot to continue looping/ animating ... to give you an even better idea, here's the swf file...
http://www.push1.com/roster_art_gal.swf
cheers!
LoadVars In A For Loop Not Executing .load Function Until For Loop Completed?
Ok so I have a simply for loop: ID[i] is a global array
Code:
for (i=0;i<12;i++)
{
var loadInfo:LoadVars = new LoadVars();
loadInfo.onLoad=function(success:Boolean)
{
if (success)
{
trace("whatever:"+loadInfo.myname);
}
else
{
trace("Nope");
}
loadInfo.load(ID[i]+".txt");
}
the problem I'm having is that the function doesn't execute until the for loop completes and then it executes 12 times in a row. Output is 'whatever: undefined' 11 times and then 'whatever: Bobble' (which corresponeds to the last .myname value as it should). Why is this? And how can I fix it? To be continued...
~NH
Loop Inside Loop... Why Doesn't Work Properly?
In order to cause a delay, I have put a loop inside another loop. Here it is:
for (a=1; a<6; a++) {
for (b=1; b<10000; b++) {
}
}
Flash delays to show the page but in the end I just see both variables with the maximun value. The point was to see variable "a" growing with delay. What have I done wrong?
Thank you
Function Inside For Loop; How To Give It Parameters Of The Loop
Hey!
This is the code:
Code:
for (i=0; i<5; i++) {
_root.createEmptyMovieClip("temp"+i, 1+i);
_root["temp"+i].beginFill(0xFF0000, 20 + (20*i));
_root["temp"+i].moveTo(0+(60*i), 0+(67*i));
_root["temp"+i].lineTo(100+(60*i), 0+(61*i));
_root["temp"+i].lineTo(100+(64*i), 100+(65*i));
_root["temp"+i].lineTo(0+(55*i), 100+(80*i));
_root["temp"+i].endFill();
_root["temp"+i].onRelease = function() {
trace("button Number = " +i);
}
}
So I made butttons and assigned each one an onRelease function. But each one needs to have assigned a variabile by the value "i" in the for loop.
When I write it like this the function itself is defined only after I click it and it ofcourse asigns all the buttons the same "i", the last value of "i" in the for loop.
How do I do it so I get first button with variable 1, second with 2,... ?
Thx.
Pausing Execution Of Code In A For Loop Between Each Loop. Howto?
I have a for loop which runs x amount of times and between each loop i'd like to implement a small pause of execution of the code. How would i do that? Can something like that only be done using a timer? If so how would i go about doing that and what things should i import? (Trying to do this in a class) ...
Loop Help: XML Attribute Doesnt Stay On Each Object Of The Loop
Hi, i'm working on a gallery that loads thumbnails from an xml file into 3 columns and when you click on a thumbnail it opens a new window with the fullsized image in.
I have modified code from a gallery tutorial to load the thumbnails from a xml file. They are going in 3 columns at the moment (I don't understand why but they are) but only the last image has a hand cursor when you rollover it, and then when you click on it, it traces "undefined" into the output box.
I have put
Code:
trace(images_arr[i].attributes.fullsize);
just below the bit where it loads the thumbnails and it traces the right path from the xml file for each image.
Can someone help me get it to trace the right path from the xml file when you click on ALL the thumbnails, not just the last one.
Thank you so much in advance!
Code:
function GenerateThumbs() {
images_arr = images_xml.firstChild.childNodes;
gap = 10;
this.createEmptyMovieClip("thumb_mc",100000);
thumb_mc._y = 10;
thumb_mc._x = 10;
for (var i = 0; i<images_arr.length; i++) {
trace('generating thumbs'+i);
this.thumb_mc.createEmptyMovieClip("thumb"+i+"_mc", i);
this.thumb_mc.createEmptyMovieClip("thumb"+i+"_tmp_mc", 300);
this.thumb_mc["thumb"+i+"_mc"]._x = ((i%3)*(67+gap));
this.thumb_mc["thumb"+i+"_mc"]._y = Math.floor(i/3)*(67+gap);
this.thumb_mc["thumb"+i+"_mc"].loadMovie(images_arr[i].attributes.thumb);
this.thumb_mc["thumb"+i+"_tmp_mc"].no = i;
this.thumb_mc["thumb"+i+"_tmp_mc"].onEnterFrame = function() {
var _mc = this._parent["thumb"+this.no+"_mc"];
var l = _mc.getBytesLoaded();
var t = _mc.getBytesTotal();
if ((l>=t) && (t>1) && (_mc._width>1)) {
_mc.onRelease = function() {
trace(images_arr[i].attributes.fullsize);
};
}
};
}
}
var images_xml = new XML();
images_xml.ignoreWhite = true;
images_xml.onLoad = function(success) {
if (success) {
GenerateThumbs();
} else {
trace("Error loading XML file");
}
};
images_xml.load("gallery.xml");
Pausing Execution Of Code In A For Loop Between Each Loop. Howto?
I have a for loop which runs x amount of times and between each loop i'd like to implement a small pause of execution of the code. How would i do that? Can something like that only be done using a timer? If so how would i go about doing that and what things should i import? (Trying to do this in a class)
Though i'm wondering if there's an easier way than timers to be able to do something like that, like C's sleep() function for example.
My Sound Loop Is Repeating Itself Ontop Of Previous Loop
Here is a link to a movie that I am working on:
LINK-
http://blue-title.com/v2/
My client says that when you first start the movie, the loop starts fine but when he clicks on one of the three buttons at the bottom (Home, Florida, Alabama) the initial first loop continues to play and a new loop is beginning to repeat while the first one is still playing.
It works fine for me in Firefox and Safari on a Mac.
Any solutions?
Todd Temple
Movie Clips In For Loop Onlydisplaying In 1st Loop
Hi there! I'm new at this so excuse if I'm being stupid.
I'm creating a game which I'm looping through an array and inside the loop I'm playing clips. The clips display only the first time the loop is being run. Here is the actionscript. PLEASE SOMEONE HELP ME... I'M DESPERATE!!!
code:
on (release) {
var myClips = new Array("Fletter", "Lletter", "Aletter", "Mletter", "Eletter");
var myClipsNewName = new Array("mov2", "mov3", "mov4", "mov5", "mov6");
var myClipsValue = new Array (10, 11, 12, 13, 14);
var cnt = 0;
for (var t = 0; t<4; t++) {
for (var i = 0; i if (cnt == -1) {
cnt = 0;
}
var temp = myClips[cnt];
attachMovie(myClips[cnt],myClipsNewName[cnt], myClipsValue[cnt]);
updateAfterEvent();
trace(myClips[cnt]);
if (i == Total-1) {
myClips.splice(cnt, 1);
myClipsNewName.splice(cnt,1);
myClipsValue.splice(cnt,1);
if (cnt == myClips.length) {
cnt = 0;
}
break;
}
cnt = cnt+1;
if (cnt == myClips.length) {
cnt = 0;
}
}
}
}
edit: jbum added as tags
Mp3 Sound Loop Bad. Wav Loop Good.
I have a soundloop which is a WAV file
and it works just fine when i loop it in flash
But when i convert it to an MP3 file...for osme weird reason theres a little less than 1 second pause when it starts again...you can tell its a loop...not smooth
But in WAV format its fine.
Its weird..ive used two different softwares to convert my wav file.
ive used Creative Wave Studio, Ive used a dedicated third party MP3-WAV convertor.
same results...the mp3 has bad looping.
any ideas?
[MX04] Loop Loop Whoops
Hi,
I know this might be really simple but I'm having a problem with my movie continuing to loop even though I've put the stop() function anywhere and everywhere I can think of. Basically, I have some mc's in Frame 1 which perform some calculations in AS. At the end of one of the calculations, I have _root.gotoAndStop(2) (which I'm assuming is telling the playhead to move on to the next frame in the main timeline).
I've put in key frames in the second frame for the same mc's to perform some different calculations which are dependent on variables from Frame 1's calculations. After running through the calculations, the movie won't stop looping and I can't figure out why.
Can anyone suggest a course of action? Thanks in advance.
Stop Loop And Replay Loop
Okay on my stage I have a start(MC) and a stop(MC) and a clear(MC) these will be used as buttons. I also have a dynamic text box that shows my output.
I am making it so when you click start it will start counting from 0 to whenever you hit the stop button, I have changed my fps to 1 so it doesn't crash my computer, And this is where I am running into trouble. Here is my code.
var myTimer = 0;
startBtn.onPress = function() {
this.onEnterFrame = function() {
myTimer = myTimer + 1;
//trace(myTimer);
this._parent.myTxt.text = myTimer;
}
}
stopBtn.onPress = function() {
trace(myTimer);
this.myTimer.onEnterFrame = stop();
}
I would also like it so when you hit start again it picks up where it left off.
Please any help would be greatly appreciated.
Thanks
T
Loop Within A Loop (creating 2 Columns)
Hello. I have the following loop, which works just fine:
ActionScript Code:
yGutter = 30;
xGutter = 28;
numPerRow = 1;
for (t = 0; t < vars.countEmployees; t++)
{
thumbCont.duplicateMovieClip("thumbCont" + t, 2000 + t);
this["thumbCont" + t]._y = thumbCont._y + yGutter * Math.floor(t / numPerRow);
this["thumbCont" + t]._x = thumbCont._x + xGutter * t - xGutter * numPerRow * Math.floor(t / numPerRow);
this["thumbCont" + t].tID = t;
this["thumbCont" + t].gotoAndStop(2);
mainCont.duplicateMovieClip("mainCont" + t, 3000 + t);
} // end of for
you can see this here:http://www.metapps.com/testing/index_email.html
I need to make 2 more columns, same as the first, with the rest of the info from the php file. Right now I have a "LIMIT 0,10" on the MYSQL request so there are only 10 rows. Ultimately there will be three rows with 30 employees.
How would I write this loop?
thanks
XML Nested Loop - Access The Loop Later... But How?
Hello all. I need help desperately, I'm very novice with this kinda stuff. Basically, I have data organized by date in an XML file. I'm trying to make a website application that will allow the user to click on a date (in a text field) to see another textfield populate with all the data under that particular date.
So far, all the information loads into the textboxes at the same time. How can I get it to only load information under a particular date when somebody clicks on that date?
Before I started this project, I was convinced I could do this by manipulating the [j] (see code below) in the myFunc2 function. Currently, it's set up to increment blank_mc._y by whatever value is returned by [j]. But for some reason this doesn't work. I feel that if I could atleas get this part to work - I could probably do the rest.
Any help is greatly appreciated. PS - I'm not sure I even need a nested loop for this...
AS code:
Code:
function loadXML(loaded) {
if (loaded) {
var nodes = this.firstChild;
for (j=0; j<nodes.childNodes.length; j++) {
groups = nodes.childNodes[j];
var info = groups.childNodes;
for (i=0; i<info.length; i++) {
var word2 = groups.childNodes[i].childNodes[0].firstChild.nodeValue;
var url2 = groups.childNodes[i].childNodes[1].firstChild.nodeValue;
_root.myText.htmlText +="<A HREF="asfunction:MyFunc,"+url2+" ">"+word2+"
</A>";
}
_root.myGroup.htmlText +="<A HREF="asfunction:MyFunc2,"+[j]+" ">"+groups.attributes.title+"
</A>";
}
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("links.xml");
function MyFunc2 (blarg) {
//trace (blarg);
//trace (blank_mc._y);
blank_mc._y = blarg;
}
function MyFunc (arg) {
loadMovie(arg, holder_mc);
};
XML Code:
Code:
<?xml version="1.0" ?>
<products>
<group1 title="January">
<item>
<one>foo</one>
<two>foo.swf</two>
</item>
<item>
<one>beans</one>
<two>beans.swf</two>
</item>
<item>
<one>spiders</one>
<two>spiders.swf</two>
</item>
</group1>
<group2 title="February">
<item>
<one>foo2</one>
<two>foo2.swf</two>
</item>
<item>
<one>beans2</one>
<two>beans2.swf</two>
</item>
<item>
<one>spiders2</one>
<two>spiders2.swf</two>
</item>
</group2>
</products>
GrRR Loop, Loop,loop
Hi ! I would like to know why when I goto publishing or otherwise. That when the program is run that the "loop" is always in the on mode. I have looked under preferences and I don't see it in there either. Can this thing be turned off somewhere by using scripts? Cause the last program I played with was supposed to "play and stop". It does work before the last frame is seen and then jumps over it when that script is activated. But then restarts the whole movie process all over again. But,now if I play the movie myself and I go and right click on the movie and turn off the loop it worksd just fine ... How do you turn that thing OFF????
ANYBODY KNOW??? HeLP!!
[Edited by Coke1bear on 12-26-2001 at 02:52 PM]
SIMPLE LOOP-D-LOOP
I have a tween that is 20 frames long nested in a MC.
Is there a way to set it to loop a specific amount of times and then stop? Similiar to the sound loop option?
Does someone have a little code or something to point me in the right direction?
Thanks!
Loop De Loop Need To Stop
Dear Helper People
I am trying to make a movie using the The Matrix Bitstream Effect
http://flashkit.com/tutorials/Specia...52/index.shtml
but I want to goandplay 10 times then stop.
Could you please tell me how I can set it so it goes through the frames 10 times then stops.
Well since I have you hear I would also like to ask.
I am also using the DOS Text Typer Effect
http://www.were-here.com/forum/tutor...sor/index.html
Why is it when I try to insert pictures to desplay on the screen, the pic moves along with the word.
How can I desplay it and not have it move.
-Thanks
MP3 Loop Script Won`t Loop
Hello guys ... I have this thing thats drivemin me nuts :s I am writing a MP3 player script but it won`t loop my sound ... and I have no idea whats wrong with it. ( I can stop the sound and play it but its not looping ) Maybe some1 could take a glance at it and give me hint woots wrong? Thank You
var mySound:Sound = new Sound();
mySound.loadSound("track1.mp3", true);
this.mc_stop.onRelease = function() {
curPlaybackPos = mySound.position;
mySound.stop();
}
this.mc_play.onRelease = function() {
mySound.start((curPlaybackPos/1000), 9999);
};
For Loop With Xml - Cant Understand The Loop
i have tried to keep this as simple as possible in order to demonstrate my confusion - i have looked at this for too long now and i really dont understand how this for loop works - sorry for the example length.
xml code:
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<node1>First node value</node1>
</root>
action script (ignoring the xml load part) :
function showNodes(node) {
trace("NODE = " + node);
for(var child = node.firstChild; child != null; child = child.nextSibling) {
trace("Node First Child = " + node.firstChild);
trace("child next sibling = " + child.nextSibling);
showNodes(child);
}
trace("xxxxxxxxxxxxxxxxxxxxxxxx " + node.nodeName + " " + node.nodeValue + " " + node.nodeType);
trace("yyyyyyyyyyyyyyyyyyyyyyyy " + child);
}
output:
NODE = <?xml version="1.0" encoding="iso-8859-1"?><root><node1>First node value</node1></root>
Node First Child = <root><node1>First node value</node1></root>
child next sibling = null
NODE = <root><node1>First node value</node1></root>
Node First Child = <node1>First node value</node1>
child next sibling = null
NODE = <node1>First node value</node1>
Node First Child = First node value
child next sibling = null
NODE = First node value
xxxxxxxxxxxxxxxxxxxxxxxx null First node value 3
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx node1 null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx root null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx null null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
i can fully see how things work up until i hit the FOR LOOP EVALUATION:
child !=null
at that point the loop is broken and the trace statements with xxxxx and yyyy come into play but why is there 4 lots of x and y traces?
if the loop is broken and child = null which it does why does the statement carry on 4 more times - should it not just return?
i understand that the update part of the for loop will execute only at the end of the loop but this still does not show why it should carry on like this?
seriously grateful for any help as its driving me nuts
thank you very much in advance
Running A Loop Within A Loop
can this be done?
so that:
this is stage 1 of loop_a (this is stage 1 of the loop_b)
this is stage 1 of loop_a (this is stage 2 of the loop_b)
this is stage 1 of loop_a (this is stage 3 of the loop_b)
this is stage 2 of loop_a (this is stage 1 of the loop_b)
this is stage 2 of loop_a (this is stage 2 of the loop_b)
this is stage 2 of loop_a (this is stage 3 of the loop_b)
and so on...
iv attempted it and the loop within the other works, but the main one does not
For Loop In For Loop Problem
in the first frame of my movie i set an array called printframes. there i list three frame labels on my main time line that i want to print. on each of those frames resides a movie clip that has its own "printframes" array, again listing frames of its own time line that i want to print.
now, i have a button who's script is as follows:
ActionScript Code:
for(Array in _root.printframes){
T1 = _root.printframes[Array];
_root.gotoAndStop([T1]);
pj.addPage(_root, {xMin:0,xMax:1024,yMin:0,yMax:768},null);
trace("current frame in main time line is "+[T1]);
for(var prop in _root){
if (typeof _root[prop] == "movieclip"){
trace("movie found= "+ [prop]);
for(Array in _root[prop].printframes){;
T2 = _root[prop].printframes[Array];
trace("found secondary movie clip's printframe, adding page," + [T2]);
_root[prop].gotoAndStop([T2]);
pj.addPage(_root, {xMin:0,xMax:1024,yMin:0,yMax:768},null);
}
}
}
}
this script is working fine accept for on huge dilema...
the first time it finds a movie with its own "printframes" array it sees the array and does what i want it to do. how ever once it sees that secondary printframes array,
when it gets to a frame of the main timeline that has a new movie clip, it sees that movie but not its "printframes" array.
can anyone tell me why?
i have attached the actual fla and would really appreciate anyones help. i am guessing that after each it finds the secondary printframes array and does what i want it to do i have to clear the array somehow.. i don't know.. my brain is fried...
Problem With A For...in Loop In A For...in Loop
Hello,
I want to do a for...in loop in another for...in loop, but can't seem to make it work properly.
I need to search a key term (var recherche) in an array (repertoire) of arrays (lettre1-lettre28).
The first solution I came up with simply doesn't work (code at the end of this message), the "lettre" variable doesn't seem to be recognize. The code works fine if I put an index there, though. And if I trace the "lettre" variable, it just comes up with "0".
In the second solution, only the lenght of the first array is being considered, so it is a problem cause the arrays don't have the same lenght and therefore not all the table is searched.
The third solution works fine, but I don't like it, if only because it generates tons of "undefined" and I'd like to keep the relative variables so that if I want to adapte the piece to another language with different letters, I can.
Here is the code:
Code:
//tableaux pour loger les différentes letters de l'alphabet
var lettre1:Array = new Array ("a", "A", "à", "À");
var lettre2:Array = new Array ("b", "B");
var lettre3:Array = new Array ("c", "C", "ç", "Ç");
var lettre4:Array = new Array ("d", "D");
var lettre5:Array = new Array ("e", "E", "é", "É", "è", "È", "ê", "Ê", "ë", "Ë");
var lettre6:Array = new Array ("f", "F");
var lettre7:Array = new Array ("g", "G");
var lettre8:Array = new Array ("h", "H");
var lettre9:Array = new Array ("i", "I", "î", "Î", "ï", "Ï");
var lettre10:Array = new Array ("j", "J");
var lettre11:Array = new Array ("k", "K");
var lettre12:Array = new Array ("l", "L");
var lettre13:Array = new Array ("m", "M");
var lettre14:Array = new Array ("n", "N");
var lettre15:Array = new Array ("o", "O", "ô", "Ô");
var lettre16:Array = new Array ("p", "P");
var lettre17:Array = new Array ("q", "Q");
var lettre18:Array = new Array ("r", "R");
var lettre19:Array = new Array ("s", "S");
var lettre20:Array = new Array ("t", "T");
var lettre21:Array = new Array ("u", "U", "û", "Û", "ù", "Ù", "ü", "Ü");
var lettre22:Array = new Array ("v", "V");
var lettre23:Array = new Array ("w", "W");
var lettre24:Array = new Array ("x", "X");
var lettre25:Array = new Array ("y", "Y");
var lettre26:Array = new Array ("z", "Z");
var lettre27:Array = new Array ("æ", "Æ");
var lettre28:Array = new Array ("œ", "Œ");
//tableau-répertoire pour loger l'ensemble des possibilités
var repertoire:Array = new Array;
for (var i:Number = 1; i < 29; i ++) {
repertoire.push(["lettre" + i]);
};//fin
var recherche:String = "k";
//solution 1
for (var colonne in repertoire) {
//trace("colonne : " + repertoire[colonne]);//repertoire[colonne] = noms des colonnes
//lettre = index des différentes lettres
for (var lettre in _root.repertoire[colonne]) {
trace(_root[repertoire[colonne]][lettre]);
}//fin for (var lettre in repteroire[colonne])
}//fin for (var lettre in repertoire)
//solution 2
for (var colonne in repertoire) {
//trace("colonne : " + repertoire[colonne]);//repertoire[colonne] = noms des colonnes
//lettre = index des différentes lettres
for (var i:Number = 0; i <= _root.repertoire[colonne].length; i ++) {
trace(_root[repertoire[colonne]][i]);
}//fin for (var lettre in repteroire[colonne])
}//fin for (var lettre in repertoire)
//solution 3
for (var colonne in repertoire) {
//lettre = index des différentes lettres, repertoire[colonne] = noms des colonnes
for (var i:Number = 0; i < 10; i ++) { //for...in avec _root[repertoire[colonne]] ne prend la mesure que de la première colonne rencontrée
trace(_root[repertoire[colonne]][i]);
if (_root[repertoire[colonne]][i] == recherche) {
trace("yeah!");
};
}//fin for (var lettre in repteroire[colonne])
}//fin for (var lettre in repertoire)
Anyone has a clue as to what can be done or what mistake I am making?
Thanks,
Victoria
Loop Inside Loop -- What's Going On?
Let's say I have this little tracer code that lists a display object container's children, and those children's children.
Maybe it would look like this:
ActionScript Code:
var target_mc = this;
for (var i:uint = 0; i < target_mc.numChildren; i++){
trace (' | ' +i+'. name:' + target_mc.getChildAt(i).name + ' type:' + typeof (target_mc.getChildAt(i))+ ' ' + target_mc.getChildAt(i));
if(target_mc.getChildAt(i).hasOwnProperty("numChildren")) {
trace(' children:');
for(var j:uint = 0; j < target_mc.getChildAt(i).numChildren; j++) {
trace(' | ' +j+'. name:' + target_mc.getChildAt(i).getChildAt(j).name + ' type:' + typeof (target_mc.getChildAt(i).getChildAt(j))+ ' ' + target_mc.getChildAt(i).getChildAt(j));
}
}
}
Edit: had an i where a j should have been, my bad
Anyways, if you want a little for loop to trace the children of an object and any children of that object, well here you go.
For Loop With Xml - Cant Understand The Loop
i have tried to keep this as simple as possible in order to demonstrate my confusion - i have looked at this for too long now and i really dont understand how this for loop works - sorry for the example length.
xml code:
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<node1>First node value</node1>
</root>
action script (ignoring the xml load part) :
function showNodes(node) {
trace("NODE = " + node);
for(var child = node.firstChild; child != null; child = child.nextSibling) {
trace("Node First Child = " + node.firstChild);
trace("child next sibling = " + child.nextSibling);
showNodes(child);
}
trace("xxxxxxxxxxxxxxxxxxxxxxxx " + node.nodeName + " " + node.nodeValue + " " + node.nodeType);
trace("yyyyyyyyyyyyyyyyyyyyyyyy " + child);
}
output:
NODE = <?xml version="1.0" encoding="iso-8859-1"?><root><node1>First node value</node1></root>
Node First Child = <root><node1>First node value</node1></root>
child next sibling = null
NODE = <root><node1>First node value</node1></root>
Node First Child = <node1>First node value</node1>
child next sibling = null
NODE = <node1>First node value</node1>
Node First Child = First node value
child next sibling = null
NODE = First node value
xxxxxxxxxxxxxxxxxxxxxxxx null First node value 3
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx node1 null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx root null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx null null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
i can fully see how things work up until i hit the FOR LOOP EVALUATION:
child !=null
at that point the loop is broken and the trace statements with xxxxx and yyyy come into play but why is there 4 lots of x and y traces?
if the loop is broken and child = null which it does why does the statement carry on 4 more times - should it not just return?
i understand that the update part of the for loop will execute only at the end of the loop but this still does not show why it should carry on like this?
seriously grateful for any help as its driving me nuts
thank you very much in advance
The Loop That Just Dosn't Loop...
After some more testing I have "the attached"...
I have moved the code onto the first frame but something is wrong...
When you click the button, it only works onces and then stops... if you keep on clicking the button the MCs get there, but they should get there in 1 click and not 17.....
Anyone know why???? :confused: :confused:
PS. the code looks very long for what it does....mmmm I need a code cleaner lol... :o
Translate 'while' Loop To 'for' Loop
hi.
i'm create a grid-like structure and am trying to translate my old loop:
Code:
while (dayCount <= lastDay) // creates 30 text fields
to a 'for' loop where I can increment the position of each duplicated text field by i * a specified width.
the thing is that i can't figure out how to do that with my while loop. but i can do it with a 'for' loop. that's why i'm trying to change it.
earlier in my code i use this 'for' loop to lay out the row above where i want to start....
Code:
for(var i:Number = 0; i < numCols; i++){
_root.createTextField("dayHeadings" + i, i, indColWidth*i, startSecRowYPos, indColWidth, colHeight);
_root["dayHeadings"+i].border = true;
_root["dayHeadings"+i].text = dayHeadings[i];
}
anyone have any ideas?
thanks to anyone for helping out. fumeng.
For Loop With Xml - Cant Understand The Loop
i have tried to keep this as simple as possible in order to demonstrate my confusion - i have looked at this for too long now and i really dont understand how this for loop works - sorry for the example length.
xml code:
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<node1>First node value</node1>
</root>
action script (ignoring the xml load part) :
function showNodes(node) {
trace("NODE = " + node);
for(var child = node.firstChild; child != null; child = child.nextSibling) {
trace("Node First Child = " + node.firstChild);
trace("child next sibling = " + child.nextSibling);
showNodes(child);
}
trace("xxxxxxxxxxxxxxxxxxxxxxxx " + node.nodeName + " " + node.nodeValue + " " + node.nodeType);
trace("yyyyyyyyyyyyyyyyyyyyyyyy " + child);
}
output:
NODE = <?xml version="1.0" encoding="iso-8859-1"?><root><node1>First node value</node1></root>
Node First Child = <root><node1>First node value</node1></root>
child next sibling = null
NODE = <root><node1>First node value</node1></root>
Node First Child = <node1>First node value</node1>
child next sibling = null
NODE = <node1>First node value</node1>
Node First Child = First node value
child next sibling = null
NODE = First node value
xxxxxxxxxxxxxxxxxxxxxxxx null First node value 3
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx node1 null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx root null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
xxxxxxxxxxxxxxxxxxxxxxxx null null 1
yyyyyyyyyyyyyyyyyyyyyyyy null
i can fully see how things work up until i hit the FOR LOOP EVALUATION:
child !=null
at that point the loop is broken and the trace statements with xxxxx and yyyy come into play but why is there 4 lots of x and y traces?
if the loop is broken and child = null which it does why does the statement carry on 4 more times - should it not just return?
i understand that the update part of the for loop will execute only at the end of the loop but this still does not show why it should carry on like this?
seriously grateful for any help as its driving me nuts
thank you very much in advance
First Loop 1 Sec, Next Loop 10 Sec, Have Code
I have this code in the last frame
Code:
stop();
var loop = true;
var timer = setInterval(makeLoop, 10000);
function makeLoop()
{
if(loop)
{
loop = false;
clearInterval(timer);
Play();
}
}
How can i put something in the first frame, so that the first loop take 1 sec, and then the code above will kick in instead of the code in the first frame?
btw, im a newbie.
EDIT:
i know that i can create a varible in the first frame like:
Code:
If (xx) {
} else {
make first loop 1 sec
xx = true;
}
For Loop Inside Of A For Loop?
Could someone please tell me why this code does not work?:
Code:
if (_root.aw3.getItemAt(count).Search == "Search") {
_root.wnd2 = Window.getWindowsByName();
for (var i = 0; i<_root.wnd2.length; i++) {
_root.searchMe = _root.wnd2[i].caption;
_root.searching = _root.aw3.getItemAt(count).Label;
_root.splitArray = _root.searchMe.split(_root.searching);
if (_root.splitArray.length>1) {
trace("Found a match from string!");
}
}
The Loop That Just Dosn't Loop...
After some more testing I have "the attached"...
I have moved the code onto the first frame but something is wrong...
When you click the button, it only works onces and then stops... if you keep on clicking the button the MCs get there, but they should get there in 1 click and not 17.....
Anyone know why???? :confused: :confused:
PS. the code looks very long for what it does....mmmm I need a code cleaner lol... :o
Translate 'while' Loop To 'for' Loop
hi.
i'm create a grid-like structure and am trying to translate my old loop:
Code:
while (dayCount <= lastDay) // creates 30 text fields
to a 'for' loop where I can increment the position of each duplicated text field by i * a specified width.
the thing is that i can't figure out how to do that with my while loop. but i can do it with a 'for' loop. that's why i'm trying to change it.
earlier in my code i use this 'for' loop to lay out the row above where i want to start....
Code:
for(var i:Number = 0; i < numCols; i++){
_root.createTextField("dayHeadings" + i, i, indColWidth*i, startSecRowYPos, indColWidth, colHeight);
_root["dayHeadings"+i].border = true;
_root["dayHeadings"+i].text = dayHeadings[i];
}
anyone have any ideas?
thanks to anyone for helping out. fumeng.
Does My For Loop Kill My While Loop?
In the code below i get results in tracing the ary array outside the while loop but not inside.
As I see it I just process the ary array to times. I don't see how they conflict?
ActionScript Code:
var i:Number = 0;
var n:Number = this.submenus.length;
// submenus will be an array contain the submenu nodes
ary = []
for (i = 0; i < n; ++i){
ary.push(this.submenus[i].attributes.nr)
}
ary.sort( function() { return random(2)? 1 : -1; });
trace(ary)// getting the correct randome arry output
while (i < n)
{
trace(ary[i])// get nothing.. not even "undefined"
}
hmmmmm.....?
Help On For Loop, I Get An Infinite Loop
Last edited by iliad2b : 2005-07-21 at 16:03.
Can anyone tell me what is wrong with my for loop?
Code:
var id:Array = new Array;
var comment:Array = new Array;
var _size:Number = 5;
var titleBar:Array = new Array;
for (var i:Number = 0; i <= _size - 1; i++)
{
titleBar.addItemAt(i, {ID: id[i]});
for (var j:Number = 0; j == i; j++)
{
titleBar.addItemAt(j, {Coments: comments[j]});
commentList_dg.dataProvider = titleBar;
commentList_dg.getColumnAt(0).width = 45;
commentList_dg.getColumnAt(0).textAlign = "center";
commentList_dg.setStyle("alternatingRowColors", Array(0xEAEFF2, 0xF8FAFB));
commentList_dg.hScrollPolicy = "auto";
commentList_dg.rowHeight = 80;
}
}
for some reason, it goes into an infinite loop.
Do...while Can Do It, But Can A For Loop Be Used?
I'm itterating through and array but sometimes I want to go backwards and sometimes I want to go forwards. Since I'm lazy I want to use the same code for both, but just adapt the condition so I can do either. I couldn't figure out a way to impliment this in a for loop (preferred method). Basically I wanted to do:
Code:
for (j=0; j<8; j++) {
// some code
}
// OR
for (j=8; j>0; j--) {
// some code
}
but I wanted to be able to change the init, condition and incrimentation dynamically. I can of course do it with do...while:
Code:
x = 5;
conditionMet = (x>0);
dir = -1;
do {
x += dir;
conditionMet = (x>0);
trace (x);
} while (conditionMet);
(obviously not the same code but same principal). If anyone has any idea how I could do this with a FOR I'd be happy to hear it.
Loop Within A Loop
i am trying to make a large matrix of the same movie clip (using duplicateMovieClip). i am doing it with nested for commands, but it seems really slow. the movie clip is very small (1kb) but sometimes i get the flash warning that the script may crash the system. in the end, it works but i am worried about the code in general. if anyone could spot anywhere there is extraneous/sloppy code, please let me know. thanks!
function scaleClip (thisClip, rowID) {scalePercent = 30 + (rowID * 2);
thisClip._xScale = scalePercent;
thisClip._yScale = scalePercent;
}
// set variables and dimensions of cross matrix
n=1;
xModule = 14;
yModule = 14;
quantHoriz = Math.floor(980/xModule);
quantVert = Math.floor(500/yModule);
// send data for first cross position
scaleClip (firstCross, n, false);
thisYCross = firstCross;
// vertical cross placement
for (n=1; n <= quantVert; n++) {
// horizontal cross placement
for (i=1; i <= quantHoriz; i++) {
fieldPlace = fieldPlace + 1;
thisYCross.duplicateMovieClip("cross"+ fieldPlace, fieldPlace);
thisXCross = eval("cross" + fieldPlace);
// determine if current clip is an even or odd column
// scale clip according to even or odd
scaleClip (thisXCross, n);
thisXCross._x = i * xModule;
}
fieldPlace = fieldPlace + 1;
thisYCross.duplicateMovieClip("cross"+fieldPlace, fieldPlace);
thisYCross = eval("cross" + fieldPlace);
scaleClip (thisYCross, n);
thisYCross._y = n * yModule;
}
stop();
If I Could Loop - Help
Hi,
Can anyone help out, does flash 5 stop checking if conditions after 9? I want to check 18 variables but after the 9th if condition there is no more checking done. what's happening???
MC Loop
hey ppl,
i was wondering if anyone knew how to loop a MC...lets say 10 loops...
so when it hits that frame it plays the MC clip 10 times
Thanx
mdddddesign...
Loop And Not Loop
I have a movie which should loop all the time. I have there also other tweened animations, which should loop e.g. two times, then wait until the whole movie has looped e.g. four times and then this (these) other animation(s) should start again.
Could this be set in a way that those other animations (or mc's) loop randomly?
How an earth this should be handled? I don't have a smallest idea.
Newbie 2nelonen
For While Loop?
i'm doing a photo counter thing.
i have a variable called 'total'.
one of the actions that the buttons perform is to add '1' to the variable 'number'
so if 'total' is set to, say 15
then I basically have a (number/total) "1/15", "2/15", "3/15" counter.
i want the photos to reset to the beginning (frame 1 of 'MC') when 'number' is greater 'total'
so i'm assuming that i need some kind of loop to check to see if number>total then go to MC frame 1 or whatever.
how would i script this?
Help In Loop
i am working on loadmovie() but i want that all files animate 10 times and then loadmovie() function start. pls help me how can i do that
Loop Can Anyone Help ?
Sorry i'm new to action scritp and this might sound stupid to most of you, I have an String of values comma separated
for the x and y coordinates for an object to follow when the mouse moves.
StringX = "1,2,3,4,5"
Stringy = "1,2,3,4,5"
I want an specific object to follow this coordinates when the mouse moves to the left or right going through the coordinates in the direction where the mouse is moving
for instance if the mouse moves left to make the object go to cordinate 3 , 2, 1 and as soon starts moving in the other direction then got to 1,2,3 and so on .
my problem is that i do not know in ow to make this loops and to send the message to the object for it to follow this coordinates could someone help Please !!
Acid
Var. Loop?
hello,
I am passing upto 20 var's into a flash movie. I would like to create one Var text box and create a loop action which will continue to loop a var box for each var passed into the movie. Ex:
Var1 >>I make this one and create a loop actions to for the below
Var2
Var3
Var4
Var5
Etc..
Which Loop?
Hi,
I have a duplicate movie event which "onclick" duplicates a movie. The problem is i want to do this x number of times on load of the movie, like creating x number of movie clips "on the fly".
I think i need to create a loop and get the above to happen on-load of the movie. I have tried loops but they haven't worked!
How can this be done?
Thanks
Cubby
Loop While ?
I am putting a preloader in front of my movie using the tutorial. What I don't understand is what the nuts "Loop While" is???? Can someone enlighten me? Below is part of the code that is part of the tutorial but I don't know how to impliment it.
Loop While (y <= _framesloaded)
Set Variable: "bytes_loaded" = bytes_loaded + eval("_level0:"&y)
Set Variable: "y" = y + 1
Thankee
I Tried That On The No Loop
I went to the last frame. I double clicked. I saw the action window. Where precisely is the information I was given on stopping the loop to be placed?
I clicked on the "Action" tab and the following comes up.
The larger window there says... "At Frame 39" in a box.
There is a smaller one line box that simply has the number "39" which I assume stands for the last frame of my little movie.
Which window gets the "code: stop ();" info? Any spaces?....More than one line?
For Loop? Help Me PLEASE
Okay i want to play a MC 3 times and i'm trying to use the for loop to do it but i cant get to work. Can i do that? Is there another way to do it? Help me please.
MC Loop?
Is there a way to take a movie clip form my first scene (library) that is not looped,..but if I wanna use it in my second scene have that same MC loop? I dont see how. With out duplicating the MC? Thanks.
-whispers-
|