-
Error 1010
Hey,
Working on a picture gallery with multiple pages. The basic idea of what I'm trying to do is I get a list of all thumbs, separate the list in groups of 20 and then add all the groups to a MC that slides left and right when the user presses a left or right button.
This is the code I've written:
Code:
if ((totalPics % 20) > 0)
{
pages = Math.floor(totalPics / 20) + 1;
} else {
pages = Math.floor(totalPics / 20);
}
for (var u:uint = 0; u < pages; i++)
{
if ((totalPics - minPic) > 20)
{
maxPic = minPic + 20;
} else {
maxPic = minPic + (totalPics - minPic);
}
for (var i:uint = minPic; i < maxPic; i++)
{
var thumbPath:String = variables.folder + "/" + fileArray[i].toString();
thumbWidth = (container.width - 68) * 0.20;
thumbHeight = (container.height - 10) * 0.25;
var pageX:uint = u * ((thumbWidth + 2) * 5);
var thumb:Thumbnail = new Thumbnail(thumbPath, thumbWidth, thumbHeight);
thumb.x = ((i % 5) * (thumbWidth + 2)) + 30 + pageX;
thumb.y = (Math.floor(i / 5) * (thumbHeight + 2)) + 2;
thumb.name = i.toString();
thumb.buttonMode = true;
thumb.mouseChildren = false;
thumb.mouseEnabled = true;
thumb.useHandCursor = true;
thumb.addEventListener(MouseEvent.CLICK, thumbClick);
thumbContainer.addChild(thumb);
thumbArray.push(thumb);
}
minPic += 21;
maxPic += 20;
}
The bolded out line throws a 1010: A term is undefined and has no properties error.
However, in the debugger, all my values are tracing:
u = 0
i = 58
thumbPath = "img/IMG_9098.jpg"
pageX = 0
So what's going wrong here?
I mean it seems like the value is doing what it's suppose to.
I've traced the fileArray[i] individually and I'm getting my value back. The variables.folder also traces to what it's suppose to.
What should I look into?
-
OK so I fixed it. I guess I didn't account for zero and the value returned was the previous one in the debugger.
-
Btw, notice how in my first for statement I have for (var u:uint = 0; u < pages; i++)?
Don't ever do that. You'll get an error that says
Error #1502: A script has executed for longer than the default timeout period of 15 seconds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|