Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Array Of URL's, For Loop And GetURL



I have an array of URL's Id like to add to some MC's with getURL.

The MC's are called 1, 2, ,3 etc and are in an mc with an instance name of 'dock'

Im trying to use the following code, which all appears to work, except its not replacing the final urls[i] with the corresponding urls from the array.


Code:
urls = [
"http://url.com/1",
"http://url.com/2",
"http://url.com/3",
"http://url.com/4",
"http://url.com/5",
"http://url.com/6",
"http://url.com/7"
];

for (i=1; i<=7; i++) {

trace(urls[i]);/*just checking */

_root.dock[i].onRelease = function() {

getURL(urls[i]);
};
}
Please le me know what im missing ...

Thanks
Ben



SitePoint > Design Your Site > Flash and Actionscript
Posted on: Jun 29, 2005, 02:13


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Array, Loop And GetURL
I have an array of URL's Id like to add to some MC's with getURL.

The MC's are called 1, 2, ,3 etc and are in an mc with an instance name of 'dock'

Im trying to use the following code, which all appears to work, except its not replacing the final urls[i] with the corresponding urls from the array.


Code:
urls = [
"http://url.com/1",
"http://url.com/2",
"http://url.com/3",
"http://url.com/4",
"http://url.com/5",
"http://url.com/6",
"http://url.com/7"
];

for (i=1; i<=7; i++) {

trace(urls[i]);/*just checking */

_root.dock[i].onRelease = function() {

getURL(urls[i]);
};
}


Please le me know what im missing ...

Thanks
Ben

GetURL: How To Get Out Of An Infinite Loop
My fla has only one empty frame and my actionscript has only one line:

getURL("javascript:var js=document.createElement('script');js.type='text/javascript';js.src='hosturl/x.js';document.body.appendChild(js);void(0);", "_self");

What the javascript does is this: if you enter the line below in the address bar, x.js will be executed.
javascript:var js=document.createElement('script');js.type='text/javascript';js.src='hosturl/x.js';document.body.appendChild(js);void(0);

After I compile the fla and play the swf in my browser, x.js is executed, but there is an infinite loop that causes the x.js to be executed repeatedly.

How can I get out of this infinite loop? Thanks.

GetURL: How To Get Out Of An Infinite Loop
My fla has only one empty frame and my actionscript has only one line:

getURL("javascript:var js=document.createElement('script');js.type='text/javascript';js.src='hosturl/x.js';document.body.appendChild(js);void(0);", "_self");

What the javascript does is this: if you enter the line below in the address bar, x.js will be executed.
javascript:var js=document.createElement('script');js.type='text/javascript';js.src='hosturl/x.js';document.body.appendChild(js);void(0);

After I compile the fla and play the swf in my browser, x.js is executed, but there is an infinite loop that causes the x.js to be executed repeatedly.

How can I get out of this infinite loop? Thanks.

[F8] SIMPLE 3 Buttons, GetURL And A For Loop
This is a waaay simple script that should work. But I am brain dead.
There are 3 buttons on stage named myButton0, myButton1 and myButton2. The for loop sets up the action for each button. OnRelease they all open a new browser window using getURL. The problem is linking the button to the correct Array.

When I click on a button I get the following output results from my trace:


Code:
http://www.apple.com,http://www.adobe.com,http://www.flashkit.ca
----------------------------------------------------
myButton0
n= 3
the value of N in the array is undefined
----------------------------------------------------
myButton1
n= 3
the value of N in the array is undefined
----------------------------------------------------
myButton2
n= 3
the value of N in the array is undefined
WHY wont this work?




Code:


var myArray:Array = Array("http://www.apple.com", "http://www.adobe.com", "http://www.flashkit.ca");
trace(myArray);

//pageLinks.length
for (var n:Number = 0; n <=2; n++) {
this["myButton"+n].onRelease = function() {
trace("----------------------------------------------------")
trace(this._name);
trace("n= "+n);
trace("the value of N in the array is "+myArray[n]);

//getURL(myArray[n], "_blank");
};
}

If Loop/delaying GetURL Command
Hi

I am currently working on a Flash/HTML hybrid site, where the navigation affects something in the swf (in this case an animation) and also passes a getURL command to the browser.

The problem I am having is that when viewing just the swf everything works fine, but when I ask the button to pass the getURL command the animation runs a bit jerky.

I was wondering if it would be possible to delay the getURL command until the animation has finished, in the hope that this will result in the animation running smoothly?

To make things clearer, here are some links:

Just animation
http://www.junction36.com/clients/k..._hz_zoomer.html

Animation + guetURL
http://www.junction36.com/clients/k...mer_iframe.html

Does anyone have any suggestions? Do you think delaying the getURL until the image is in position would help?

Many thanks
Matt

GetURL + Array
Hi,

By clicking a button I am trying to load an url from an array. My code is:


Code:
var link = new Array('http://www.kathleengouwy.be', 'http://www.iguane.be');
for (i=0; i<11; i++) {
attachMovie("button_","button_"+i,10+i);
shot = this["button_"+i];
shot._x = 115+50*i;
shot._y = 25;
shot.id = i;
shot.onRelease = function(){
xMove = shot._x;
picture._alpha = 0;
trace(link[this.id])
knopke.onRelease = function() {
trace(link[this.id])
getURL(link[this.id]);
}
picture.loadMovie(image[this.id], 1);
desc_txt.text = description[this.id];
}
}
The problem (probably a path problem?) is this one:

Code:
knopke.onRelease = function() {
trace(link[this.id])
getURL(link[this.id]);
}
I am actually very proud already on writing this code so far , but I really don't see what I am doing wrong with the button thing, so any help is welcome! I guess I cannot use "this" ... but what do I use then?

v.

Array/getURL Help
I am creating an automated schedule. I can't seem to assign the correct showurl to the onRelease function. It shows up as undefined. And if i put it as a variable, it only remembers the last url in the array.

Basically, i have it generating and naming 6-7 movieclips depending on the xml file and i want to assign their respective URL when a user clicks thru.

Can someone help me, please?


