-
Moving square
Hi...
I want to make a flash page with a square (containing text and pictures) that moves horizontal when the menubuttons are pressed.
I've found an example af the effect here...
http://www.fiveight.com/
But I can't figure out how it's done :(
Can anyone help me out??
Thanks in advance
J-12
-
Let's assume you have the flash movie you want to move and it has an instance name of movingMovie.
Let's also assume you have some buttons with instance names of button1, button2, etc.
let us further assume that within your flash movie's library you have several content movies you want to go on the movingMovie and these movies have linkage names of content1, content2, etc.
In timeline of your flash project (NOT in the timeline of the various movie clips) some code like this might do what you want.
Code:
var currentX:Number = 0;
var contentMovieDepth = movingMovie.getNextHighestDepth();
this.movingMovie.onEnterFrame = function() {
if (movingMovie._x == currentX) {
return; // we good...movie is in right place
}
var xDiff:Number = currentX - movingMovie._x;
if (Math.abs(xDiff) < 1) {
movingMovie._x = currentX;
} else {
var deltaX:Number = xDiff * 0.1;
trace(deltaX);
movingMovie._x += deltaX;
}
}
button1.onRelease = function() {
currentX = 100;
movingMovie.attachMovie('content1', 'content', contentMovieDepth);
}
button2.onRelease = function() {
currentX = 200;
movingMovie.attachMovie('content2', 'content', contentMovieDepth);
}