Hello all.
Im attempting to display xml generated text in 2(or more) dynamic textfields. One textfield under the thumbnail and 2 or more textfields next to the large image that loads.
Ive posted an example where I put text in the dynamic text fields just to show location and how it should work: http://www.davidmcneal.com/as3/xml/site.html
I keep getting undefined errors. I’ve made minor adjustments from the original source: http://www.flashperfection.com/tutorials/Scrolling-Photos-Loaded-Dynamically-with-ActionScript-3-52067.html
I think the error might be a typo. Ive pasted the AS and you can click the link for the zip if any want to take a crack at this issue: http://www.davidmcneal.com/as3/flash_xml_gallery.zip
Thanks for any help.
Dav
----------------ERROR I KEEP GETTING----------------------------
1120: Access of undefined property arrayThumb.
1120: Access of undefined property arrayThumb.
1120: Access of undefined property thumbsDescription.
--------------------XML----------------------------
<images>
<image>
<url>pics/thumb1.jpg</url>
<big_url>big_pics/img_1.png</big_url>
<descriptionThumb>PIC UNO</descriptionThumb>
<descriptionPic>Number one PHOTO</descriptionPic>
</image>
<image>
<url>pics/thumb2.jpg</url>
<big_url>big_pics/img_2.png</big_url>
<descriptionThumb>PIC DOS</descriptionThumb>
<descriptionPic>Number two PHOTO</descriptionPic>
</image>
----------------------AS-----------------------------
//---------loading the external xml file-------
var urlRequest:URLRequest = new URLRequest(“pics0.xml”);
var urlLoader:URLLoader = new URLLoader();
var myXML:XML = new XML();
var xmlList:XMLList;
myXML.ignoreWhitespace = true;
urlLoader.addEventListener(Event.COMPLETE,fileLoaded);
urlLoader.load(urlRequest);
var arrayDescription:Array = new Array();
var arrayThumbDescription:Array = new Array();
//--------holds the paths to the thumbnails-------
var arrayURL:Array = new Array();
//--------holds the paths to the big photos-------
var arrayName:Array = new Array();
//--------holds the thumbnails objects-------
var holderArray:Array = new Array();
//-------represents the container of our gallery
var sprite:Sprite = new Sprite();
addChild(sprite);
var thumb:Thumbnail;
//-------- the thumbnails container-------
/var prevContainer:Sprite = new Sprite();
sprite.addChild(prevContainer);/
//-------- the photoLoader container-------
var loaderHolder:Sprite = new Sprite();
loaderHolder.graphics.beginFill(0xffffff,1);
loaderHolder.graphics.drawRect(0,0,950,450);
loaderHolder.graphics.endFill();
loaderHolder.x = 1000;
loaderHolder.y = 10;
sprite.addChild(loaderHolder);
//-------- loads the big photo-------
var photoLoader:UILoader = new UILoader();
photoLoader.width = 540;
photoLoader.height = 320;
photoLoader.y = 5;
photoLoader.x = 5;
photoLoader.buttonMode = true;
photoLoader.addEventListener(MouseEvent.CLICK,onClickBack);
full_mc.addChild(photoLoader);
function fileLoaded(event:Event):void {
myXML = XML(event.target.data);
xmlList = myXML.children();
for (var i:int=0; i<xmlList.length(); i++) {
var picURL:String = xmlList*.url;
var picName:String = xmlList*.big_url;
arrayURL.push(picURL);
arrayName.push(picName);
holderArray* = new Thumbnail(arrayURL*,i,arrayName*);
holderArray*.addEventListener(MouseEvent.CLICK,onClick);
holderArray*.name = arrayName*;
holderArray*.buttonMode = true;
holderArray*.y = 50;
holderArray*.x = i*325+50;
prevContainer.addChild(holderArray*);
///------- PIC DESCRIPTION
var picDescription:String = xmlList*.descriptionPic;
arrayDescription.push(picDescription);
arrayThumb*.name = arrayDescription*;
arrayThumb*.addEventListener(MouseEvent.CLICK,showDescription);
function showDescription(event:MouseEvent):void{
full_mc.blurbText.text = String(event.currentTarget.name);
trace (event.currentTarget.name);
}
//------- THUMB DESCRIPTION ---------
var picThumbDescription:String = xmlList*.descriptionThumb;
arrayThumbDescription.push(thumbsDescription);
arrayThumbDescription*.name = arrayDescription*;
arrayThumbDescription*.addEventListener(MouseEvent.CLICK,showThumbDescription);
function showThumbDescription(event:MouseEvent):void{
prevContainer.thumbText.text = String(event.currentTarget.name);
trace (event.currentTarget.name);
}
}
}
//----handles the Click event added to the thumbnails–
function onClick(event:MouseEvent):void {
photoLoader.source = event.currentTarget.name;
Tweener.addTween(full_mc,{x:0, time:1});
Tweener.addTween(prevContainer,{x:-950, time:1});
scrollOutPrev();
}