flash actionscript:
Help, I'm stuck. I've got a prototype that works. I can pull out one of the new
array entries from it.
I want to be able to pull out all the array elements and place their
properites (if more than one element is in the array) and put their respective
pictures and names in another location.
the link below may help you understand what I'm trying to accomplish.
http://skysflashtest.50webs.com please help, I've looked all over and found nothing that is working for me.
myArray = [{myname:"bob", town:"London", id:1, pic:"1.gif"},
{myname:"hans", town:"Munich", id:2, pic:"2.gif"},
{myname:"manuel", town:"Barcelona", id:3, pic:"3.gif"},
{myname:"bob", town:"Newark", id:4, pic:""}];
Array.prototype.id = function(prop, val) {
var res:Array = new Array();
var i = this.length;
while (i--) {
if (this[i][prop] == val) {
res.push(this[i]);
trace(myArray.myname);
for (var entry in res) {
for (var prop in res[entry]) {
theID = res[entry].id;
theName = res[entry].myname;
theTown = res[entry].town;
thePic = res[entry].pic;
anotherTown = res[entry[i]].town; // would be the second bob in the
Array's town.
anotherPic = res[entry].pic; // would be the second bob in the Array's
picture.
goodsearch();
}
}
} else {
trace("I'm in else");
}
}
return (res);
};
var myArray = myArray.id();
getInfo_mc.onRelease = function() {
var getConvertText = it_txt.text;
var convertedToLowerCase = getConvertText.toLowerCase();
var getName = convertedToLowerCase;
myArray.id("myname", "bob");
};
goodsearch = function () {
//trace("this is a good search");
dtName_txt.text = theName;
//trace(theName);
dtTown_txt.text = theTown;
dtAddress_txt.text = theID;
imageLoader.contentPath = thePic;
dtAnother_txt.text = "Another "+theName+" lives in ";
dtSecName_txt.text = anotherTown;
imageLoader2.contentPath = anotherPic;
};