Hi all,
I am a newbie in Flash and having might be a very simple problem to you, but I really hope people here is able to help me solve this. Been stuck for 3 days now. Trying to modify some code and for my usage.
I am trying to load images from external XML files, and display on a movieClip name thumb_mc, The following codes will generates a list of buttons using button_mc, my task here is to add a thumbnails to each button from each record of xml.
I have added below codes in red, However, what I am getting is the thumbnails are overlapping each other. What should I do to make it display on the thumb_mc on each button?
public function showXML(e:Event):void {
XML.ignoreWhitespace = true;
xml = new XML(e.target.data);//loading the xml
//more variable declaring after the xml has loaded
//xml var extract
var slideTime:Number = xml.settings.slideTime;
ttype= xml.settings.transition;
ttime= Number(xml.settings.animationTime);
xs = xml.pixel.xSections;
ys = xml.pixel.ySections;
str = xml.blinds.numStrips;
w= xml.settings.width;
posi = xml.settings.height*89/100;
h = xml.settings.height;
//we set up the buttons position from xml
if (xml.settings.buttonsPosition=="right") {
buttonsCon.x = w - int(xml.settings.buttonsWidth);
buttonsCon.alpha = 1;
} else {
imgcon.x = int(xml.settings.buttonsWidth);
}
if (ttype == "random") {
randomise();
}
//adding the compnonents on stage
addChild(imgcon);
setChildIndex(imgcon,0);
addChild(buttonsCon);
for (i=0; i< xml.picture.length(); i++) {
var image_mc:MovieClip = new Image();
//setting up the image loaded by the 'container' class
image_mc.x=mpoz;
image_mc.y=0;
mpoz=mpoz+w;
image_mc.setImage(new URLRequest(xml.picture*.file),xml.picture*.url,xml.picture*.target,w,int(xml.settings.height),i,xml.picture*.description);
img.push(image_mc);
image_mc.buttonMode = true;
imgcon.addChild(image_mc);
//settting up the scrolling menu
var button_mc:MovieClip = new Button();
button_mc.title_txt.htmlText = xml.picture*.buttonTitle;
Tweener.addTween(button_mc.title_txt, { _color:uint(xml.settings.buttonsTitleNormalColor), time:0 } );
Tweener.addTween(button_mc.text_mc, { _color:uint(xml.settings.buttonsTextNormalColor), time:0 } );
button_mc.text_mc.text_txt.htmlText = xml.picture*.buttonText;
button_mc.y = poz;
button_mc.bg_mc.width = xml.settings.buttonsWidth;
button_mc.stroke_mc.width = int(xml.settings.buttonsWidth) + 1;
button_mc.title_txt.width = int(xml.settings.buttonsWidth) - 14;
button_mc.text_mc.text_txt.width = int(xml.settings.buttonsWidth) - 14;
poz += int(xml.settings.buttonsSpacing);
button_mc.text_mc.y = button_mc.title_txt.y + int(xml.settings.buttonsTitleTextSpacing);
button_mc.nr = i;
[COLOR=Red]//setting up the thumbnails
l.load(new URLRequest(xml.picture*.thumbnail));
button_mc.thumb_mc.addChild(l);
//button_mc.thumb_mc.addChild(l).y = -10;[/COLOR]
//if the user wants the buttons to have shadow we set it up
if (xml.settings.buttonsShadow == "on") {
button_mc.shadow_mc.cacheAsBitmap = true;
button_mc.shadow_mc.visible = true;
button_mc.shadow_mc.alpha = xml.settings.buttonsShadowAlpha;
button_mc.shadow_mc2.x = int(xml.settings.buttonsWidth) + 6;
button_mc.shadow_mc2.visible = true;
button_mc.shadow_mc2.alpha = xml.settings.buttonsShadowAlpha;
} else {
button_mc.shadow_mc.visible = false;
button_mc.shadow_mc2.visible = false;
}
//we set up the stroke and background
button_mc.mouseChildren = false;
button_mc.buttonMode = true;
Tweener.addTween(button_mc.stroke_mc, { _color:uint(xml.settings.buttonsStrokeColor), time:0 } );
button_mc.bg_mc.gotoAndStop(1);
if (xml.settings.buttonsPosition != "right") {
button_mc.stroke_mc.strokeleft.x = int(xml.settings.buttonsWidth);
button_mc.stroke_mc.strokedown.x = 0;
}
//we add listeners for the events that will happen
button_mc.addEventListener(MouseEvent.ROLL_OVER, handleButtonMouse);
button_mc.addEventListener(MouseEvent.ROLL_OUT, handleButtonMouse);
button_mc.addEventListener(MouseEvent.CLICK, handleButtonMouse);
buttonArray.push(button_mc);
if (i == 0) {
//we set up the current button that is the first
Tweener.addTween(button_mc.bg_mc, { _frame:60, time:0 } );
currButton = button_mc;
Tweener.addTween(currButton.title_txt, { _color:uint(xml.settings.buttonsTitleSelectedColor), time:0 } );
Tweener.addTween(currButton.text_mc, { _color:uint(xml.settings.buttonsTextSelectedColor), time:0 } );
}
buttonsCon.addChild(button_mc);
}
//poz -= int(xml.settings.buttonsSpacing);
function stoptimer() {
timer.reset();
}
function eVisible():void {
}
var rect:Sprite = new Sprite();
rect.graphics.beginFill(0xFFFFFF);
rect.graphics.drawRect(0, 0, w, h);
rect.graphics.endFill();
addChild(rect);
mask = rect;
//if the slideshow is on in the xml we start it
if (xml.settings.autoPlay=="on") {
timer.start();
} else {
stoptimer();
}
function handleSlideshow(e:TimerEvent):void {
if (e.currentTarget.currentCount / 100 == xml.settings.slideTime) {
gotoNext();
}
}
//we add listeners to the enter frame and timer functions
timer.addEventListener(TimerEvent.TIMER, handleSlideshow);
addEventListener(Event.ENTER_FRAME, handleFrame);
buttonsCon.addEventListener(MouseEvent.ROLL_OVER, handleButtonsMouse);
buttonsCon.addEventListener(MouseEvent.ROLL_OUT, handleButtonsMouse);
}
please help! Thank you.
KarSin