I'm trying to load some .swf files into my Flash project from XML. I've attached my code below. "pane" is a scrollpane component on the stage, and "emptyMC" is an empty movie symbol in the library.
Everything is working fine... I have the images loading in rows, 18 per row, but if there's a large number of images, I want to be able to scroll through them. So, after all the images are loaded, I want to put them all into a scrollpane component. I just don't know how to attach the dynamically created movieclip with all the images to the scrollpane.
Any ideas would really be appreciated!!
thanks,
stop();
StencilGalleryXML = new XML();
StencilGalleryXML.onLoad = init;
StencilGalleryXML.load("stencils.xml");
StencilGalleryXML.ignoreWhite = true;
var xPos:Number = 185;
var yPos:Number = 315;
var MCL = new MovieClipLoader();
function init(success) {
if (success == true) {
rootNode = StencilGalleryXML.firstChild;
nbrStencils = rootNode.childNodes.length;
currentStencil = rootNode.firstChild;
_root.pane.contentPath = "emptyMC";
_root.pane.vScrollPolicy = "on";
for (i=0; i<nbrStencils; i++) {
mcName = "stencil"+i;
loadImage(currentStencil.attributes.swfURL, currentStencil.attributes.outline, mcName, currentStencil.firstChild.nodeValue, i+1);
currentStencil = currentStencil.nextSibling;
}
//CAN I ADD THE PARENT MOVIE CLIP TO THE pane SCROLLPANE COMPONENT HERE???
//p = pane.content.attachMovie("emptyMC", "scrollingMovie", this.getNextHighestDepth());
//p.loadMovie()
}
}
function loadImage(imgSrc, imgOutline, clipName, desc, ctr) {
//Creates a parent movie clip to hold the container
this.createEmptyMovieClip("parent", this.getNextHighestDepth());
newClip = parent.createEmptyMovieClip(clipName, this.getNextHighestDepth());
//this is the movie clip the currentStencil will replace
newClip.createEmptyMovieClip("container_mc", this.getNextHighestDepth());
//use moviecliploader to load the currentStencil
MCL.loadClip(imgSrc, newClip.container_mc);
newClip._y = yPos;
newClip._x = xPos;
//new row after every 18 stencils
if (ctr%18 == 0) {
xPos = 185;
yPos += 30;
} else {
xPos += 30;
}
}
MCL.onLoadInit = function (targetMC) {
targetMC._width = 25;
targetMC._height = 25;
}
Everything is working fine... I have the images loading in rows, 18 per row, but if there's a large number of images, I want to be able to scroll through them. So, after all the images are loaded, I want to put them all into a scrollpane component. I just don't know how to attach the dynamically created movieclip with all the images to the scrollpane.
Any ideas would really be appreciated!!
thanks,
stop();
StencilGalleryXML = new XML();
StencilGalleryXML.onLoad = init;
StencilGalleryXML.load("stencils.xml");
StencilGalleryXML.ignoreWhite = true;
var xPos:Number = 185;
var yPos:Number = 315;
var MCL = new MovieClipLoader();
function init(success) {
if (success == true) {
rootNode = StencilGalleryXML.firstChild;
nbrStencils = rootNode.childNodes.length;
currentStencil = rootNode.firstChild;
_root.pane.contentPath = "emptyMC";
_root.pane.vScrollPolicy = "on";
for (i=0; i<nbrStencils; i++) {
mcName = "stencil"+i;
loadImage(currentStencil.attributes.swfURL, currentStencil.attributes.outline, mcName, currentStencil.firstChild.nodeValue, i+1);
currentStencil = currentStencil.nextSibling;
}
//CAN I ADD THE PARENT MOVIE CLIP TO THE pane SCROLLPANE COMPONENT HERE???
//p = pane.content.attachMovie("emptyMC", "scrollingMovie", this.getNextHighestDepth());
//p.loadMovie()
}
}
function loadImage(imgSrc, imgOutline, clipName, desc, ctr) {
//Creates a parent movie clip to hold the container
this.createEmptyMovieClip("parent", this.getNextHighestDepth());
newClip = parent.createEmptyMovieClip(clipName, this.getNextHighestDepth());
//this is the movie clip the currentStencil will replace
newClip.createEmptyMovieClip("container_mc", this.getNextHighestDepth());
//use moviecliploader to load the currentStencil
MCL.loadClip(imgSrc, newClip.container_mc);
newClip._y = yPos;
newClip._x = xPos;
//new row after every 18 stencils
if (ctr%18 == 0) {
xPos = 185;
yPos += 30;
} else {
xPos += 30;
}
}
MCL.onLoadInit = function (targetMC) {
targetMC._width = 25;
targetMC._height = 25;
}