PDA

View Full Version : scrolllPane loading images issue?


Navarone
08-18-2005, 06:45 PM
I have a question on how to do something. First I on my stage I have a scrollPane that I want to use for displaying thumbnail images. So in the library I have a movieClip with a Loader component, an instance name of "myLoader".

Now I have been successful in getting the movieClip into the scrollPane and loading an image, but I want to run through a for loop to load all the images.

How would I go about do this.


var myScrollPane:mx.containers.ScrollPane;
myScrollPane.contentPath = 'mc_container';
//
MyPicVars = new LoadVars();
MyPicVars.load("jetPlane.txt");
MyPicVars.onLoad = function(success) {
if (success) {
trace("loaded");
Rc = this["Rc"];
for (i=0; i<=Rc-1; i++) {
trace(this["pic"+i]);
myScrollPane.content.myLoader.contentPath = "jetPlane/"+this["pic"+i];
}
} else {
trace("not loaded");
}
};

Navarone
08-18-2005, 08:17 PM
I added a new emptyMovieClip as the myScrollPane.contentPath The trace(mc_container.myLoader.contentPath), list out the correct images in the output box, but I still can't get the images to load.

var myScrollPane:mx.containers.ScrollPane;
myScrollPane.contentPath = 'mc_holder';
//
MyPicVars = new LoadVars();
MyPicVars.load("jetPlane.txt");
MyPicVars.onLoad = function(success) {
if (success) {
trace("loaded");
Rc = this["Rc"];
var my_mc:MovieClip;
for (i=0; i<=Rc-1; i++) {
//trace(this["pic"+i]);
my_mc = myScrollPane.content.attachMovie("mc_container", "mc"+i, i, this.getNextHighestDepth());
my_mc._x = 5;
my_mc._y = 5+(i*80);
mc_container.myLoader.contentPath = "jetPlane/"+this["pic"+i];
trace(mc_container.myLoader.contentPath)
my_mc.i = i;
myScrollPane.invalidate();
}
} else {
trace("not loaded");
}
};

sleekdigital
08-18-2005, 08:19 PM
EDIT: I wrote this in response to the first post, did not read second yet

Well in each iteration of the loop you are just replacing what you did in the previous iteration. Maybe do this instead....

var myScrollPane:mx.containers.ScrollPane;
// myScrollPane.contentPath = 'mc_container';
// instead make this a blank mc (so have a blank mc in lib with linkage "blank")
myScrollPane.contentPath = "blank";
//
MyPicVars = new LoadVars();
MyPicVars.load("jetPlane.txt");
MyPicVars.onLoad = function(success) {
if (success) {
trace("loaded");
Rc = this["Rc"];
var currentClip;
for (i=0; i<=Rc-1; i++) {
trace(this["pic"+i]);
currentClip = myScrollPane.content.attachMovie("'mc_container'", "pic"+i, i);
currentClip.myLoader.contentPath = "jetPlane/"+this["pic"+i];
}
} else {
trace("not loaded");
}
};

Also, I'm pretty sure I have mentioned before that I have code that does exactly what you are describing here...
http://www.layer51.com/proto/d.aspx?f=1396

Navarone
08-18-2005, 08:28 PM
I have seen what you have on your link, but doesn't what you have use XML?

sleekdigital
08-18-2005, 08:32 PM
It does, but it would be simple for you to create an xml object inside of flash based on whatever you are currently using.

Navarone
08-18-2005, 08:35 PM
Will XML run from a cd rom? :)

sleekdigital
08-18-2005, 08:36 PM
my_mc = myScrollPane.content.attachMovie("mc_container", "mc"+i, i, this.getNextHighestDepth());

this should probably be ...
my_mc = myScrollPane.content.attachMovie("mc_container", "mc"+i, i);

sleekdigital
08-18-2005, 08:37 PM
The xml doesn't have to exist anywhere accept inside the flash movie itself. but certainly you could put an xml file on the cd rom just the same as you would any other text file.

You could create the xml object in flash based on your loaded variables or whatever you want.

Navarone
08-18-2005, 08:56 PM
O, I'll have to read up on it and see how to do it. :)