473,748 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with arrays

42 New Member
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_i mg" 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 2005
onyris
42 New Member
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
3459
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 guestbook scripts out there - but that doesn't help me learn how to programme arrays !!! The following is the code for the PHP (called externally), which does execute...
4
1844
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 elaborate to make sure my questions are clear enough. Let's say I need to write a function whose logic is same for all types (T) except in the case of T * (including const T *). Furtheremore , the function needs to be written differently for...
4
2830
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 arrays of datetime.datetime instances. The following is the code I have written: import cPickle, datetime import Numeric
8
2260
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 was created by Tom Johnson. Apologies to those who are not musically literate, but as this is basically a mathmatical problem I think most here can follow the logic. Lets keep eveything in C Major, that's all the white keys on the piano....
1
455
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 do it via arrays but I am stumbled on how to implement this same solution with pointers, "malloc" and "free" as I can't use arrays. Below is the code I have to do it with arrays. If anyone can help give me some tips on how to implement this code...
2
1635
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 about parameter passing. If someone give me comment, it will be thankful. thankyou very much
9
2518
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 *after* calling increase_arrays(), I received segmentation fault. I tried to step it through gdb, and I found out that after calling increase_arrays(), words's original value is modified, and if I tried to access it, I get <address 0x11 out of...
2
2005
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 am learning. My problem is this. I had sucessfully written a C code that worked ( with considerable speedup over the IDL version ) using an array size of 100x100. However, I am working towards making the array size closer to 300x300. Since I had...
5
2157
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 quiz i have to do a password and a login. I managed to do the password but when i tried to join this to the whole program its not working. This is the main program: import java.util.*; import java.io.*; import java.util.Scanner; import...
110
7026
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 don't. I have gone over a few different examples but they were limited. I was able to find one piece of code that I would like to disect and ask questions about so I can gain a better understanding. $characters = array ( array (...
0
8996
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9386
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6799
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.