I have a bit of code that doesn’t do what I want it to do. As this is not an uncommon occurence, I’ll elaborate!
The piece of code is a modified (by me) snippet from the ‘‘Adding thumbnails’’ tutorial for the XML gallery here on kirupa.
[IMG]file:///J:/DCIM/124CANON/IMG_2480.JPG[/IMG]function thumbNailScroller() {
this.createEmptyMovieClip("tscroller", 1000);
scroll_speed = 10;
this.onMouseDown=function()
{
MouseDown=true
}
this.onMouseUp=function()
{
MouseDown=false
}
tscroller.onEnterFrame = function() {
if ((_root._ymouse>=thumbnail_mc._y) && (_root._ymouse<=thumbnail_mc._y+thumbnail_mc._height)) {
if ((_root._xmouse>=(hit_right._x-40)) && (thumbnail_mc.hitTest(hit_right)) && (MouseDown == true)) {
thumbnail_mc._x -= scroll_speed;
} else if ((_root._xmouse<=23) && (thumbnail_mc.hitTest(hit_left) && (MouseDown == true))) {
thumbnail_mc._x += scroll_speed;
}
} else {
delete tscroller.onEnterFrame;
}
};
}
This code works more or less fine, with the sidenote that the buttons will cease functioning when you release the mouse outside one. Thats a minor issue I’m sure I can find a way to fix. (although I’m open to suggestions )
The main issue is that these buttons stop working completely when I load the .swf containing above code into a movieclip in my ‘‘main’’ flash file.
I’m using
PortfolioContainer.loadMovie("Portfolio.swf");
to load it. Everything inside the portfolio.swf works as its supposed to when its loaded into the ‘PortfolioContainer’ moveclip, but the thumbnail buttons do not.
I’ve tried adding a _root here and there, but that didn’t seem to change anything. I have a feeling the code can’t find the hit_left and hit_right buttons for some reason, but am unsure how to fix that.
I’d appreciate it if someone would be kind enough to take a look at this and hopefully see whats wrong!