|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
stopping movieclip when reaches end
I'm creating a small sliding app which slides images left to right using next and previous buttons, however the clip continues to slide even if it goes off the stage. I would like it to stop when the last image of 'slider' has reached the edge of the stage. Can someone take a look at my code attached to the 'slider' in my movie? Thanks for any help!
Here's the AS attached to 'slider' (there is not instance name for it, it's just the movieclip slider): Code:
// initialize movie to starting point
onClipEvent (load) {
_x = 0;
_y = 0;
div = 5;
}
// sliding action
onClipEvent (enterFrame) {
_x += (endX-_x)/div;
_y += (endY-_y)/div;
// previous button
_root.previous.onRelease = function() {
endX += 750;
/*endY += 0;*/
};
// next button
_root.next.onRelease = function() {
endX -= 750;
/*endY -= 0;*/
};
}
|
|
#2
|
|||
|
|||
|
Hi, I'm not at a machine with flash installed right now. It seems pretty straight forward though:
Code:
// initialize movie to starting point
onClipEvent (load) {
_x = 0;
_y = 0;
div = 5;
// These two are just my rough guesses
minX = 0;
maxX = 750*numberOfImages;
// previous button
_root.previous.onRelease = function() {
endX += 750;
/*endY += 0;*/
};
// next button
_root.next.onRelease = function() {
endX -= 750;
/*endY -= 0;*/
};
}
// sliding action
onClipEvent (enterFrame) {
if(endX > minX || endX < maxX)
{
_x += (endX-_x)/div;
_y += (endY-_y)/div;
}
All you have to do is work out what minX and maxX should be. Without looking at your source file I can't really say how to do this. I moved the button functions to onload as they should only really be created once. |
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > stopping movieclip when reaches end |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|