function LoadProjects():void {
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
var child:MovieClip;
var thumbLoader:Loader;
var holder_mc:Sprite = new Sprite();//thumbs load into
//var holder_mc:MovieClip; = new MovieClip;();//thumbs load into
var slideThumb:String
var slideFull:String
var slideName:String
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("menu.xml"));
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
ParseImages(xmlData);
}
function ParseImages(imageInput:XML):void {
var imageList:XMLList = imageInput.sub;
for (var i:int = 0; i < imageList.length(); i++){
slideThumb=imageInput.sub.attribute("slide")*;
slideFull=imageInput.sub.attribute("full")*;
slideName=imageInput.sub.attribute("name")*;
thumbLoader = new Loader();
thumbLoader.load(new URLRequest(String(slideThumb)));//access the thumbnails
thumbLoader.name = "thumb_"+i;
child = new MovieClip();
child.addChild(thumbLoader);
child.x=(125*i);
child.y=100;
child.addEventListener(MouseEvent.MOUSE_UP,onClick);
child.buttonMode = true;
child.name = "child_"+i;
holder_mc.addChild(child);
}
main_content.addChild(holder_mc);
}
var holder_mask:Shape = new Shape();
holder_mask.graphics.lineStyle(1, 0x000000);
holder_mask.graphics.beginFill(0xff0000);
holder_mask.graphics.drawRect(-395, 100, 790, 75);
holder_mask.graphics.endFill();
main_content.addChild(holder_mask);
holder_mc.mask = holder_mask;
holder_mc.name = "holder_mc";
function onClick(event:MouseEvent):void {
}
function addScrollListeners():void {
holder_mc.addEventListener(MouseEvent.ROLL_OVER,toggleScroll);
holder_mask.addEventListener(Event.ENTER_FRAME, getThisWidth);
}
function getThisWidth():void {
if(holder_mc.width > 0) {holder_mask.removeEventListener(Event.ENTER_FRAME, getThisWidth)
holder_mc.x=-1*(holder_mc.width/2)
}
}
function toggleScroll(event:MouseEvent):void {
holder_mc.addEventListener(Event.ENTER_FRAME, scrollThumbs);
}
function scrollThumbs(event:Event):void {
if(mouseX > 790/2) {
holder_mc.x -=5;
if(holder_mc.x <=790/2-holder_mc.width){
holder_mc.x = 790/2-holder_mc.width;
}
}
if(mouseX < 790/2) {
holder_mc.x +=5;
790-holder_mc.width;
if(holder_mc.x>=((790/2)*-1)){
holder_mc.x =((790/2)*-1);
}
}
}
addScrollListeners();
trace(main_content.holder_mc.numChildren);
/*if (main_content.holder_mc.numChildren > 0) {
trace(main_content.holder_mc.numChildren);
}
*/
}
I am trying to figure out how to remove the children added by the xml file.
Once I can detect the movies I think I should just be able to remove them with removeChild etc…
Its not pretty but its how I got it to work. I neeeeeed to buy a as3 book, coming from mx this is tragic.
Here is the error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at home6_fla::MainTimeline/LoadProjects()
at MethodInfo-173()
Which I guess means that its empty. It loads fine etc, but as I change between screens it holds the children of that movie. I figure once I can get this figured out I can go back and clean up the rest of the mess.
Since I can hardly see my screen anymore I apologize in advance for any typos