Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-25-2004, 01:48 AM   #1
Mortimer Jazz
Thing
 
Mortimer Jazz's Avatar
 
Join Date: Jun 2001
Location: UK
Posts: 2,418
Default 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.
Mortimer Jazz is offline   Reply With Quote
Old 03-25-2004, 05:21 AM   #2
ericlin
Registered User
 
Join Date: Jun 2003
Posts: 621
Default

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:[]}};
ericlin is offline   Reply With Quote
Old 03-25-2004, 05:51 AM   #3
Mortimer Jazz
Thing
 
Mortimer Jazz's Avatar
 
Join Date: Jun 2001
Location: UK
Posts: 2,418
Default

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.
Mortimer Jazz is offline   Reply With Quote
Old 03-25-2004, 06:55 AM   #4
farafiro
Addicted To FLASH
 
farafiro's Avatar
 
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
Send a message via MSN to farafiro Send a message via Yahoo to farafiro
Default

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
farafiro is offline   Reply With Quote
Old 03-25-2004, 07:02 AM   #5
Mortimer Jazz
Thing
 
Mortimer Jazz's Avatar
 
Join Date: Jun 2001
Location: UK
Posts: 2,418
Default

your nose never lets you down Faffy
Just upgrading an old one, but from the bottom up
Mortimer Jazz is offline   Reply With Quote
Old 03-25-2004, 07:14 AM   #6
farafiro
Addicted To FLASH
 
farafiro's Avatar
 
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
Send a message via MSN to farafiro Send a message via Yahoo to farafiro
Default

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
farafiro is offline   Reply With Quote
Old 03-25-2004, 07:18 AM   #7
Mortimer Jazz
Thing
 
Mortimer Jazz's Avatar
 
Join Date: Jun 2001
Location: UK
Posts: 2,418
Default

I can help you if you want the php equiv, but not VB I'm afraid
Mortimer Jazz is offline   Reply With Quote
Old 03-25-2004, 07:26 AM   #8
farafiro
Addicted To FLASH
 
farafiro's Avatar
 
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
Send a message via MSN to farafiro Send a message via Yahoo to farafiro
Default

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
farafiro is offline   Reply With Quote
Old 03-25-2004, 07:41 AM   #9
Mortimer Jazz
Thing
 
Mortimer Jazz's Avatar
 
Join Date: Jun 2001
Location: UK
Posts: 2,418
Default

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.
Mortimer Jazz is offline   Reply With Quote
Old 03-25-2004, 07:48 AM   #10
farafiro
Addicted To FLASH
 
farafiro's Avatar
 
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
Send a message via MSN to farafiro Send a message via Yahoo to farafiro
Default

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
farafiro is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:16 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.