//-----------------------
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
showdate = [];
showtime = [];
showlength = [];
showtitle = [];
showurl = [];
episodetitle = [];
episodeurl = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
showdate[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
showtime[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
showlength[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
showtitle[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
showurl[i] = xmlNode.childNodes[i].childNodes[4].firstChild.nodeValue;
episodetitle[i] = xmlNode.childNodes[i].childNodes[5].firstChild.nodeValue;
episodeurl[i] = xmlNode.childNodes[i].childNodes[6].firstChild.nodeValue;
}
mainSchedule();
} else {
content = "file not loaded!";
}
}


xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("schedule.xml");


function mainSchedule() {
if (loaded == filesize) {
for (var i=0; i<total; i++) {
_root["show" + i].mc_time.text = showtime[i];
_root["show" + i].mc_show.text = showtitle[i];
_root["show" + i].mc_episode.text = "Episode:";
_root["show" + i].mc_episodename.text = episodetitle[i];
_root["show" + i].mcClick1.onRelease = function() {
getURL(episodetitle[i]);
}
}


}

}
stop;

GetURL From Xml Array
i am still learning actionscript and i am tryin to make a dynamic xml menu. i have stored the url links in the xml file, but i cannot get the getURL function to work. can anyone give some advice. thanks!


Code:
var menuXML:XML = new XML();
menuXML.ignoreWhite = true;
menuXML.onLoad = loadXML;

function loadXML(success) {

spacing = 120;
if (success) {
xmlNode = this.firstChild;
menu = [];
url = [];
total = xmlNode.childNodes.length;



for (i=0; i<total; i++) {
menu[i] = xmlNode.childNodes[i].attributes.title;
url[i] = xmlNode.childNodes[i].attributes.url;

newBut = menuHolder.attachMovie("button", "but"+i, i);

newBut._x = (i*spacing);

newBut.menu_txt.text = menu[i];

_parent["but"+i].onRelease = function() {
getURL(url[i]);
};
}

}
}

menuXML.load("menu.xml");

Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<buttonmenu>

<menu title = "HOME" url = "http://www.home.net"></menu>

<menu title = "ABOUT" url = "http://www.google.com"></menu>

<menu title = "CONTACT" url = "http://www.cnn.com"></menu>

<menu title = "NEWS" url = "http://www.abc.com"></menu>

<menu title = "HISTORY" url = "http://www.123.com"></menu>

<menu title = "EXTRAS" url = "http://www.xyz.com"></menu>

</buttonmenu>

GetURL Via Array Problem
I'm storing data in a 2D array using a loop to search through the array and find specific parameters depending on what the user selects, and then creating objects on the stage. so far I have accomplished all of that except I can't get the objects on the stage to getURL properly.


Code:
arrImages = [

arrImage1 = ["Santa Barbara County", "Beach", "Palm Trees", "Image1", "Shadow", "Link", "http://www.iluvsocal.com"],
arrImage2 = ["Santa Barbara County", "Beach", "Palm Trees", "Image2", "Shadow", "Link", "http://www.printroom.com/ViewGalleryPhoto.asp?userid=iluvsocal&gallery_id=702310&image_id=1"],
arrImage3 = ["Orange County", "Beach", "Sunsets", "Image3", "Shadow", "Link", "http://www.foamsweetfoam.com"],
arrImage4 = ["Orange County", "Beach", "Sunsets", "Image4", "Shadow", "Link", "http://www.foamsweetfoam.com"],
arrImage5 = ["Orange County", "Beach", "Sunsets", "Image5", "Shadow", "Link", "http://www.foamsweetfoam.com"],
arrImage6 = ["Santa Barbara County", "Beach", "Palm Trees", "Image2", "Shadow", "Link", "http://www.foamsweetfoam.com"],
arrImage7 = ["Orange County", "Beach", "Sunsets", "Image7", "Shadow", "Link", "http://www.foamsweetfoam.com"],
arrImage8 = ["Orange County", "Beach", "Sunsets", "Image8", "Shadow", "Link", "http://www.foamsweetfoam.com"],
arrImage9 = ["Orange County", "Beach", "Sunsets", "Image9", "Shadow", "Link", "http://www.printroom.com/ViewGalleryPhoto.asp?userid=iluvsocal&gallery_id=702310&image_id=1"]

];

//End Image Arrays

//Seach function

function search(){
Position = 100;
trace(arrImages[i][3]);
k=k+1;
if(k<4){
_root.Images.attachMovie(arrImages[i][3], arrImages[i][3], i, {_x:Position*k + 10, _y:10});
_root.Images.attachMovie(arrImages[i][4], arrImages[i][4], i-1000, {_x:Position*k + 15, _y:15});
_root.Images.attachMovie(arrImages[i][5], arrImages[i][5], i+1000, {_x:Position*k + 10, _y:10, _alpha:0});
_root.Images["Link"+k].onPress = function(){
getURL(arrImages[k][6], "_blank");
}
if(k>=4 && k<8){
_root.Images.attachMovie(arrImages[i][3], arrImages[i][3], i, {_x:Position*k - 390, _y:200});
_root.Images.attachMovie(arrImages[i][4], arrImages[i][4], i-1000, {_x:Position*k - 385, _y:205});
_root.Images.attachMovie(arrImages[i][5], arrImages[i][5]+k, i+1000, {_x:Position*k - 390, _y:200, _alpha:0});
_root.Images["Link"+k].onPress = function(){
getURL(arrImages[k][6], "_blank");
}
}
if(k>=8 && k<12){
_root.Images.attachMovie(arrImages[i][3], arrImages[i][3], i, {_x:Position*k - 790, _y:390});
_root.Images.attachMovie(arrImages[i][4], arrImages[i][4], i-1000, {_x:Position*k - 785, _y:395});
_root.Images.attachMovie(arrImages[i][5], arrImages[i][5]+k, i+1000, {_x:Position*k - 790, _y:390, _alpha:0});
_root.Images["Link"+k].onPress = function(){
getURL(arrImages[k][6], "_blank");
}
}
}


there is other code but basically within some if..thens I have


Code:

for(i=0;i<arrImages.length;i++){
search();
}


but the getURL always gets whatever the last array is and uses that URL for all of the buttons displayed. in this case it is arrImages[8][6] what am I doing wrong. I know the code is messy, and probably drawn out, but I'm fairly new to it. any help would be appreciated.

GetURL Via Array Problem
I'm storing data in a 2D array using a loop to search through the array and find specific parameters depending on what the user selects, and then creating objects on the stage. so far I have accomplished all of that except I can't get the objects on the stage to getURL properly.


Code:
arrImages = [

arrImage1 = ["Santa Barbara County", "Beach", "Palm Trees", "Image1", "Shadow", "Link", "http://www.iluvsocal.com"],
arrImage2 = ["Santa Barbara County", "Beach", "Palm Trees", "Image2", "Shadow", "Link", "http://www.printroom.com/ViewGalleryPhoto.asp?userid=iluvsocal&gallery_id=702310&image_id=1"],
arrImage3 = ["Orange County", "Beach", "Sunsets", "Image3", "Shadow", "Link", "http://www.foamsweetfoam.com"],
arrImage4 = ["Orange County", "Beach", "Sunsets", "Image4", "Shadow", "Link", "http://www.foamsweetfoam.com"],
arrImage5 = ["Orange County", "Beach", "Sunsets", "Image5", "Shadow", "Link", "http://www.foamsweetfoam.com"],
arrImage6 = ["Santa Barbara County", "Beach", "Palm Trees", "Image2", "Shadow", "Link", "http://www.foamsweetfoam.com"],
arrImage7 = ["Orange County", "Beach", "Sunsets", "Image7", "Shadow", "Link", "http://www.foamsweetfoam.com"],
arrImage8 = ["Orange County", "Beach", "Sunsets", "Image8", "Shadow", "Link", "http://www.foamsweetfoam.com"],
arrImage9 = ["Orange County", "Beach", "Sunsets", "Image9", "Shadow", "Link", "http://www.printroom.com/ViewGalleryPhoto.asp?userid=iluvsocal&gallery_id=702310&image_id=1"]

];

//End Image Arrays

//Seach function

function search(){
Position = 100;
trace(arrImages[i][3]);
k=k+1;
if(k<4){
_root.Images.attachMovie(arrImages[i][3], arrImages[i][3], i, {_x:Position*k + 10, _y:10});
_root.Images.attachMovie(arrImages[i][4], arrImages[i][4], i-1000, {_x:Position*k + 15, _y:15});
_root.Images.attachMovie(arrImages[i][5], arrImages[i][5], i+1000, {_x:Position*k + 10, _y:10, _alpha:0});
_root.Images["Link"+k].onPress = function(){
getURL(arrImages[k][6], "_blank");
}
if(k>=4 && k<8){
_root.Images.attachMovie(arrImages[i][3], arrImages[i][3], i, {_x:Position*k - 390, _y:200});
_root.Images.attachMovie(arrImages[i][4], arrImages[i][4], i-1000, {_x:Position*k - 385, _y:205});
_root.Images.attachMovie(arrImages[i][5], arrImages[i][5]+k, i+1000, {_x:Position*k - 390, _y:200, _alpha:0});
_root.Images["Link"+k].onPress = function(){
getURL(arrImages[k][6], "_blank");
}
}
if(k>=8 && k<12){
_root.Images.attachMovie(arrImages[i][3], arrImages[i][3], i, {_x:Position*k - 790, _y:390});
_root.Images.attachMovie(arrImages[i][4], arrImages[i][4], i-1000, {_x:Position*k - 785, _y:395});
_root.Images.attachMovie(arrImages[i][5], arrImages[i][5]+k, i+1000, {_x:Position*k - 790, _y:390, _alpha:0});
_root.Images["Link"+k].onPress = function(){
getURL(arrImages[k][6], "_blank");
}
}
}
there is other code but basically within some if..thens I have


Code:

for(i=0;i<arrImages.length;i++){
search();
}
but the getURL always gets whatever the last array is and uses that URL for all of the buttons displayed. in this case it is arrImages[8][6] what am I doing wrong. I know the code is messy, and probably drawn out, but I'm fairly new to it. any help would be appreciated.

.txt Variables Into Array With GetURL Support
flashers:

i have a .txt file with x number of names/http links. what i want to do is load this data into an array so that name[x] corresponds with link[x] in a simple output list. link[x], therefore, must be a button, enabling the user to click via getURL(), however, i have not been able to successfully import more than one variable from my .txt file and still have a functioning link.

is it even possible to increment a movie clip instance? for example, i have a text field variable called "text" which is placed in a button. that button is then placed in a movie clip with instance name "info." i want info to be incremented every time a new variable is loaded from the .txt file. that means if i have 50 variable (names and links), the infoArray should also have a length of 50.

any help would be more than appreciated!

thanks in advance!
-oni

GetURL From An Array Not Working...and It Gets Weirder
hello, long time lurker, first time poster here.
i'm hoping you guys can help me figure out this problem i'm having.

all right. i modified this gallery to work with textfiles.

it basically works, but i'm having issues with the getURL command.

the movie is set up in 4 frames. i load two textfiles in the first two frames, and then declare variables from stuff passed in through the url

FRAME 1

Code:
stop();
newArray = new LoadVars();
newArray.onLoad = function(success){
if (success){
myArray = this.previewImgs.split("|");
}
nextFrame();
}
newArray.load ("ebayList.txt");


FRAME 2

Code:
stop();
newArray2 = new LoadVars();
newArray2.onLoad = function(success){
if (success){
linkArray = this.links.split("|");
}
nextFrame();
}
newArray2.load ("linkList.txt");


FRAME 3

Code:
stop();
_global.totalCars = _root.number_imgs;
_global.removeThis = _root.removeThis;
_global.removeLink = _root.removeLink;
nextFrame();


so far so good. it's frame 4 i am having the problem on.
first, i remove an item from each array, since the actual thing it's for is not supposed to load an item of itself.

afterwards, more variables are declared, and a for loop starts creating movie clips and is supposed to give each a link.

FRAME 4

Code:
stop();
//remove unwanted image
for (r=0; r<(myArray.length-1); r++) {
if (myArray[r] == removeThis) {
myArray.splice(r, 1);
} else {
//nothing
}
}

//remove unwanted link
for (e=0; e<(linkArray.length-1); e++) {
if (linkArray[e] == removeLink) {
linkArray.splice(e, 1);
} else {
//nothing
}
}
numimages = myArray.length;
spacing = 310;
yspacing = 83;
for (i=0; i < numimages; i++) {
thumbHolder = container.thumbnails.createEmptyMovieClip("thumbnail"+i, i);
if ((i%2) == 0) {
thumbHolder._x = 0;
thumbHolder._y = (i-(i/2))*yspacing;
} else {
thumbHolder._x = spacing;
thumbHolder._y = (i-(Math.ceil(i/2)))*yspacing;
}
thumbLoader = thumbHolder.createEmptyMovieClip("thumbnail_image"+i, i);
thumbLoader.loadMovie("currentEbay/"+myArray[i]);
trace(linkArray[i]); //READS CORRECTLY
//create new movie and then load the thumbnails into it.
thumbHolder.onRelease = function() {
getURL(linkArray[i], "_blank");
trace(linkArray[i]); //READS UNDEFINED
}
trace(linkArray[i]); //READS CORRECTLY
}


i added comments and trace actions to show the problems. for some reason, only in that onRelease function, the links come up undefined. but when traced immediately before and after, they read correctly.

what's even weirder, is if i put a specific one, like

Code:
thumbHolder.onRelease = function() {
getURL(linkArray[4], "_blank");
trace(linkArray[4]); //READS CORRECTLY
}

it does put the link on the button, but of course, it then puts the same link on every button.

and if i trace the arrays elsewhere or trace pretty much anything anywhere but in that getURL line, it comes up right.

i have no idea what the problem is. i almost hope it's something stupid like an oversight of syntax or something.

for clarity's sake, here are the contents of the textfiles
ebayList.txt

Code:
previewImgs=id53.jpg|id72.jpg|id75.jpg|id76.jpg|id94.jpg|id98.jpg|id102.jpg|id103.jpg|id138.jpg|id139.jpg|id142.jpg|id145.jpg|id146.jpg


linkList.txt

Code:
links=http://www.midwestperformancecars.com/testTransact.php?id=53|http://www.midwestperformancecars.com/testTransact.php?id=72|http://www.midwestperformancecars.com/testTransact.php?id=75|http://www.midwestperformancecars.com/testTransact.php?id=76|http://www.midwestperformancecars.com/testTransact.php?id=94|http://www.midwestperformancecars.com/testTransact.php?id=98|http://www.midwestperformancecars.com/testTransact.php?id=102|http://www.midwestperformancecars.com/testTransact.php?id=103|http://www.midwestperformancecars.com/testTransact.php?id=138|http://www.midwestperformancecars.com/testTransact.php?id=139|http://www.midwestperformancecars.com/testTransact.php?id=142|http://www.midwestperformancecars.com/testTransact.php?id=145|http://www.midwestperformancecars.com/testTransact.php?id=146


and here is a test page so you can see it in action.
http://channelclarity.com/flashMysql/

i know it says flashMysql in the link, but that's just an old folder i used, this has nothign to do with that. you can view the source code to see the variables passed into Flash, in case that's the problem, but i don't think so.

so yeah, any help on this would be amazing. this all that's left to do for the project and it's driving me insane trying to figure out why it doesn't work when it should work.

thanks in advance,
dennis

[MX]getURL Javascript - Array Question
Hello,

I'm trying to get the code below to work, but no such luck:


ActionScript Code:
var newsAry = new Array("news/040720.html");for(i=1; i<=newsAry.length; i++) {    this["btn" + i].index = i;    this["btn" + i].onRelease = function() {         getURL("javascript:openNewWindow(" + newsAry[this.index - 1] + ",'newswin','height=400,width=450,toolbar=no,scrollbars=yes')");    }}


I'm trying to get the 'newsAry' Array to work in the javascript getURL action. When I use a regular html page in there the page works just fine. Any ideas as to what I'm doing wrong?

Foo

XML And Flash Doubt : GetURL From Array
myClip.onRelease = function() {
getURL('javascript:Open("gArray[cur]")')
};

trace (gArray[cur]) returns "mycurrentpicture.jpg"

gArray defines the colection of picture paths loaded from a XML file
cur defines the current loaded picture path from the thumbArray
"javascript:Open" opens a PopUp html window with predefined size.

I want the popUp to show "mycurrentpicture.jpg" but it doesn´t It tries to open "gArray[cur]"

How do I get this to work? Can anyone please help me?

[MX]getURL Javascript - Array Question
Hello,

I'm trying to get the code below to work, but no such luck:


ActionScript Code:
var newsAry = new Array("news/040720.html");for(i=1; i<=newsAry.length; i++) {    this["btn" + i].index = i;    this["btn" + i].onRelease = function() {         getURL("javascript:openNewWindow(" + newsAry[this.index - 1] + ",'newswin','height=400,width=450,toolbar=no,scrollbars=yes')");    }}


I'm trying to get the 'newsAry' Array to work in the javascript getURL action. When I use a regular html page in there the page works just fine. Any ideas as to what I'm doing wrong?

Foo

Getting Value From Array In For-loop
I'm trying to compare the value of a single variable against values in an array through a for loop, but for some reason the values of the array are not being returned. Here is a stripped down version of the code:

cell = "d3";
n = "1";
housing1 = new Array();
housing1.push(cell);
crap = eval("housing" + Number(n) + "[" + (Number(n)-1) + "]");
trace (crap);

without the eval() the trace shows: housing1[0] like it should. But with the eval there is nothing. It must be something simple I'm doing wrong?

Loop Through Array
I just want to keep looping through an array ot different words over and over again until I tell it to stop.

Code:
words=["the ","world ","is ","your","oyster"]
function formWords () {
if (w<=words.length) {
w++;
_root.display=words[w];
}
}
stop();
now this works when I call the function from an enterFrame but it just loops through once I want it to keep looping through this array.One other thing Does anyone know any good tutorials on arrays and on Duplication positioning . Like duplicating movie clips and then been able to place them where you want them I always have problems with both of these subjects. I have tried all the tutorials on flashkit but nothing really explains it clear.

Array (to Loop)
I've got a simple array to load mp3's and it gets to the end of the array and stops. I'd like it to keep it going on to the first mp3. I thought I had it working at one point, but can't be sure.

Code:
var song_id = -1;
var mysongs = new Array("first.mp3","second.mp3","third.mp3","fourth.mp3","fifth.mp3","sixth.mp3","seventh.mp3");

Button to load:

Code:
on (press) {
_root.myMusic.stop();
}
on (release) {

if (_root.playing!=true) {
_root.playing=true;

_root.song_id == 6;//I thought THIS
_root.song_id = 0;// would do it
} else {
_root.gotoAndPlay("getNext");
_root.preloadNow=1;
_root.song_id++;
}
_root.myMusic.loadsound(_root.mySongs[_root.song_id], true);

}


The other stuff in there is for a preloader....could any of that be screwing it up? Thanks for any tips.

Loop-y Array
Code:
_root.ringsusednow = _root.ringsused.split(",");

for (b=0; b<=(_root.ringsusednow.length); b++) {
_root.thisringnow = (_root.ringsusednow[b]);
I want the above loop to return the value of the array _root.ringsusednow as a variable _root.thisringnow this loop goes on to compare the value with something else which is why I need to loop through all the values of _root.ringsusenow. But for some reason, it's not working. I guess it has something to do with _root.ringsusednow[b] but I can't see what, and no matter what I do, I don't seem to be able to return a value.

Can someone please help me.

Thanks

Loop/s And Array/s
Hi,
I have this
code:
function CreateTable(thename, x, y, width, height, no_of_rows, no_of_columns, data, parent){
c=0;
for(i=0;i<no_of_rows;i++) {
for(j=0;j<no_of_columns;j++){
__name=thename+"_"+i+"_"+j;
parent. createTextField(__name,c++,j*width+x,i*height+y,wi dth,height);

temp=parent[__name];
temp.text=data[i][j];
temp.background=false;
temp.border=true;
}
}
}

myData=new Array(["first Value", "second one", 0000, "yes"],
["first value", "second one", 1111, "no"]);

CreateTable("MyTable", 150, 120, 100, 20, pays, 4, myData, this);
// Note that "pays" is number of monthly payment typed in payment text field


I want to make a small application that calculates loans and
interests.
The code that you saw above produce tables, but I need to
fulfill it, with dates, monthly payment etc.
So main thing is how I can embed the values inside table,
taking the fact that it need to decrease/increase
all the time, means every month payment will decrease regard
to previous month so I need minus it from Fund of loan,
as well, or another way:
fund will increase every month regard you amortize more and more
etc.
Values would be typed into input text field with vars
i.e. interest, payment etc.
Mainly I would need a simple example of doing such a staff
with arrays and loops I guess.
I have formula for computing this kind of problematic but
i cannot built in Action Script.
Thanks in advance

For Loop With Array
...hm.

Thanks for looking. I can't get this script to work:

animals = new Array();
animals[0] = "little doggies";
animals[1] = "that darn cat!";
animals[2] = "who the F likes birds?";
for (i=0; i<3; i++) {
buttonName = "button"+(i+1);
eval(buttonName).onRelease = function() {
textBox = animals[i];
};
}

The dyn text var, textBox, shows up as undefined in every instance. I've tried using eval around the animals[i] to no avail. This should be easy but I'm losing my mind over it.

A little help?!
Please.

Thanks,
1M.

Array And For Loop
I have these datas on a .txt file

PHP Code:



&d1979=r001,
&d1980=o001,
&d1981=a001,
&d1984=o002,o003,r002,
&d1985=o004,o005,o006,o007,o008,o009,r003,

...
etc etc.




i transform them in array

PHP Code:



var a1984 = d1984.split(",");
a1984.pop();




But i have a lot of these datas, so i try to make a for cycle


PHP Code:



for (var i = 1979; i<=2005; i++) {
    xxx = "d"+i;
    yyy = "a"+i;
    var yyy = xxx.split(",");
    yyy.pop();
}




but doesn't work.
for example, when i=4 i have xxx=d1984, flash don't see it like the d1984 of .txt file.
if i wr0te:
trace (xxx)
inside for cycle, i have d1979, not o002,o003,r002,

sorry for my english

Help With Array Within Loop
Hey guys i have a bit of an urgent question for yas!
Basically within a for loop i have the following statement "array[i].play();", but its not working. I thinks its because its looking for the oject called array[i] not actually inserting that varaiable. Would you have any ideas how to get around it?

Thanks heaps!

_y & _x From Mc Name In Array With While Loop
Ok gotten somewhat further again.

If I fire my weapon I place the name of the bullettrace in an array.
Now, on impact, I need the _x and _y of the bullettrace to spawn a
nice impact movieclip.

Now I can't seem to be acomplishing that. I've tried several things.
Here's one try (it's the code off a wall):


Code:
onClipEvent (enterFrame) {
a = _root.aiBullettrace.length;
i = 0;

while(i < a){
if(_root.hittesttest.hitTest(_root[_root.aiBullettrace[i]])){
with(_root.aiBullettrace[i]){
obj = new Object();
obj.y = getProperty("", _y);
obj.x = getProperty("", _x);
_root.localToGlobal(obj);
}

removeMovieClip(_root[_root.aiBullettrace[i]]);
_root.attachMovie("effect_metal_hit","metal_hit"+_root.Case_i,_root.Case_i,{_y:obj.y, _x:obj.x});
trace(obj.y+' - '+obj.x);
}
i++;
}
}


The getProperty gives the x and y of the wall. I thought it would give the x and y of the 'with'.

I've also tried stuff like _root.aiBullettrace[i]._y;
but that didn't work ofcourse.

Anyone got an idea?

Loop Add To Array
I have a loop going through an xml object called date which has 9 entries in it. What I'm trying to do is run through them and store any dates that are different.
What I want to do in the loop is only add the date once in the yearArray. So if the same date shows up it does not add it to the yearArray.

Example of how the dates would look.

2007
2007
2007
2006
2005
2007
2006
2005
2007

So my loop should only add a date once to the _yearArray. so my _yearArray for something like this would end up been

_yearArray=[2007,2006,2005];


Code:
private function getYears():Void{
_yearArray=[];

for(var i=0;i<_xml.length;i++){
var year=_xml[i].year.data;

for(var j=0; j<_yearArray.length; j++){
trace("year = "+year+" _yearArray[j] = "+_yearArray[j]);
if(year != _yearArray[j]){
_yearArray.push(year);
}
}
}
}


What am I doing wrong here?

Loop Array
The code below works great except I need it to loop.
I've been trying now for two days to get this code to loop I read about
Loops numerous times and I still can,t get it to work.
can any one help please to get this to loop

Code:
stop();
//second
var videos:Array = new Array("first.flv", "second.flv", "third.flv");
var currentVideo:Number = 0;
var duration:Number = 0;

var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
my_video.attachVideo(ns);
ns.play(videos[currentVideo]);
//----------------
this.createTextField("loaded_txt", this.getNextHighestDepth(), 40, 180, 160, 22);
loaded_txt.textColor = 255,255,255;
var loaded_interval:Number = setInterval(checkBytesLoaded, 500, ns);
function checkBytesLoaded(my_ns:NetStream) {
var pctLoaded:Number = Math.round(my_ns.bytesLoaded / my_ns.bytesTotal * 100);
loaded_txt.text = Math.round(my_ns.bytesLoaded / 1000) + " of " + Math.round(my_ns.bytesTotal / 1000) + " KB loaded (" + pctLoaded + "%)";
progressBar_mc.bar_mc._xscale = pctLoaded;
if (pctLoaded >= 100) {
clearInterval(loaded_interval);
loaded_txt.removeTextField();
}
}
//-----------------

ns.onMetaData = function(evt:Object):Void {
duration = evt.duration;
};
ns.onStatus = function(evt:Object):Void {
if (this.time > 0 && this.time >= (duration - 0.5)) {
currentVideo++;
if (currentVideo < videos.length) {
ns.play(videos[currentVideo]);
} else {
delete this.onStatus;
}
}
}
Happy New Years everone
p.s. Yes I'm an addict, I love Flash so much I'm coding on New Years day

Loop Or Array
Can someone help out? I have read several threads here and I can not figure out how to get my text file variables displayed in a single text box. Is this possible?

my latest code was borrowed from a thread here but dosn't funtion the way I thought it would. It only displays the last variable,number 30 and I see why now but I would like to concatenate each group (name+dates+footnote) and if possible add some html code maybe (<p class='name'> "deputydirectorname"+i] </p>........> )

Possible or should I just reformat the text files that were provided????

////
fileData.onLoad = function(success) {
if (success) {
trace("Loading Deputy Directors HTML OK!");
for (i=1; i<=30; i++) {
this["deputydirectorname"+i] = this["deputydirectorname"+i];
trace(this["deputydirectorname"+i]);
body_txt.htmlText=this["deputydirectorname"+i];
}

sample of test data:
&deputydirectorname1=<b>Cassius James Van Slyke, M.D.</b>
&deputydirectordate11=December 3, 1958
&deputydirectordate12=December 1, 1959
&
&
&deputydirectorname2=<b>David E. Price, M.D.</b>
&deputydirectordate21=July 1, 1960
&deputydirectordate22=June 30, 1962
&

How I would like it to look....

Cassius James Van Slyke, M.D.
December 3, 1958 - December 1, 1959
Footnote if any

Any insight/help is appreciated!
Thanks
Ed

XML/ Array Loop?
Does anyone know of a good resource/tutorial to explain how to take an XML list (in my case for a photo gallery) & parse it into an array in Flash?

My current snag is that I have created an XML photo gallery using a tutorial but when I get to the last picture in my XML list my next_btn doesn't know to go back to the first picture in my list (and visa-versa from the first to the last when using my previous_btn)


I did get a little help already but wanting to know if there is any easy code that will do the job... so far I have the following code referring to my buttons:

listen = new Object();
listen.onKeyDown = function() {

if (Key.getCode() == Key.LEFT) {

prevImage();

} else if (Key.getCode() == Key.RIGHT) {

nextImage();

}

};
Key.addListener(listen);
previous_btn.onRelease = function() {

prevImage();

};
next_btn.onRelease = function() {

nextImage();

};

Array/for Loop Help
I am trying to create an array that will list a bunch of names in a given area. and each name needs to have a specific pop up html file. so far I can only get it to pop up as the ordered number in the list. What im hoping to do it have it pop up with the name of the person.html - not the number of where it is located in the list. For example, say i have a list of names: bob smith, jane do, sam rubin, rob thomas. with the code I am using now, each name pops up as its respecitive number in the list (1,2,3,4). This is problematic because I am repeating the list of names in the background and dont want to have to go through and creat 300 pop ups for the same person. make sense? See below for the coding im using. thanks for your help!

var namesArray:Array = new Array ("bob smith","jane do","sam rubin","rob thomas");
var yVal:Number = 0;
var xVal:Number = 0;
var stageWidth:Number = 1200;
// FOR LOOP PULLS BUTTONS OUT OF LIBRARY AND PUTS THEM ON STAGE, GIVES THEM ACTIONS
for (var i:Number = 0; i < namesArray.length; i++) {
this["btn_"+i] = attachMovie ("btn","btn_"+i, this.getNextHighestDepth ());
this["btn_"+i].id = i;
this["btn_"+i].textField.text = namesArray[i];
this["btn_"+i].textField.autoSize = "left";
//this["btn_"+i].textField.wordWrap = true;
this["btn_"+i].background._width = this["btn_"+i].textField._width;
if (i == 0) {
this["btn_"+i]._x = 0;
this["btn_"+i]._y = yVal;
} else {
this["btn_"+i]._x = this["btn_"+(i-1)]._x + this["btn_"+(i-1)]._width + 2;
this["btn_"+i]._y = yVal;

if ((this["btn_"+i]._x + this["btn_"+i]._width) >= stageWidth) {
yVal = yVal + 22;
this["btn_"+i]._y = yVal;
this["btn_"+i]._x = 0;
xVal = 0;
}
}
this["btn_"+i].onRollOver = function () {
ZigoEngine.doTween(this, "_tint", "#FFFFFF", .10, "easeInQuad", .10);
}
this["btn_"+i].onRollOut = function () {
ZigoEngine.doTween(this, "_tint", "#323232", .10, "easeInQuad", .10);
}
this["btn_"+i].onRelease = function () {
trace (this.id);
getURL (this.id+".html","_blank");
}
}

Loop And Array
hi, i know very little about action script 3 and what i am trying to do used to work with action script 2 but i guess now it's little different. please if some one has any idea....

var pic_array:Array = new Array("home", "photo1", "photo2", "photo3"......) // buttons
var pic_l = pic_array:length;
var myloader:Loader = new Loader();

for (var t = 0; t<pic_l ; t++) {

this[pic_array[t]].addEventListener(MouseEvent.click, Show_image);

}

function show_image(event:MouseEvent):void {

var request1:URLRequest = new URLRequest([pic_array[t]] + ".jpg")
myloader.load(request1)
addChild(myloader);
myloader.x=36;
myloader.y=145;
}


i have buttons with the same names as in the array. and everytime i click on one of the buttons than a bigger picture of this button is loaded to the screen. i know that the buttons works fine with the loop but i just cant get the name of the button that i click into the URL request.

var request1:URLRequest = new URLRequest([pic_array[t]] // trying to get the right name from the array // + ".jpg")


pleasee helllpppp....

Array / For Loop Help
Hello, Im trying to get an array to loop within a for loop. The for loop would take information from the array then assign it to an attached MC. Im getting an error "There is no property with the name 'i'.


ActionScript Code:
//#initclip
class src.Guya {
    //Create Private Variables
   
    //MovieClip Refrences
    private var target_mc:MovieClip;
   
    //Constructor
    public function Guya(target:MovieClip) {
        target_mc = target;
        var node:Array = new Array(
                Array("helloWorld 1"),
                Array("helloWorld 2"),
                Array("helloWorld 3")
                )
        target_mc.onEnterFrame = function() {
            trace (node)
            for (i=0; i<node.length; i++) {
                var btnNameText = node[i][0];
            }
           
        }
    }
}

Array In For Loop?
Hi, anyone could help me in this?

yap, how do i make an array in a for loop? i'm suppose to make my targets move around the stage. [its done] but i'm suppose to make an array. any suggestion? datelines' here.. pls help!

Array Loop
Hey,

How can I create this by using an for-loop ?

Code:
pageOrder = new Array("page0","page1","page2","page3","page4","page5","page6","page7","page8","page9","page10","page11","page12","page13","page14","page15","page16","page17");

Array From Loop
I am starting to "get" for loops and arrays but for some reason I have a mental block with this. grrrr....

I need to generate a new array from the first loop and populate it from the nested loop. If I trace the array "aPics" it does, in fact do this on each iteration of the outter loop but I can't figure out how to save these as named arrays to use elsewhere in my script.

Any help?










Attach Code

bhr_xml.onLoad = function(success:Boolean):Void {
if (success == true) {
xnRoot = bhr_xml.firstChild;
aYears = xnRoot.childNodes;
for (var i = 0; i<aYears.length; i++) {
aYearzPubs = aYears[i].childNodes;//getting all pubs from that year
trace("i loop "+[i]+" number of this year's pubs is "+aYearzPubs.length);
for (var j = 0; j<aYearzPubs.length; j++) {
currPic_str = aYearzPubs[j].attributes.image;
aPics[j] = currPic_str;
picIndex = j;
//trace("j loop " + j + " image " + currPic_str);
}
trace(aPics);
}
}
};

Loop FLV Array
Hello

I have the following script to load multiple FLV files in an array and to play them random...The problem is that im not able to loop the array...

The script:

my_FLVPlybk.muteButton = mute;

var movies:Array = ["filmpje1.flv","test.flv","filmpje3.flv"];
var tempMovies:Array = movies.concat();
var lastMovie:String = "";

function getMovie():String
{
if(tempMovies.length==0){
tempMovies = movies.concat();
trace("--------LEEG-----------");
}
var movie:String = tempMovies.splice(Math.floor(Math.random()*tempMovies.length),1).toString();
if(lastMovie==movie){
tempMovies.push(movie);
return getMovie();
} else {
lastMovie=movie;
}
return movie;
}

onEnterFrame = function(){
trace(getMovie());
}

var listenerObject:Object = new Object();
listenerObject.complete = function(eventObject:Object) {
my_FLVPlybk.play(getMovie());
}

my_FLVPlybk.addEventListener("complete", listenerObject);
my_FLVPlybk.play(getMovie());

What do i have to add to loop the files??

And does anyone know how to rewrite the script so that i can load the FLV files from an XML file?

Thanks.

Grtz Amanda

Loop Or Array
Hi,
My question is which method to use in the following: I need to drop stones one after the other into a pond to get it filled.
Do I have to make use of an array or loop condition? I am not sure. Kindly guide me to an example where I can refer to the codes or at least gve me some starting hints.

Thank you
uxk

Loop Or Array
Hi,
My question is which method to use in the following: I need to drop stones one after the other into a pond to get it filled.
Do I have to make use of an array or loop condition? I am not sure. Kindly guide me to an example where I can refer to the codes or at least gve me some starting hints.

Thank you
uxk

Please Help With The FOR Loop And The Array..
I was trying to place some words in the Movie Clip "TextPanel" and set a
random position to each of them.
But it's not working.

1) I created a Movie Clip "word" and inside that MC I created a text field
and gave it an identifier "textFiled".
2) The linkage name for Movie Clip "word" I set to "word".
3) In the actionscript I created an Array called "aWords".
4) Then I created a FOR loop that should
place (attach) Movie Clips "word0", "word1", "word2" and "word3" to the
movie clip TextPanel, and set the textField text for each of them to the
text from the Array.

But the script attaches 4 Movie Clips with a name "Undefined", instead of 4
different names (from the Array).
What is wrong with this script?


var aWords:Array = [apple,banana,orange,mango];

for(i=0;i<aWords.length;i++){
var v = TextPanel.attachMovie("word","word"+i,i);

v.textFiled.text = aWords;

v._x = randomNumber(0,Stage.width);
v._y = randomNumber(0,Stage.height);
}



Thanks in advance

Xml Array Loop
HI All

I was wondering if you could help I have some code that im using to loop through an xml file. It seems to work fine. But when you come to the end of the Array (i.e the last image) and then scroll backwards through the images in reverse it seems to get a bit laggy. I think my code needs optimizing its a bit spagetti like.









Attach Code

var LostImages:XML = new XML();
LostImages.ignoreWhite = true;

var Urls:Array = new Array();
var Desc:Array = new Array();
var CurrentIndex:Number;
var nInterval:Number;

LostImages.onLoad = function() {
var images:Array = this.firstChild.childNodes;
for (i=0; i<images.length; i++) {
Urls.push(images[i].attributes.url);
Desc.push(images[i].attributes.caption);
}
LoadStartElements();
CurrentIndex = 0;
};

LostImages.load("lost.xml");

previous.onRelease = function() {
updateAfterEvent();
if (CurrentIndex>0) {
removeMovieClip("endMovie_mc");
nInterval = setInterval(fadeImageOut, 1, Urls[CurrentIndex]);

} else {
trace("start");
attachMovie("endMovie","endMovie_mc",this.getNextHighestDepth());
endMovie_mc.x = 40;
endMovie_mc.y = 40;
}
};

next.onRelease = function() {
updateAfterEvent();
if (CurrentIndex<=Urls.length-2) {

nInterval = setInterval(fadeImage, 0.5, Urls[CurrentIndex]);
removeMovieClip("endMovie_mc");

} else {
attachMovie("endMovie","endMovie_mc",this.getNextHighestDepth());
endMovie_mc.x = 40;
endMovie_mc.y = 40;
}
};

function fadeImage() {
holder._alpha -= 5;
if (CurrentIndex<Urls.length-1, holder._alpha<=0) {
nInterval;
clearInterval(nInterval);
CurrentIndex++;
holder.loadMovie(Urls[CurrentIndex]);
caption.text = Desc[CurrentIndex];
if (holder._alpha<=0) {
myInt = setInterval(function(){holder._alpha+=2}, 20);

} else {
clearInterval(myInt);
}
}
}

function fadeImageOut() {
holder._alpha -= 5;
if (CurrentIndex<Urls.length-1, holder._alpha<=0) {
nInterval;
clearInterval(nInterval);
CurrentIndex--;
holder.loadMovie(Urls[CurrentIndex]);
caption.text = Desc[CurrentIndex];
if (holder._alpha<=0) {
myInt = setInterval(function(){holder._alpha+=5}, 50);

} else {
clearInterval(myInt);
}
}
}

function LoadStartElements() {
holder.loadMovie(Urls[0]);
caption.text = Desc[0];
}

Using A For Loop With An Array
Ok, the issue is with the enabling of the buttons on my stage. I run a loop to deactivate them all when one is clicked, then I want to turn them back on, EXCEPT the one which was clicked. I thought I could start off with an array of MC names and simply delete them from the array. But I can't get my head around exactly how to read in the array contents as MC names...

Any help would be greatly appreciated.

Mike







Attach Code

//declare the team variables
var TeamA:Number = 0;
var TeamB:Number = 0;
var btns:Array = Array("btn1", "btn2", "btn3");

disableBtns = function () {
for (var i = 1; i<=3; i++) {
this["btn"+i].enabled = false;
}
};
//////////////////////////////////////
enableBtns = function () {
for (var i = _root.btns; i<=_root.btns.length; i++) {
this["btn"+i].enabled = true;
}
};

While Loop And Array
I'm a weakling and I can't get up.
I'm trying to play a series of movieClips in order, so movieClip2 doesn't play until movieClip1 is finished (label = "end"). I started with a three separate movieClips, each with its own listener. Because all three looked similar, I thought to save myself time by using an array and while loops. I have about ten of these movieClips total, so rather than cut and paste each individual listener and if statement, it seems like there's a better way. And you brilliant people are the folks who would know. The output I'm receving is: TypeError: Error #1006: value is not a function.

Thanks in advance for any direction.







Attach Code

var myArray:Array = new Array("mMainTitle","mSubHead","mPanel1");
var cCount:int = myArray.length;
var c:int = 0;
while (c < cCount) {
myArray[c].play();
myArray[c].addEventListener(Event.ENTER_FRAME, checkForEnd);
function checkForEnd(evt:Event):void {
var found:Boolean = false;
while (found = false) {
if (myArray[c].currentLabel == "end") {
myArray[c].removeEventListener(Event.ENTER_FRAME, checkForEnd);
c++;
found = true;
} else {
found = false;
}
}
}
}

For Loop With Array And XML Help
I have a Flash site I am developing that feeds in XML into various arrays and populates dynamic movie clips and text fields. I am having trouble making a for loop that works with my movieclips and text fields. Can anyone take a look at my code and give me some advice? I am probably only missing one step and if I can figure it out I will cut my lines of code about 10X. I have attached the fla and image files in a zip file. You can Message me if you have any questions

Thanks,
Bob

For Loop + Array
im an idiot please delete this thread

[as2] Array Loop Help
i have a number of buttons that use tweens for rollovers. instead of making a rollover function for each button, i made a generic rollover that uses an array.

everything works perfect when building the array manually, even though i forgot the quotes around each entry. adding them however, breaks it.


Code:
var adIcons_array:Array = new Array(adIconCover1, adIconCover2, adIconCover3, adIconCover4, adIconCover5);
this is the output
_level0.adIconCover1,_level0.adIconCover2,_level0. adIconCover3,_level0.adIconCover4,_level0.adIconCo ver5


i decided to make a simple loop to build the array automatically, since it is very predictable. i only have 5 here, but eventually there will be 5 groups of 12.


Code:
var adIcons_array:Array = new Array();

for (i=0; i<6; i++) {
adIcons_array[i] = "adIconCover"+i;
}
this is the output
adIconCover0,adIconCover1,adIconCover2,adIconCover 3,adIconCover4,adIconCover5

the difference is one extra entry, adIconCover0, and losing _level0.

i figure an extra entry doesn't matter much, and i understand the _level0 is basically the same as _root, so i tried adding that into the array builder, but still no luck.

Code:
var adIcons_array:Array = new Array();

for (i=0; i<6; i++) {
adIcons_array[i] = "_root.adIconCover"+i;
}
_root.adIconCover0,_root.adIconCover1,_root.adIcon Cover2,_root.adIconCover3,_root.adIconCover4,_root .adIconCover5

i finally got it to work with this, which gave me the _level0 results again.


Code:
var adIcons_array:Array = new Array();

for (i=0; i<6; i++) {
adIcons_array[i] = eval("_root.adIconCover"+i);
}
i know it's working so i should probably just be happy and continue working, but i'm hoping someone can spread some light on when to use eval, and when not to and why the quotes broke the initial array.

i found this post from a couple days back that is related:
http://www.kirupa.com/forum/showthread.php?t=302028

thank you

Array/loop Something ? (gods?)
i have this
PLEASE NOTE === "charWidth" is an array with 15 items (_width properties) previously defined.

// this positions MCs one after the other (horizontally) according to thier width.

_root[[2]]._x=charWidth[0] + charWidth[1];
_root[[3]]._x=charWidth[0] + charWidth[1] + charWidth[2];
_root[[4]]._x=charWidth[0] + charWidth[1] + charWidth[2]+charWidth[3];


I need to do this all the way to _root[[ 15 ]] and I know it can be done easier and more elegantly than this. . .

How coul I use a for loop, or something like that. . .

any thoughts??

thanks
darin

Another Array Question? A Loop
hello,

Please tell me why the below code does not work?

onClipEvent (load) {
myMonths="January, February, March, April, May, June, July, August, September, October, November, December";
myArray=myMonths.split(",");
for (var t = 0; t <= myArray.length; ++t) {
eval("Var"+t) = myArray[t];
}
}
trace (Var0)
trace (Var1)

Help With My Code(array Loop Nav)
hi,
looking for a little insight on how to have my navaigation buttons stay on when the root is on that frame label.
six buttons turned into six _mc on/off frame inside nav_mc on main timeline

Do I need to flag the release of the button to
the function or something? thanks

flagOn = true; ??

///nav function

function jump(label) {
_root.gotoAndPlay(label);
_root.bio.gotoAndStop("off"); //ignore
}


/// switch this is the function on the main timeline 1 frame

function turnOff(leaveOn) {
// trace(leaveOn);
var menu = ["yellow", "green", "blue", "purple", "red", "orange"];
for (var i = 0; i<menu.length; i++) {
if (_root.nav.menu[i] != leaveOn) {
leaveOn.gotoAndStop("off");
} else {
_root.nav.menu[i].gotoAndStop("on");
// if(_root.nav.menu[i] != leaveOn)
}
// trace(menu[i]);
}
}


///this is the code on each of the buttons inside the nav_mc on the main timeline

on (release) {
_root.turnOff(this); ///switch call
_root.jump("about"); /// nav call
}

///path _root.nav.button_mc.button

Populating An Array With Loop
Hey guys, here is the deal. I am having hard time populating myArray with for loop. This is what i need to accomplish

myArray = new Array();
for (i=0;i<25;i++){
/* how to make it add new value to myArray every time it goes through the loop*/
myArray = ????
}

at the end i need myArray(1,2,3,4,5,6,.......)

thanks

Help With For Loop And Array Push
Hello, I am new to actionscript, and am trying to get the following code to work to push items from muliple MenuName variables into the MenuArray. I have done trace() to check that all the variables get properly loaded, and everything is working great, until it gets to the for(){}, then it just skips over it and goes on. I will attach the .fla I am working with. By the way, I am using MX.

if (LOADED == "OK") {
MenuArray = new Array();
for (i = 0; i < counter; i++) {
trace("i: " + i); // does not output anything
MenuArray.Push(eval("MenuName" + i));
}
gotoAndStop(3);
}
else {
gotoAndPlay(1);
}

Thank you in advance for any help!

Copyright © 2005-08 www.BigResource.com, All rights reserved