473,424 Members | 1,695 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,424 software developers and data experts.

Help with arrays

42
Hi guys ,
I have got lost a bit with this flash i am doing at moment , i will try to explain the best i can and i'll post the code as well so u can see what i've done .
I am using Action script 2, i have an XML with photos , at the moment are 7 photos in there. The code i have at the moment just simply reads from the xml all the photos adn display them in a movie clip .

This is the code so far :
Expand|Select|Wrap|Line Numbers
  1.  step_sel_img.onRelease=function(){
  2. myPhoto = new XML();
  3. myPhoto.ignoreWhite = true;
  4. thumbnails._visible=true;
  5. thumbnails.background=0xD8D8D8;
  6. myPhoto.onLoad = function(success) {
  7.     //portfolioTag = this.firstChild;
  8.     numimages = this.firstChild.childNodes.length;
  9.     spacing = 70;
  10.     for (i=0; i<numimages; i++) {
  11.         this.picHolder = this.firstChild.childNodes[i];
  12.         this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
  13.         this.thumbHolder._x = i*spacing;
  14.         this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
  15.         this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);
  16.         this.thumbHolder.title = this.picHolder.attributes.title;
  17.         this.thumbHolder.main = this.picHolder.attributes.main;
  18.         this.thumbHolder.onRelease = function() {
  19.             grass_bcg.visible=true;
  20.             loader.loadMovie(this.main);
  21.             title_txt.text = " Price = " + this.title;
  22.         };
  23.     }
  24. };
  25. myPhoto.load("xmlphoto.xml") 
There is a button called "step_sel_img" which when pressed loads all the images in a movie clip called " thumbnails ".
Everything is working fine .
Now ..what i want to do is :
i want to set up an array that holds all the images ( before to display them ), and for each of the image i also have other fields like for ex:
image1 contains , name , price, thumbnail, main
The reason i want to do this is that when all images are loaded in the array, then i can set up some button back and forward to display like 3 at the time instead of all.
So basically i need an arary of array ( 2d array) , bust i got lost doing this
I'll put the code below to show u what i've tried to do , and if anyone can tell me what i'am doing wrong .
Expand|Select|Wrap|Line Numbers
  1. step_sel_img.onRelease=function(){
  2. myPhoto = new XML();
  3. myPhoto.ignoreWhite = true;
  4. thumbnails._visible=true;
  5. thumbnails.background=0xD8D8D8;
  6. myPhoto.onLoad = function(success) {
  7.     //portfolioTag = this.firstChild;
  8.     numimages = this.firstChild.childNodes.length;
  9.     spacing = 60;
  10.     for (i=0; i<numimages; i++) {
  11.         this.picHolder = this.firstChild.childNodes[i];
  12.         this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
  13.         this.thumbHolder._x = i*spacing;
  14.         this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
  15.         // testing --------------
  16.         //images[i]=i;
  17.         images = new Array (3);
  18.         images[0]= this.picHolder.attributes.title;
  19.         images[1]= this.picHolder.attributes.price;
  20.         images[2]= this.picHolder.attributes.main;
  21.         images[3]= this.picHolder.attributes.thmb;
  22.         lastimage=i;
  23.         newArray = new Array();
  24.         //newArray[i].push(images)
  25.         set("countArray"+i, images);
  26.             trace (countArray);
  27.  
  28.         //for (var a=0;a<4;a++)
  29. //        {
  30. //            this.picHolder = this.firstChild.childNodes[a];
  31. //            this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+a, a);
  32. //            this.thumbHolder._x = i*spacing;
  33. //            this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
  34. //            this.thumbLoader.loadMovie(images[a][3]);
  35. //            this.thumbHolder.title = images[a][0];
  36. //            this.thumbHolder.main = images[a][2];
  37. //            
  38. //        }
  39.         // testing ------------------
  40.  
  41.         this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);
  42.         this.thumbHolder.title = this.picHolder.attributes.title;
  43.         this.thumbHolder.main = this.picHolder.attributes.main;
  44.         this.thumbHolder.onRelease = function() {
  45.             grass_bcg.visible=true;
  46.             loader.loadMovie(this.main);
  47.             title_txt.text = " Price = " + this.title;
  48.         };
  49.     }
  50.     trace (images);
  51.  
  52. };
  53. myPhoto.load("xmlphoto.xml");
  54. };
  55.  
the code i have tried is between the testing comments
Thanks.
Jul 6 '09 #1
1 1987
onyris
42
Hi guys , found a solution for that , for creating a 2d array
basically this 2 lines of code , first creates the main array , then for each index of that arrya i assign more values for it .
Not sure if this is the right way to do it , but it works for me .
Expand|Select|Wrap|Line Numbers
  1. images[i]=i;
  2.         images[i] = [this.picHolder.attributes.title, this.picHolder.attributes.price,this.picHolder.attributes.main,this.picHolder.attributes.thmb];
Jul 7 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Dariusz | last post by:
I want to use arrays in my website (flat file for a guestbook), but despite having read through countless online tutorials on the topic, I just can't get my code to work. I know there are...
4
by: CoolPint | last post by:
I would be grateful if someone could point out if I am understanding correctly and suggest ways to improve. Sorry for the long message and I hope you will kindly bear with it. I have to make it...
4
by: Mingus Tsai | last post by:
Hello- please help with unpickling problem: I am using Python version 2.3.4 with IDLE version 1.0.3 on a Windows XPhome system. My problem is with using cPickle to deserialize my pickled...
8
by: inkexit | last post by:
I am a very amatuer c++ programmer and a somewhat accomplished composer. I am trying to write some code that creates 'self similar' melodies from a base melody the user inputs. This musical idea...
1
by: Geoff | last post by:
I was wondering if anyone could help me with a problem I am having. I am trying to read in a list of numbers from a file and then sort them using pointers and malloc() and free(). I know how to...
2
by: Pasacco | last post by:
dear I want to ask help on this problem. Array a is partitioned into a0 and a1 in main(). Then a1 is partitioned into a2 and a3 in th_partition() function. And I think this problem is something...
9
by: weidongtom | last post by:
Hi, I've written the code that follows, and I use the function add_word(), it seems to work fine *before* increase_arrays() is called that uses realloc() to allocate more memory to words. But...
2
by: Dr Dav | last post by:
Hello all, I'm a physicist whose rewriting a numerical simulation, previously written in IDL, in C with the goal reducing runtime. As you may imagine, my C programming skills are quite poor but I...
5
by: saytri | last post by:
Hi i have this project were i have to do a quiz. i wrote the questions in a textfile and i called them through java. I have also made a menu to choose which type of quiz. But before accessing the...
110
by: fjm | last post by:
For some reason, I have always had a hard time understanding arrays as they pertain to php and databases. I understand associative arrays just fine but when there are multidimensional arrays, I kinda...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.