Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Trying to access XML data from for loop not working...

Posted on 2008-06-20
3
Medium Priority
?
341 Views
Last Modified: 2013-11-11
Hi,

This is driving me nuts!  I want to load images from an XML file into a scrollpane (which is also not working properly).  I am having trouble accessing my XML object--aVideos[index].imagei, where i is 1, 2, 3 etc.  If I hard code this to "aVideos[index].image1, aVideos[index].image2 etc" it works.  But, I would like to load many images from this XML object in a for loop.  Another expert suggest using "eval", but that didn't work or I didn't manage to use it correctly.  Can someone see what is wrong with my code?

Many thanks in advance!
for (i=1; i<=9; i++){ 
 
_root.mcMain.createEmptyMovieClip("imageholder+i", _root.mcMain.getNextHighestDepth());
_root.mcMain.imageholder+i.loadMovie(aVideos[index]."image"+i); 
setProperty("_root.mcMain.imageholder"+i, _x, i+390);
setProperty("_root.mcMain.imageholder"+i, _y, 0);
_root.myScrollpane.invalidate();
};

Open in new window

0
Comment
Question by:1Cougar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
ddlam earned 1500 total points
ID: 21837116

for (i=1; i<=9; i++){ 
_root.mcMain.createEmptyMovieClip("imageholder"+i, _root.mcMain.getNextHighestDepth());
_root.mcMain["imageholder"+i].loadMovie(aVideos[index].["image"+i]); 
_root.mcMain["imageholder"+i]._x = i+390
_root.mcMain["imageholder"+i]._y = 0;
_root.myScrollpane.invalidate();
};

Open in new window

0
 

Author Comment

by:1Cougar
ID: 21839892
Hi,

This code unfortunately doesn't work as I get an error:

Expected a field name after '.' operator.

I don't understand why.  Plus, when I hard code the field--image1, image2, etc.  I can see the images, but there is no scrollbar or rather a blank scrollbar with no button to scroll.  It is like the scrollpane doesn't understand there are images in there.  Yet, if I set the "draggable" property to true in the scrollpane then I can drag the mc and see all of the images, so they are there but the scroll pane doesn't recognize it?

So, 2 problems--["image"+i]
And, even when image1 etc hardcoded, scrollpane not functioning.

Any help would be much appreciated!

Thanks!
0
 

Author Comment

by:1Cougar
ID: 21839989
So, this code is somewhat working--I had to change it to be loadMovie(aVideos[index]["image"+i] , so without the "."  However, I am still having difficulties.  This code is loading the 10 images.  But, the result is not correct.  

1) Image0 are starts x = 390, when the first one should be at 0 and the next 390.  If I hard code the set property x value to 0, it is as it should be.
2) I have no scroll button to scroll through, only blank scroll bar.
3) When I set "drag" to true, I can go through the images, but only see part of the last image....

So, something is wrong with my set up and I can't figure it out.

I thought this was supposed to be easy!!!!  I am very frustrated!
for (i=0; i<=9; i++){ 
_root.mcMain.createEmptyMovieClip("imageholder"+i, _root.mcMain.getNextHighestDepth());
setProperty("_root.mcMain.imageholder"+i, _x, i*300);
setProperty("_root.mcMain.imageholder"+i, _y, 0);
_root.mcMain["imageholder"+i].loadMovie(aVideos[index]["image"+i]); 
_root.myScrollpane.invalidate();
}

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question