03-25-2004, 01:48 AM
|
#1
|
|
Thing
Join Date: Jun 2001
Location: UK
Posts: 2,418
|
Associative arrays
Hi Guys, I don't work with associative arrays much, and just want to condense some code.
I've got 3 main arrays, one of which is associative.
For time-saving (and code-saving) reasons I won't go into here I thought I'd declare them all within a master array like so:
theArrays = [artistArray=[],titleArray=[],infoArray=[]];
This is fine, but it appears I can't also declare the sub-arrays like this.
For example, one sub-array is infoArray["album"] = [];
and I was hoping to do something like this:
theArrays = [artistArray=[],titleArray=[],infoArray=[], infoArray["album"] = []];
-----------------------------------
This doesn't work and I just wondered if I was making a simple mistake somewhere or whether I'm just not allowed to do it this way.
|
|
|
03-25-2004, 05:21 AM
|
#2
|
|
Registered User
Join Date: Jun 2003
Posts: 621
|
Array in Flash are indexed by numbers.
Genuine Object might be the thing you want. The syntax "infoArray["album"] = [];" is the way we access object properties.
Since an Array is also an Object, we still can use that syntax, but it is another story.
I would like to create theArrays like this:
theArrays = {artistArray:{}, titleArray:{}, infoArray:{album:[]}};
|
|
|
03-25-2004, 05:51 AM
|
#3
|
|
Thing
Join Date: Jun 2001
Location: UK
Posts: 2,418
|
Thanks, but I was hoping to avoid using the Object object, as I intend to use properties of the Array object to perform sorting later on. I could have sworn MM were claiming support for associative arrays in their pre-release bumpf for MX04.
It's no biggie. The code I've got works, it's just not as condensed as I would like.
I still think if it lets me assign an array as a property of the Array object then I should be able to go one deeper, but I can't even get it to work with a number based index.
[edit - okay I've worked out why now. The infoArray doesn't get initialised before I try to intialise the sub-array. If I declare infoArray first outside of theArrays array I can then declare the subArrays inside theArray array without any problems. For example:
infoArray=[];
theArrays = [artistArray=[],titleArray=[],infoArray["pic"]=[]]; //works
Cheers for the suggestion though :].
Last edited by Mortimer Jazz; 03-25-2004 at 06:09 AM.
|
|
|
03-25-2004, 06:55 AM
|
#4
|
|
Addicted To FLASH
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
|
smelling like u r gonna file a mp3 player soon mate
__________________
â€* GOD Is Near â€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
|
|
|
03-25-2004, 07:02 AM
|
#5
|
|
Thing
Join Date: Jun 2001
Location: UK
Posts: 2,418
|
your nose never lets you down Faffy 
Just upgrading an old one, but from the bottom up
|
|
|
03-25-2004, 07:14 AM
|
#6
|
|
Addicted To FLASH
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
|
lol
okey, so I have a questionif u r interested and a VB-er
I know there is a code to read all the files in a spacefic folder
it's not an AS but I need it if u know it
this is to make an mp3 player also, but on the fly, if u get what I mean
__________________
â€* GOD Is Near â€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
|
|
|
03-25-2004, 07:18 AM
|
#7
|
|
Thing
Join Date: Jun 2001
Location: UK
Posts: 2,418
|
I can help you if you want the php equiv, but not VB I'm afraid
|
|
|
03-25-2004, 07:26 AM
|
#8
|
|
Addicted To FLASH
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
|
would it do what I want, here it is:
to get all the files name + extentions from a folder
import this to flash
store it in an array
play it
__________________
â€* GOD Is Near â€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
|
|
|
03-25-2004, 07:41 AM
|
#9
|
|
Thing
Join Date: Jun 2001
Location: UK
Posts: 2,418
|
Yep that's do-able, but you may be best off asking in the scripting forum. I only have a php script to do that.
|
|
|
03-25-2004, 07:48 AM
|
#10
|
|
Addicted To FLASH
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
|
and??
ahuh
so, would u please forword that code for me
please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please
__________________
â€* GOD Is Near â€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 10:16 AM.
///
|
|