Hi!
I want t make a row of images that I am loading from a xml file. But I am struggling at the begining.I want to load each image into an empty MC and load this whole MC of images into another MC so I can scroll it.
Here is my code so far:
package
{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class teste extends MovieClip
{
var picXML : XML;
var xmlLoader : URLLoader = new URLLoader();
var thumbs : Array = new Array();
var numImgs : Number;
var holder : MovieClip = new MovieClip();
var imgLoader : Loader = new Loader();
var mcImg : MovieClip;
public function teste()
{
init();
}
private function init():void
{
xmlLoader.load(new URLRequest("album.xml"));
xmlLoader.addEventListener(Event.COMPLETE,onXMLLoaded);
}
private function onXMLLoaded(event:Event):void
{
picXML = new XML(event.target.data);
var picList : XMLList = picXML.pic.attribute("url");
for each(var pl : XML in picList)
{
thumbs.push(pl);
}
numImgs = thumbs.length;
buildThumbs();
}
//here is where starts my pain. I am getting an error and if I comment out the line imgLoader.load(...) I dont get the error message.
private function buildThumbs():void
{
for(var i = 0;i <= numImgs;i++)
{
mcImg = new MovieClip();
mcImg.name = "img" + i;
imgLoader.load(new URLRequest(thumbs*));
mcImg.addChild(imgLoader);
holder.addChild(mcImg);
}
}
}
}
another question is how I set the x and y position of each imgMC inside the holder MC?
Here is what I get when I teste my fla that has this code : var s : teste = new teste(); addChild(s);
TypeError: Error #2007: Parameter url must be non-null.
at flash.display::Loader/flash.display:Loader::_load()
at flash.display::Loader/load()
at teste/::buildThumbs()
at teste/::onXMLLoaded()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()