moving 2 movieclips
- Started
- Last post
- 32 Responses
- legspin
How do you move 2 movieclips across the screen (x) using 1 button?
- unfittoprint0
function move(status, speed){
this.speed = speed;
if(status){
this.onEnterFrame = function(){
movieclip1._x += speed;
movieclip2._x += speed;
} else {
delete this.onEnterFrame;
}
}//usage
button.onPress = function(){
move(true, 5);
}button.onRelease = function(){
move(false);
}//for motion in the opposite direction use negative speeds.
- yah0
newClip1X = 300;
newClip2X = 400;
on(release){
_root.clip1._x = newClip1X;
_root.clip2._x = newClip2X;
}
- legspin0
thanks you two I'll give it a shot.
- yah0
Nice snippit unfittoprint! There's a small error in the code though:
function move(status, speed) {
this.speed = speed;
if (status) {
this.onEnterFrame = function() {
movieclip1._x += speed;
movieclip2._x += speed/2; //for fun...
}; // left this off
} else {
delete this.onEnterFrame;
}
}
//usage
button.onPress = function() {
move(true, 5);
};
button.onRelease = function() {
move(false);
};
//for motion in the opposite direction use negative speeds.
- legspin0
Not sure of how to tackle this but its giving me brain sickness.
This is what I want to acheive:
http://www.perspektiv.co.uk/nav_…Where the red band could be different widths as well - depending on what nav its over. How would you go about it?
- unfittoprint0
simple. make the band._width = button._width.
- legspin0
And the band behaves like this:
- yah0
Let's see your code...
- legspin0
on button:
on (release) {
this.targetX = 200;
}in movieclip:
// move across screen
startX = this._x;
newX = _parent.targetX;
destX = startX+((newX-startX)/9);
this._x = destX;
- legspin0
I think I could get something working if I could apply this code to an other movieclip but with obviously different x values. I was thinking maybe a grey band following the red one.????
- unfittoprint0
I would make a mask [imagine you want a image background in the back without stretching it], and within the loop you could including a line that stretchs the mask [_width] accordingly to the band's position.
- legspin0
Here's my flash file if that helps:
- Hizzle0
* bump
- yah0
Ok, think I got it, the code isn't pretty but you can clan it later...
http://owenmundy.com/Cook_testin…
Source...
owenmundy.com/Cook_testing/Zenit...
- legspin0
Genius!
I've downloaded something what sort of file is it?
- yah0
.SIT www.stuffit.com
- legspin0
Ha ha...cheers. I've got it now.
This is much appreciated.
- legspin0
The problem comes when I need the red band to be wider over some of the buttons.
- legspin0
Must go home now but will pick up responses tomorrow. Cheers for all the feedback.
- yah0
You bet! Good luck!