Hi
I’m new to this forum and new to AS3 so please igoner my stupidness. I’m trying to build a photo gallery and have almost got there but I am stuck with one error that I can’t get rid of or find the answer too, which is:
ReferenceError: Error #1069: Property picCaption not found on Thumbnail and there is no default value.
at photoGallery_fla::MainTimeline/onClickHorizontal()
The error happens on the following line which is in the last function of the second block of code below:
photoDescVertical.text = event.currentTarget.picCaption;
When I debug and put a break point on the line and in the veriable window expand event.currentTarget picCaption is there and has the text I expect, so why am I getting the error?
This is hopefuly all the code to help me out!
//---------loading the external xml file-------
var urlRequest:URLRequest = new URLRequest(xmlStr);
var urlLoader:URLLoader = new URLLoader();
var myXML:XML = new XML();
var xmlList:XMLList;
myXML.ignoreWhitespace = true;
//--------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 captions to the big photos-------
var arrayCaption:Array = new Array();
//--------holds the thumbnail objects-------
var holderArray:Array = new Array();
//--------represents the number of collumns-------
var nrColumns:uint = 2;
//-------represents the container of our gallery
var sprite:Sprite = new Sprite();
addChild(sprite);
var thumb:Thumbnail;
//-------- set up variables for scrolling thumbnails-------
var MAXPIXELS:Number = 12;
import fl.containers.UILoader;
import caurina.transitions.*;
//---------loading the external xml file-------
urlLoader.addEventListener(Event.COMPLETE,fileLoadedHorizontal);
urlLoader.load(urlRequest);
//-------- the thumbnails container-------
var thumbsHolderHorizontal:Sprite = new Sprite();
thumbsHolderHorizontal.x = 25;
sprite.addChild(thumbsHolderHorizontal);
thumbsHolderHorizontal.mask=thumb_holder;
//-------- the photoLoaderHorizontal container-------
var loaderHolderHorizontal:Sprite = new Sprite();
loaderHolderHorizontal.graphics.beginFill(0xffffff,1);
loaderHolderHorizontal.graphics.drawRect(20,495,910,135);
loaderHolderHorizontal.graphics.endFill();
loaderHolderHorizontal.x = 20;
loaderHolderHorizontal.y = 495;
sprite.addChild(loaderHolderHorizontal);
//-------- loads the big photo-------
var photoLoaderHorizontal:UILoader = new UILoader();
photoLoaderHorizontal.width = 540;
photoLoaderHorizontal.height = 320;
photoLoaderHorizontal.y = 0;
photoLoaderHorizontal.x = 0;
photoLoaderHorizontal.buttonMode = true;
photoHolderHorizontal.addChild(photoLoaderHorizontal);
function fileLoadedHorizontal(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;
var picCaption:String = xmlList*.caption;
arrayURL.push(picURL);
arrayName.push(picName);
arrayCaption.push(picCaption);
holderArray* = new Thumbnail(arrayURL*,i,arrayName*,arrayCaption*);
holderArray*.addEventListener(MouseEvent.CLICK,onClickHorizontal);
holderArray*.name = arrayName*;
//holderArray*.picCaption = arrayCaption*;
holderArray*.buttonMode = true;
holderArray*.y = 562.5;
holderArray*.x = i*100+50;
thumbsHolderHorizontal.addChild(holderArray*);
}
}
thumbsHolderHorizontal.addEventListener(Event.ENTER_FRAME, rollOverHorizontal);
function rollOverHorizontal(event:Event) {
var w:Number = thumbsHolderHorizontal.width/2;
var hw:Number = thumb_holder.width/2;
var npixels:Number;
// only do when mouse over slider mask
if (mouseY > thumb_holder.y && mouseY < thumb_holder.y + thumb_holder.height) {
// mouse over left half of slider:
if (mouseX > thumb_holder.x && mouseX < thumb_holder.x + hw) {
npixels = (hw - mouseX) / hw * MAXPIXELS;
if (thumbsHolderHorizontal.x <= 25) {
if (thumbsHolderHorizontal.x + npixels <= 25) {
thumbsHolderHorizontal.x += npixels;
} else {
thumbsHolderHorizontal.x = 25;
}
}
// mouse over right half of slider:
} else if (mouseX > thumb_holder.x + hw && mouseX < thumb_holder.x + thumb_holder.width) {
npixels = (mouseX - hw) / hw * MAXPIXELS;
if (thumbsHolderHorizontal.x >= -w) {
if (thumbsHolderHorizontal.x + thumbsHolderHorizontal.width >= thumb_holder.x + thumb_holder.width) {
thumbsHolderHorizontal.x -= npixels;
}
}
}
}
}
//----handles the Click event added to the thumbnails--
function onClickHorizontal(event:MouseEvent):void {
photoDescVertical.text = event.currentTarget.picCaption;
photoLoaderHorizontal.source = event.currentTarget.name;
//Tweener.addTween(thumbsHolderHorizontal, {x:-650, time:1, transition:"easeInElastic"});
Tweener.addTween(loaderHolderHorizontal, {x:10, time:1, transition:"easeInElastic"});
//Tweener.addTween(thumbsHolderHorizontal, {alpha:0, time:1, transition:"linear"});
Tweener.addTween(loaderHolderHorizontal, {alpha:1, time:1, transition:"linear"});
}
stop();
private var nume:String;
private var url:String;
private var picCaption:String;
private var id:int;
private var urlRequest:URLRequest;
private var loader:UILoader;
function Thumbnail(source:String,itemNr:int,numeThumb:String,caption:String):void {
url = source;
id = itemNr;
this.nume = numeThumb;
picCaption = caption;
drawLoader();
addEventListener(MouseEvent.MOUSE_OVER,onOver);
addEventListener(MouseEvent.MOUSE_OUT,onOut);
scaleThumb();
}
private function drawLoader():void {
urlRequest=new URLRequest(url);
loader=new UILoader ;
loader.mouseEnabled=false;
loader.load(urlRequest);
loader.x=-50;
loader.y=-50;
addChild(loader);
}