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








[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




KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 08-10-2004, 10:15 AM


View Complete Forum Thread with Replies

Sponsored Links:

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.

View Replies !    View Related
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;

View Replies !    View Related
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>

View Replies !    View Related
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

View Replies !    View Related
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.

View Replies !    View Related
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.

View Replies !    View Related
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

View Replies !    View Related
.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

View Replies !    View Related
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

View Replies !    View Related
[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

View Replies !    View Related
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?

View Replies !    View Related
Array, Array HELP - Importing A External File Into N ARRAY - Almost There
I am reading and external file with the following code:

ActionScript Code:
on (release, keyPress "<Enter>") {
lv = new LoadVars();
lv.onLoad = function() {
questions1 = this.filelist0.split(",");
answers1 = this.filelist1.split(",");
for(i=0;i<questions1.length;i++)
//trace(questions1[i]+"   "+answers1[i]);
trace(questions1[i]);

//assumes same number of scores in each list
};
lv.load("questions.txt");
}


When I parse the file it puts it into an columar format as it should...however I need it to look like this:

questions1=new Array ("2+4=?","What is the capital of Illinois?","What color is the sky?","10x(5+2)=?");

answers1=new Array ("8","springfield","blue","70");


How do I do that?

Text file look like this:

&questions1=2+4=?,What is the Capital of Illinois?,What color is the sky?,10x(5+2)=?")&
&answers1=8,springfield,blue,70&

View Replies !    View Related
GetURL Or Not GetURL That Is The Question ...
Hi, please bear with me as I'm not a Flash programmer so am stumbling around here.

I have a SWF which uses a GetURL to pass a variable into the address bar. The problem is the variable it needs to pass is required by the existing form the SWF is embedded on. For reasons I won't bore you with I can't simply reload the form etc so the problem is of course GetURL opens a new page and in so doing loses the form I need the variable to be passed in to.

My question is this therefore - is there an equivalent command like geturl which puts a value in the url bar but DOESN'T activate it i.e. as if you didn't hit go/return in the browser OR a way to stop getURL from loading the "new" page?

Hope this makes sense and thanks in advance for any help ...

View Replies !    View Related
Pls Help: Need To Create New Array Taking 3 Random Entries From An Existing Array
Hello

I have a 2d array:

qTeeth[1] = [How many teeth do we have?, 1-10, 11-20, 21-30, 11-20]
etc.

It goes [question, option1, option2, option3, real answer]

I now just want to extract 3 or so of these entries and create a new array with them. Since I want to just use 3 or so questions randomly from a large array of questions.

Does anyone know a good tidy script to do this with??


Thanks in advance,
Ben.

View Replies !    View Related
If I Type Array[1]=array[2] Their Values Are Permanently Linked. How Do I Change This
e.g.

Code:
array[2][0] = 4;
array[1] = array[2];
array[1][0] = array[1][0] + 3;

trace("array[1]= " + array[1]);
trace("array[2]= " + array[2]);


Result:
array[1]=7;
array[2]=7;


The result I want is:
array[1]=4;
array[2]=7;




How do I achieve this?

View Replies !    View Related
Array Text Into Textfield And Creating New Line For Each Array Element
I have an array called dropTarg1 which stores dropped-in items.

I want to loop through this array and in a textfield, display each array item on a new line of this text field

I think I need to use something like Array.join("/n") but I can't get it working properly. I hope that the /n would create a new line of the text field called reviewBoxContentText.

for(var i:Number = 0; i<dropTarg.length; i++){
with(reviewBoxContent.reviewBoxContentText){
autoSize = true;
text = dropTarg1.join("/n");
}
}

All that is happening though is that the text field displays on a single line with /n in between each array element.

View Replies !    View Related
Calling A Function With An Array Variable As Arguments Is Resetting Array?
I'm going to post the full code of the two functions, disregard the "fluff" unrelated to the two functions as it is all working flawless, I've tested this HEAVILY and cannot understand why it keeps setting the entire array to undefined!

Any help would be grateful.

ActionScript Code:
// processReplace Function    function processReplace(transferFiles) {        var processArray:Array = transferFiles.slice();        var fileName:String = new String();        var filesArray:Array = new Array();        var replaceArray:Array = new Array();        var exists:String = new String();        var error:String = new String();        var promptResult:String = new String();        // Check        for (i=0; i<processArray.length; i++) {            // This is where it bugs up            <b>exists = processSearch(transferFiles[i][1]);</b>             if (exists == "replace") {                replaceArray.push(processArray[i]);            } else {                filesArray.push(processArray[i]);            }        }        // Prompt        if (replaceArray.length>0) {            error = "Replace "+replaceArray.length+" item(s):

";            for (i=0; i<replaceArray.length; i++) {                error += " - "+replaceArray[i][1]+"
";            }            promptResult = mSystem.messageBox(error, "Replace Existing Files?", 4);        }        // Action                  if (promptResult == "NO") {            transferFiles = filesArray;        } else if (promptResult == "YES") {            transferFiles = filesArray.concat(replaceArray);        }        processTransfer(transferFiles);    }

The processSearch

ActionScript Code:
// == processSearch Function    function processSearch(sentInfo) {        for (i=0; i<_global.boxFiles.length; i++) {            if (_global.boxFiles[i] == sentInfo[1]) {                return "replace";                break;            }        }    }

Basically it's supposed to check to see if the file exists and return as true if it does and add it to a replace array, then the replace array is processed into a single string and put into a dialog box through the flash wrapper prompting them to "replace the files or not".

It makes the replace array just fine, it actually even has the right "count" in it but it's setting all the "filenames" to undefined because of the exists = processSearch function.

I even tried to make a new array and run the search just from that one and set the values from the old one and it's still failing.

Is it because of the "break" or can anyone figure it out? Iknow it's hard because you can't use the code

ANY Solution ideas are welcome, even if you think it's dumb

Thanks!

View Replies !    View Related
Dynamic Array/change Array Size At Run Time
how can i make a dynamic array
so i can change its size at run time
add and delete values fom the array
and his size will change as needed
10X
peleg

View Replies !    View Related
Array.splice Works But Array.slice Doesnt?
This should be simple enough. I have an array of objects, and I want to SLICE a piece of the array and assign it to a new array. All of my attempts have failed. SPLICE works, and I could duplicate my original array into a temp array and splice out what I want, but surely slice is supposed to save me this trouble, right?

I'm a bit baffled, but here's the code:


Code:

private function createGlist() {

var glistObj:Glist = this;

xml_object = new XML();
xml_object.ignoreWhite = true;

xml_object.onLoad = function(success:Boolean):Void {
if(success) {
var i:Number = 0;
for (var this_node = this.firstChild.firstChild; this_node != null; this_node = this_node.nextSibling) {
glistObj.thumb_array.push(new Gthumb(glistObj, glistObj.thumb_array_mc.getNextHighestDepth(), this.firstChild.childNodes[i]));

i++;
}

var load_start:Number = 2;
var load_count:Number = 2;
glistObj.thumb_load_array = glistObj.thumb_array.slice(load_start,load_count);
trace(glistObj.thumb_load_array); //no result, no error
trace(glistObj.thumb_array.slice(load_start,load_count)); //no result, no error
trace(glistObj.thumb_array.splice(load_start,load_count)); //outputs [object Object],[object Object]
} else {
//error
}
}

xml_object.load(xml_url);
}

View Replies !    View Related
Array Copy Points To Original Array Instead Of Duplicating
Hey all.
Spent a long time trying to figure out what was wrong with my code. Then I remembered about arrays being objects instead of primitive variables. My question is, how can I make a duplicate copy of an Array?

Details:

So this code

PHP Code:




package{
    import flash.display.*
    public class tester extends MovieClip{
        var a:Array = [1,2]
        public function tester () {
            var b = a
            trace (a)
            b.splice(1,1)
            trace (a)
        }
    }
}







results in this output:

PHP Code:




1,2
1







How can i make b an actual duplicate of a, instead of a pointer?

PHP Code:




b = new Array
b = a






doesn't work either.
Thanks!
DHP

View Replies !    View Related
Creating Multi-dimentional Array From Single Array
I have an array

myArray=[hello,bye,fred,1,2,3,4,5,6];

I need to convert it to a multi-dimentional array that would look something like below

array1=[hello,bye,fred];
array2=[1,2,3];
array3=[4,5,6];

newArray=[array1, array2,array3];

I am not sure how to split the array can anyone help? myArray.length/3 would give me the number in each of the new arrays but I am puzzled after this?

View Replies !    View Related
Associating Array Elements With Another Array Keeping The Order.
hi, i have already posted this problem yesterday but i haven't solved it yet.
i have two arrays:

array_1[a,b,c,d]
array_2[01,02,03,04]

the first array represents mcs in my stage - the buttons of the menu.
the second represents other mcs, containing some text.

when i rollOver each element of array_1 i would like to show each element of array_2 in the same order and hide it when i rollOver another menu button to show a new one.

I mean, it always has to be showing a with 01, b with 02, c with 03...

any suggestions?

View Replies !    View Related
Array Of Movie Loaders/array Of Image Files
Alright. I'm fairly new to Actionscripting, so if we can somewhat lame out the tech talk to mild to medium I'd appreciate it. what I am trying to do is create an swf movie that will interact with a PHP script. first lets start with saying the PHP script reads the directory that it is currently in and filters out any file that is not a GIF,PNG, or JPG and then it suffes all of this into a URL encoded string and the directory path ,such as :

?pictures=image1+image2+image3+image4&path=http://servername/directoryPath

now i have flash load the variables "pictures" and split the images and stuff those into an array and the directory path of course stays in its own seperate variable. ive gotten this far with no problems.

so what im trying to do now with this info is create a bit of a slide show. I want to take the array of pictures and load those into an empty movie clip displaying each picture consecutively. Ive made several attempts but no such luck. Ive tried to use a for() loop to cycle through the array of pictures loading them into the empty clip. im still very new and rather lost with these objects and class use i. Im sure im probably not using a listener of somesort that i need and what not. I am sorry i am probably not giving enough info for all this. the whole idea of this clip is to be able to display an indefinite amount pictures , so the flash player will not know ahead of time how many pictures till the php script has sent all the names of what is in the directory. this movie needs to be able to dynamically load any images that are in that directory.so any suggestions on what i can do with an array an an empty clip? thank you to anyone who can make suggesions.

View Replies !    View Related
How Do I Lope Through Array, Delete Clip And Remove From Array
I have a function that creates an instance of a movieClip and adds it to an array.

In my gameloop I loop through the array and change some values. Now I want a cleanup function that loops through the array, and if the y value exceeds a certain value, I want to delete the clip instance and remove the record in the Array.

Could someone please help me with the syntax for that? I will lay the code out below.

Thankyou







Attach Code

var myClipArray = new Array();

public function createClipInstance() {
var myClipInstance:myClip = new myClip();
myClipInstance.y = 0;
addChild( myClipInstance );
myClipArray.push(myClipInstance);
}


// loop through array and check y value
// if y > 400: Delete clip and remove from array



public function cleanClips() {
for (var n:int = 0; n<myClipArray.length; n++){
if (myClipArray[n].y > 400) {

// DELETE CLIP AND REMOVE FROM ARRAY

trace("this is where I need help");
}

}
}

View Replies !    View Related
Generate Random Value From Array 'excluding' The Current Array Value
getting my head round flash (sorta!)...

ok, nearly got this working; i have 11 movie clips on the root timeline and a empty controller movie. what i need to happen is for a random movie clip to play. when it reaches a point in it's own timeline, it sets the playNext variable to true and the controller movie clip works out the next random movie to play.

the problem comes when the controller 'randomly' picks the movie clip thats already playing! then the whole thing breaks...

is there a way that i can say 'generate me a random clip to play from this array 'excluding' the currently playing movie clip'?

any suggestions would be grand.

this is what i have on my controller clip:

onClipEvent (load) {
//define a new array
video_array = new Array();
//list each of the videos
video_array[0] = "zero";
video_array[1] = "one";
video_array[2] = "two";
video_array[3] = "three";
video_array[4] = "four";
video_array[5] = "five";
video_array[6] = "six";
video_array[7] = "seven";
video_array[8] = "eight";
video_array[9] = "nine";
video_array[10] = "ten";
//this is the count of how many elements (videos) are in your array
max = video_array.length;
//set the playNext to true
_root.playNext = true;
}
onClipEvent (enterFrame) {
//if playNext is true
if (_root.playNext) {
//generate a new random video to play
randomNumber = Math.floor(Math.random()*max);
//store the name
randomVideo = video_array[randomNumber];
//tell that video to play
_parent[randomVideo].gotoAndPlay(13);
//record the video we are playing
crntVideo = randomVideo;
//set playNext to false
_root.playNext = false;
}
}

View Replies !    View Related
Load Xml Images-->Array-->Duplicate Array: AHAA
Hello Kirupians!
[Summary]
I want to load images from an XML, then store the images inside an array, then duplicate that array into other clone arrays so that I can addChild() copies of the images into stage whenever i want (and be able to change their properties).
Basicly i have to create two duplicates; big_img and icon_image

[SYMPTOMS]
Everything is loaded fine;the big_imgloads and positions correctly, but, when i try to load icon_image the first big_img disappears! as if the new array has hasn't duplicated the original array (as if it's only a shortcut, not a real copy).

The cody thing:

ActionScript Code:
// total images read from XMLvar axiLength=Accessoir.length();// main image container arrayvar axxARR:Array = new Array();// add images to arrayfor (var k=0; k<axiLength; k++) {    var axxLoader:Loader = new Loader();    axxLoader.load(new URLRequest(Accessoir.PHOTO.text()[k]));    axxARR.push(axxLoader);    axxLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, axxLoaded);}function axxLoaded(e:Event):void {    // show big image    if (axiLength==axxARR.length) {        axxShow(0);    }}function axxShow(ID_AXX:Number) {    // duplicate images array    var axxImage:Array=axxARR.concat(axxARR);    // reposition it    axxImage[ID_AXX].x = product_details_swf.axx.x+(axxImage[ID_AXX].width/2)-5.5;    // Add init image to accessoires    axxImage[ID_AXX].name="axxImage";    product_details_swf.axx.addChild(axxImage[ID_AXX]);}// here i got an event listner to a button, once rolle over is triged it // should make small copies of the whole array images and put them on stage//....function rollover_button(ID_AXX:Number) {    for (var i=0; i<axiLength; i++) {        axxCreate(i);    }    function axxCreate(ID_AXX:Number) {        var axxPic:Array=axxARR.concat();        imageResizer(axxPic[ID_AXX], 50, 50);        axxPic[ID_AXX].name="axxPic_"+ID_AXX;        axxPic[ID_AXX].x=product_details_swf.axx.getChildByName("axxBG_"+ID_AXX).x+axxPicSpacingX;        axxPic[ID_AXX].y=product_details_swf.axx.getChildByName("axxBG_"+ID_AXX).y+axxPicSpacingY;        product_details_swf.axx.addChild(axxPic[ID_AXX]);    }}


[MORE INFORMATION]
I tried array duplication using; concat and slice but not work, it doesn't creat copies of the orriginal array, but just a shortcut to it!

thanx for any tips!

View Replies !    View Related
Generate Random Value From Array 'excluding' The Current Array Value
getting my head round flash (sorta!)...

ok, nearly got this working; i have 11 movie clips on the root timeline and a empty controller movie. what i need to happen is for a random movie clip to play. when it reaches a point in it's own timeline, it sets the playNext variable to true and the controller movie clip works out the next random movie to play.

the problem comes when the controller 'randomly' picks the movie clip thats already playing! then the whole thing breaks...

is there a way that i can say 'generate me a random clip to play from this array 'excluding' the currently playing movie clip'?

any suggestions would be grand.

this is what i have on my controller clip:

onClipEvent (load) {
//define a new array
video_array = new Array();
//list each of the videos
video_array[0] = "zero";
video_array[1] = "one";
video_array[2] = "two";
video_array[3] = "three";
video_array[4] = "four";
video_array[5] = "five";
video_array[6] = "six";
video_array[7] = "seven";
video_array[8] = "eight";
video_array[9] = "nine";
video_array[10] = "ten";
//this is the count of how many elements (videos) are in your array
max = video_array.length;
//set the playNext to true
_root.playNext = true;
}
onClipEvent (enterFrame) {
//if playNext is true
if (_root.playNext) {
//generate a new random video to play
randomNumber = Math.floor(Math.random()*max);
//store the name
randomVideo = video_array[randomNumber];
//tell that video to play
_parent[randomVideo].gotoAndPlay(13);
//record the video we are playing
crntVideo = randomVideo;
//set playNext to false
_root.playNext = false;
}
}

View Replies !    View Related
Copying Loaded Array Into A Local Array
I'm loading an array through loadVariablesNum (into level 0). The script properly returns array values... I've checked by using text boxes on my stage. But, when I try to store the loaded array within a local Actionscript array for manipulation, it doesn't seem to be able to read the loaded values. It's as if the stage and the frame Actionscript were independent of each other. Can anyone help?

Thanks

View Replies !    View Related
Inserting An Array Into An Array To Make It Multidemensional
hi there,
Using an ASP script I've managed to get strings into flash
at the moment the strings come in like this:

array1=data1,data2,data3,data4,data5
array2=celeb1,celeb2,celeb3,celeb4,celeb5

currently I'm doing this:

webfoldercontents = new Array();
webfoldercontens = websubfolders.split(",");

which creats a 2d array. what I need is this:

multidemesionalarray = [array1[array2]]

any help v.appreciated!

Danny

View Replies !    View Related
Saving An Array Then Importing Saved Array?
I am creating a kids activity. At the moment I am working on the stamp tool that allws them to stamp a shape in different colours over the canvas... this is working fine, however I need to track the position and colour (and maybe more later) so that the child can save the activity and go back to it later.

So far I have managed to create an array for each propery (_x position, _y position and colour) in seperate arrays as a new stamp is attached it is given a number (1,2,3,4...) and in each array entry of that number are the position or colour properties. When I save these arrays (using FSCommand in Flash5) I think thay form a string in the text document.

When I loads the array from the text document, that looks like this:

&colourArray=255,255,255,16711680,16711680,1671168 0,16711680,16711680,16711680,16711680&XposArray=23 3,420.95,389,262,556.95,674.95,619.95,481.95,458.9 5,280&YposArray=109,167,313,211,301,158,80,105,174 ,451.95

I cannot pull out the data from the arrays (colourArray[2] traces as undefined) What I want to do is a loop based on the lenght of one the arrays that attaches the stamp MC in the correct position and colour.

Hope someone can shed light on this for me... I think I need to find a way to convert the text file data from a string to an array?!?

Cheers
Oll

View Replies !    View Related
Copying Array Inside Array Of Arrays
Hi,

I've got an array made up of other arrays, and I need to copy one of the arrays to a tempory array (so i can copy it)

I've tried using...

TempArray = ArrayList[0].splice();

but TempArray just shows (in debugger) as undefined, any idea's??

thanks

phil.

View Replies !    View Related
Tracing An Array :: Sending Array Through JS Proxy
Correct me if I'm wrong, but I thought when you traced an Array, the output was [object]. For example:
code:
var x = new Array();
x.push("one");
x.push("two");
x.push("three");
x.push("four");
trace(x);


Would output: [object Object], not the array as a comma delimited string, correct?

Having a problem where I'm passing an Array to a JS function throuh the JS proxy (flash-javascript kit) and JS picks it up as a string.

View Replies !    View Related
How To Duplicate Array?Array.slice() Can Not Work
I test it, and Array.slice() can not work.

var arNew:Array = new Array();
var arOld:Array = [
{checked:0},
{checked:0},
{checked:0}
];

arNew = arOld.slice();
for(var i = 0; i < arNew.length; ++ i)
{
arNew[i].checked = 1;
}

for(var i = 0; i < arOld.length; ++ i)
{
trace(arOld[i].checked);
}

It seems that "arOld" had been changed and "arNew" is not a copy of "arOld", but a reference of "arOld".

How should I copy a array?

thanks for any help

View Replies !    View Related
Given An Array Return An Array With Only Unique Elements
if i have an array of elements like 1,2,2,1,3,3,1,2,...

I want to return only

1,2,3

so to strip out duplicates, I thought this would be easy but its proving harder than I thought.
thanks

View Replies !    View Related
Filling Array - Passing Array In Function
hello

I'm trying to fill an array then pass it to a function i'm tying to do it that way
but it giving me strange results when I trace things (try it and you'll see):


Code:
////////////////// fiiling the array /////////////////
for (i=1; i<=numberof_player;i++){

pos_array = new Array(numberof_player)
pos_array [i]= i
trace("in array"+pos_array [i])
}

////////////////// pasing array in function //////////////////////



function rolldice( pos_array:Array){
trace(pos_array) /// gives 4,undefined,undefined,undefined,4
}
///////////////////////////////////////////////////////////////////
maybe i'm stupid

Thanks

T

View Replies !    View Related
Random Array, Array Name Selected Randomly
Random Array, Array Name selected Randomly

Here is the code:

var RDNumber2x:Array = [2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36, 38,40];

var RDNumber3x:Array = [3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54 ,57,60];

var RDNumber4x:Array = [4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,7 2,76,80];

var RDNumber5x:Array = [5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85, 90,95,100];

var RDNumber6x:Array = [6,12,18,24,30,36,42,48,54,60,66,72,78,84,90,96,102 ,108,114,120];

var RDNumber7x:Array = [7,14,21,28,35,42,49,56,63,70,77,84,91,98,105,112,1 19,126,133,140];

var RDNumber8x:Array = [8,16,24,32,40,48,56,64,72,80,88,96,104,112,120,128 ,136,144,152,160];

var RDNumber9x:Array = [9,18,27,36,45,54,63,72,81,90,99,108,117,126,135,14 4,153,162,171,180];

var RDNumber10x:Array = [10,20,30,40,50,60,70,80,90,100,110,120,130,140,150 ,160,170,180,190,200];

var RArray:Array = ["RDNumber2x","RDNumber3x","RDNumber4x","RDNumber5x ","RDNumber6x","RDNumber7x","RDNumber8x","RDNumber 9x","RDNumber10x"];

var RArrayBox:String;
var RArrayBoxS = 0;


RArrayBox = RArray[Math.floor(Math.random() * RArray.length)];


RArrayBoxS = RArrayBox[Math.floor(Math.random() * RArrayBox.length)];


trace(RArrayBoxS);

Heres The error:

ReferenceError: Error #1069: Property 6 not found on String and there is no default value.
at randomarray_fla::MainTimeline/randomarray_fla::frame1()

What I am trying to atchieve is randomly selecting the array name and then randomly selecting something from that array.

So I am randomly selecting from a randomly selected array

Can anyone help with my problem?

View Replies !    View Related
Assigning Array Objects To Variables In An Array
how do i take an array with objects [orange, red, yellow, green, blue] and assign them to another array 5 random variables named [Slot1, Slot2, Slot3, Slot4, Slot5]

so i can get results such as

Slot1 = color*
Slot2 = color*
Slot3 = color*
Slot4 = color*
Slot5 = color*


thanks !

View Replies !    View Related
How To Sort An Array Based On A Value Of The Objects In The Array
hi,

i have a array containing many objects like this:

arr = [{id:6,val:"bla"},{id:3,val:"bleah"},{id:10,val:"bl o"}]

now i want to sort this array based on the id values of the objects.

any ideas ?

thanks

View Replies !    View Related
Sorting A New Array From An Existing Array (emergency)
Hi

i got an existing array, main[y], which after an equation, will come out with another array.


Code:
if (main[y] === topicList.getValue()){
subTopic = [];
subTopic = fTitle[y]
trace(subTopic)
}
However, i could not sort the subTopic, as it gkeep giving me undefined. Is there any way to sort this subTopic, such that they are in alphabetical orders?

Appreciate any help.

View Replies !    View Related
Referencing Array Items With An Id Pulled From The Array
I have been modifying one of the Kirupa tutorials about loading external xml data and arrays. I have it successfully working, but i would like to figure out how to take it one step further. I want to be able to designate a each item in the arrays with an id rather than an iterative variable number and cannot figure out how to do it.

This is a snippet from the xml file:

<projects>
<item>
<id>13</id>
<projectname>First Project</projectname>
<location>Anytown, USA</location>
<units>60</units>
</item>
<item>
<id>33</id>
<projectname>Second Project</projectname>
<location>Sometown, USA</location>
<units>132</units>
</item>
</projects>

I am currently populating an array this way:

total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
id[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
projectname[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
plocation[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
units[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
}

but that just gives me references to: projectname1, projectname2 etc.
I would like to figure out how to get the <id> value from the loaded xml file connected to the variable name of each item in the array so that i can refer to the variables this way: projectname13, projectname33, etc.

Does this make sense? Can anyone help?

View Replies !    View Related
Setting Array Values To Variables In Another Array
I have some variables created on the main timeline and a mc called options which will be where those variables can be manipulated.

A way I've tried to this is by creating a first array(array1) and populating it will all the variable names found on the main timeline, and another array(array2) containing the values of the variables the user has changed(which are displayed on some dynamic text fields). To make these changes, an "apply" button is pressed which will set the values found in array2 to the variables in array1.

So...

Code:

PHP Code:



//variables on the main or root timelinevar1 = 1; var2 = 2; //... //within options mc timelinearray1 = [var1, var2]; array2 = [var1Display, var2Display]; apply.onRelease = function() { //set values in array2 to variables in array1 and update the main timeline's variables//... } 




How would you do this so that var1, var2... are updated properly according to the values found in array2?

And because array2 contains strings(read from dynamic textfields), how do you deal with that since var1 and var2 are numbers?

hope this all makes sense to everyone

View Replies !    View Related
PHP Array -> Flash Array In Function
I'm retrieving an array from PHP, bringing it into Flash, converting it to a Flash array, then passing the array values to functions in order to control playback of multiple timelines.

The PHP array consists of time values in milliseconds, and mouth positions for a character's lip-synch. For example, &time1=0.015962&mouth1=eat&time2=etc...

I want my first function to extract the first array value for time and the first array value for mouth position, and pass it to another function that reads the time, does a calculation to determine how long to pause before executing the original function again, thus leaving the mouth position passed to it and moving along to the next array value.

My problem is this: how can I write the array references into the function so that it knows each time which successive array value to extract? Do I need to pass a total number of array values initially, then trade a "current value" between the two functions (time and mouth position) to make sure the array value being retrieved is correct?

Any help is appreciated,

Mike

View Replies !    View Related
Simple? Array To Array Problem
I am trying to pass the value from one array element to an element in another array. I believe the value is getting there, but it won't display when the 2nd array element is used as the variable in a dynamic text block. Here's the simplistic code I'm trying to learn the concept with:

one = new Array(5);
one[0]=1;
one[1]=2;
one[2]=3;
one[3]=4;
one[4]=5;
two = new Array(5);
two[0]=one[4];
two[1]=one[3];
two[2]=one[2];
two[3]=one[1];
two[4]=one[0];

I then set up individual dynamic text boxes for two[0] through two[4], but no value will show.

View Replies !    View Related
Link Array 2 To Randomized Array 1
Hi,

I am trying to do the following:

I have a textfile that contains 2 variable sets:

&songs=bluestravelertest.swf|aridtest.swf|dmbtest. swf|joewalshtest.swf&eof=1
&info=<br><b>Blues Traveler</b><br>Onslaught|<br><b>Arid</b><br>Little Things of Venom|<br><b>Dave Matthews Band</b><br>Mother, Father|<br><b>Joe Walsh</b><br>Funk #49&eof=2

The 'songs' var I use to load a new swf in an empty MC, the 'info' var I use to load into a dynamic textfield. Both vars are properly parsed via a function (no problems here).


I created a button that should shuffle the 'songs' var.


Code:
var o=_root.myArray.slice(myArray[0], myArray(total))
var newlength=o.length
var shuffledArray=new Array()
for(var i=0;i<newlength;++i){
var r=random(o.length)
shuffledArray[shuffledArray.length]=o[r]
//o[r]=o[o.length-1]
o[r]=o[o.length-1]
o.pop()
}


This all works fine, but how can I link the 'info' var to the 'songs' var after it has been shuffled? (in other words, how can I get the 'info' var 2 to load when 'songs' var 2 is loaded)?


It's kinda late, so let me know if it is not clear.

I really hope you can help me here, because I have been working on this for ages, but I simply can't get it to work.


Thx in advance.


With kind regards,

RF

View Replies !    View Related
Question: PHP Array To Flash Array?
I've searched many topics about this and they have helped me a little bit, but I can't quite get my PHP array to go into Flash as an array. I think the method I want to do is echo my PHP array as a string separated by commas and then bring that into flash and split it.

1. I'm not quite sure how I could format my PHP array as a string separated by commas.

2. I'm not sure how to bring it into Flash via LoadVars.

Heres what I have so far:


PHP Code:



<? // test.php
include('db.php');
dbConnect("slayer");
$result=mysql_query("select*from portfolio");
$num=mysql_num_rows($result);
echo "&num_results=" . $num;
$myArray=$row["name"];
for($i=0;$i<=$num;$i++){
$row=mysql_fetch_array($result, MYSQL_BOTH);
echo "&name$i=" . $myArray[$i];
}
?>





code: on (release) {
myData = new loadVars();
myData.load("test.php");
myData.onLoad = function(success) {
if (success) {
var i = 0;
while (this["myArray" + i] != undefined) {
_root.myVar = this["myArray" + i];
i++;
}
}
};
}


Thanks for any help or tips. I would really appreciate it greatly.

View Replies !    View Related
ARRAY Element Value - Not Array Index Value
Hi all -
Have a small problem converting the below variables from PHP into a useful Ascript Array. I keep getting the value of the array index, rather than the value of the variable in question.


So I know I have 3 rows in my database (totalRows var),
and I have a incremental values for the "recordId"'s (which correspond to the record ID in the db).

totalRows = 3

recordId0 = 1
recordId1 = 5
recordId2 = 6

this is the code I am using:

Code:
function extractMenu() {
//returned vars (FYI): totalRows=3&recordId2=6&recordId1=5&recordId0=1&result=okay&
this.menuArray = new Array();
with (menuLoad) { //menuLoad is the LoadVars object holding PHP vars.
for (i=0; i<=totalRows-1; i++) {
menuArray[i] = recordId + i;
trace(menuArray[i]);
//the trace returns:
//0
//1
//2
//I was expecting the values:
//1
//5
//6
}
}


any takers?

View Replies !    View Related
Array Data Is Set Then Lost... But Just One Array
Hi,

I have 3 arrays, 2 hold different information which will be combined into the third one.

The creation/population of each array is done with in each own function as results are sent back to the flash from remoting.

I have attached a mock up of the code below.


Code:

array1 = new Array();
array2 = new Array();
array3 = new Array();

combineArrays = function () {
for (j=0; j< array2.length; j++) {
array3.push({something:array1[j].something, something:array2[j].something, ....});
}
this.myGrid.setDataProvider(array3);
};

query2_Result = function (result) {
array2.push({something:result[0].something, ....});
};

query1_Result = function (result) {
aMatrix = result;
for (i=0; i<aMatrix.length; i++) {
array1.push({something:aMatrix[i].something, ....});
remoting.query2(int(aMatrix[i].something), "");
}
combineArrays();
};
array1 and array3 keep the data that was populated into it. But by the time we reach the combine function array2 has no data.

I'm not sure why its losing the information, if you trace with in query2_Result() you get all the information that was populated into the array2.

Any help would be greatly appreciated.

Ty,
alex

View Replies !    View Related
Reading Array, Not Setting Array
Sorry everyone, I think I'm making a simple mistake but I just can't see it.


I'm using an array to store the order of something, I also make a backup of that array as a reference to remember what that first array looked like.

The problem comes when I'm using the values of that backed up array to populate the first array. What happens is that the backed up array gets it values overwritten, when all I wanted to do was read its values, not set its values.

Heres what I'm up to :



Code:
// Sets initial array
var ButtonOrder = new Array("One", "Two", "Three", "Four");

// Makes a backup of the initial array
ButtonOrderBackup = ButtonOrder;

// Changes the initial array with values from the backup
// (This is where I think the problems at)
ButtonOrder[0] = ButtonOrderBackup[3];
ButtonOrder[1] = ButtonOrderBackup[2];
ButtonOrder[2] = ButtonOrderBackup[1];
ButtonOrder[3] = ButtonOrderBackup[0];


// Trace Backup array
for (i = 0; i < ButtonOrderBackup.length; i++)
{
trace("Backup " + i + " " + ButtonOrderBackup[i]);
}
trace("");


// Trace initial array
for (i = 0; i < ButtonOrder.length; i++)
{
trace(i + " " + ButtonOrder[i]);
}
trace("");
Heres what the debugger feeds back to me :


Code:
Backup 0 Four
Backup 1 Three
Backup 2 Three
Backup 3 Four

0 Four
1 Three
2 Three
3 Four
I was wanting the initial array to have the values: Four, Three, Two, One. And the backup array to be how it was originally : One, Two, Three, Four.

What have I done wrong, thank you.

View Replies !    View Related
Populate An Array Values From An Array
ok i have this xml file

Code:
<artworkinfo>
<movieinfo>
<artLocation>cover1.jpg</artLocation>
<movie>Live Free or Die Hard</movie>
<plot>John McClane takes on </plot>
</movieinfo>

<movieinfo>
<artLocation>cover2.jpg</artLocation>
<movie>Meet the Robinsons</movie>
<plot>Lewis is a brilliant inventor </plot>
</movieinfo>

</artworkinfo>
the xml will tell where the cover art is the movie title and plot.
i want to populate my movie with this info what is the best approach to create empty movieclips using actionscript or create individuals MC , i try the second one and create 4 movieclips (cause the xml have 4 elements just post 2) and make an array of mc but i can find how to match the xml array to the mc array , this is the code for better explaining,


Code:
function loadXML(loaded) {

if (loaded) {

xmlNode = this.firstChild;
image = [];
movie = [];
plot = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {

image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
movie[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
plot[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;

}
placeholder=new Array(loader1,loader2,loader3,loader4);
placeholder_total = placeholder.length;
for (e=0; e<placeholder_total; e++){
placeholder[e].contentPath=this.image[i];
}


} else {

content = "file not loaded!";

}

}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("movieinfo.xml");
the stage have 4 movieclips name loader1,loader2,ect... each mc have 2 dynamic text field one for title and one for the plot.

View Replies !    View Related
Flash Array Works, Not Php Array
Hi!

Cant figure out what the problem is. Im using amfphp remoting to load some data from mySQL db. The weird thing is that if I "hardcode" values in an Array in Flash I get it all to work, but when I'm using the array from php it wont load the pictures. But if I trace out my array from the php-file in Flash I get the correct values...

Here's my AS:

Code:
import mx.remoting.*;
import mx.rpc.*;
import mx.remoting.debug.NetDebug;

var gatewayUrl:String = "http://localhost/flashservices/gateway.php"

NetDebug.initialize();
var _service:Service = new Service(gatewayUrl, null, 'Bilder', null , null);
var pc:PendingCall = _service.getEverything();
pc.responder = new RelayResponder(this, "handleResult", "handleError");

//Stage.scaleMode = "noScale";
function handleResult(re:ResultEvent)
//init();
//function init()
{

info_mc._visible = false;
var arrPictures = new Array();
arrPictures = re.result;

//This one works --> arrPictures = new Array("http://localhost/flashservices/services/pics/thumb_fall 017.jpg", "http://localhost/flashservices/services/pics/thumb_fall 018.jpg", "http://localhost/flashservices/services/pics/thumb_fall 019.jpg");
var xPos:Number = 90;
var nPic:Number = 0;

for (var i:Number = 0; i < arrPictures.length; i++) {
this.attachMovie("pic_holder", "pic_holder"+i, this.getNextHighestDepth(), {_x: xPos, _y: 150});
_root["pic_holder"+i].attachMovie("preloader_mc", "preloader_mc"+ i, 1);

_root["pic_holder"+i].material = arrPictures[i]["material"];
_root["pic_holder"+i].preloader = _root["pic_holder"+i]["preloader_mc"+i].preloader_txt;


this["pic_holder"+i].onRollOver = function():Void {
_root.infoClothing();
info_mc._visible = true;
info_mc.material_txt.text = this.material;
}
this["pic_holder"+i].onRollOut = function():Void {
info_mc._visible = false;
}
xPos += 90;
}

}

//Ladda in bilderna
var index:Number = 0;

var mcLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
nperc = Math.round((bytesLoaded/bytesTotal)*100);
_root["pic_holder"+index]["preloader_mc"+index].preloader_txt.text = nperc + "%";
}

listener.onLoadInit = function(target:MovieClip) {
index++;
if(index < arrPictures.length)
mcLoader.loadClip(arrPictures[index]["url"], _root["pic_holder"+index].lilla_mc);
}
mcLoader.addListener(listener);
mcLoader.loadClip(arrPictures[index]["url"], _root["pic_holder"+index].lilla_mc);
// Slut på preloader



function handleError(fe:FaultEvent)
{
trace('There has been an error');
}

function infoClothing():Void {
this.info_mc.swapDepths(getNextHighestDepth());
this.info_mc.onMouseMove = function() {
this.updateAfterEvent();
info_mc._x = _root._xmouse + 22;
info_mc._y = _root._ymouse - 10;
}
}

View Replies !    View Related
Mp3 Array - Won't Play Whole Array And Then Stop - Somebody Help?
I've got an array of mp3s. I'm trying to find the right combination of code to get the play button to play each mp3 in the array, then stop at the end of the array. Must keep the items in the array - so no shifting. I've come up with dozens of ways to loop the items in the array - or the other side of the spectrum - to get the play button to only play one item at a time each time you click it. This has gone on too long... Somebody has to know how to help me...

In frame 1 I've got:

ActionScript Code:
_global.DIALPAD = []
now = 0;
_global.PADSOUND = new Sound();

//then on the play button I have:

on (press) {
_global.PADSOUND.loadSound(_global.DIALPAD[(++now)%_global.DIALPAD.length]);
_global.PADSOUND.start();
}Don't ask me how I came up with the button code - I don't even know anymore. At any rate, I've got other buttons that push mp3s into the array with this code:

_global.DIALPAD.push("SOUND1.mp3");

I'm trying to get the array to play all the way through and stop there. I've tried dozens of combinations of [i] and looping - all kinds of crazy nonsense trying to piece together what I could from posts and scanning other people's code, but I'm new to AS.

I will appreciate any help you can give me. Thanks!!

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved