FORUMS: list search recent posts

movieClips acting crazy!!

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
dlacloche
movieClips acting crazy!!
on Oct 10, 2006 at 4:26:32 am

As a motion graphic artist who's been working with keyframes forever, it's really blowing my mind that you can create cool animation with just code. Being new to this concept, I can't figure out how to get this to happen:

onRelease, movieClip1 (where ever it happens to be at the time of click) travels to x=150, y=60 of the stage. And the other movieClips--movieClip2, movieClip3, movieClip4, and movieClip5 move to the left side of the stage, x=75 y=200, 250, 300, and 350 respectively.

And of course, I want the same to happen to the other movieClips--when you click on them they go to x=150, y=60 and the others go off to the side.

I have some ActionScript that works on the first click of any movieClip, but if you click any movieClip after that, all the movieClips gravitate to eachother. The more you click the closer they get, until they're all overlapping and jittering around a little. Also, when I roll over a button symbol that isn't even near the movieClips, they start jumping all over the stage. They've gone crazy!!

I'm new at all this, and I need help. Thanks.
Here's the code:

var startX2 =_root.ball2._x
var startY2 =_root.ball2._y
var startX1 =_root.ball1._x
var startY1 =_root.ball1._y
var startX3 =_root.ball3._x
var startY3 =_root.ball3._y
var startX4 =_root.ball4._x
var startY4 =_root.ball4._y
var startX5 =_root.ball5._x
var startY5 =_root.ball5._y
var endX1 = 75
var endY1 = 200
var endX2 = 150
var endY2 = 250
var endY3 = 300
var endY4 = 350
var endY5 = 400
var endY6 = 60

var speed = 10
ball2._x = startX2
ball2._y = startY2
ball1._x = startX1
ball1._y = startY1
ball3._x = startX3
ball3._y = startY3
ball4._x = startX4
ball4._y = startY4
ball5._x = startX5
ball5._y = startY5
function moveMe2(targ){
targ._x+=(_root.endX1-targ._x)/_root.speed;
targ._y+=(_root.endY1-targ._y)/_root.speed
}
function moveMe1(targ){
targ._x+=(_root.endX2-targ._x)/_root.speed;
targ._y+=(_root.endY6-targ._y)/_root.speed
}
function moveMe3(targ){
targ._x+=(_root.endX1-targ._x)/_root.speed;
targ._y+=(_root.endY2-targ._y)/_root.speed
}
function moveMe4(targ){
targ._x+=(_root.endX1-targ._x)/_root.speed;
targ._y+=(_root.endY3-targ._y)/_root.speed
}
function moveMe5(targ){
targ._x+=(_root.endX1-targ._x)/_root.speed;
targ._y+=(_root.endY4-targ._y)/_root.speed
}

stop();


ball1.onRollOver = function () {
this.reverser_mc.gotoAndStop(1);
this.play(1);
}

ball1.onRollOut = function () {
this.reverser_mc.gotoAndPlay(2);
}

ball1.onPress = function () {
this.gotoAndStop(15);
}

ball1.onRelease = function () {
this.gotoAndStop(1);
}
ball1.onRelease = function () {
setInterval(moveMe1,30,_root.ball1);
setInterval(moveMe2,30,_root.ball2);
setInterval(moveMe3,30,_root.ball3);
setInterval(moveMe4,30,_root.ball4);
setInterval(moveMe5,30,_root.ball5);
}

ball2.onRollOver = function () {
this.reverser_mc.gotoAndStop(1);
this.play(1);
}

ball2.onRollOut = function () {
this.reverser_mc.gotoAndPlay(2);
}

ball2.onPress = function () {
this.gotoAndStop(15);
}

ball2.onRelease = function () {
setInterval(moveMe1,30,_root.ball2);
setInterval(moveMe2,30,_root.ball3);
setInterval(moveMe3,30,_root.ball4);
setInterval(moveMe4,30,_root.ball5);
setInterval(moveMe5,30,_root.ball1);
}


ball3.onRollOver = function () {
this.reverser_mc.gotoAndStop(1);
this.play(1);
}

ball3.onRollOut = function () {
this.reverser_mc.gotoAndPlay(2);
}

ball3.onPress = function () {
this.gotoAndStop(15);
}

ball3.onRelease = function () {
setInterval(moveMe1,30,_root.ball3);
setInterval(moveMe2,30,_root.ball4);
setInterval(moveMe3,30,_root.ball5);
setInterval(moveMe4,30,_root.ball1);
setInterval(moveMe5,30,_root.ball2);
}


ball4.onRollOver = function () {
this.reverser_mc.gotoAndStop(1);
this.play(1);
}

ball4.onRollOut = function () {
this.reverser_mc.gotoAndPlay(2);
}

ball4.onPress = function () {
this.gotoAndStop(15);
}

ball4.onRelease = function () {
setInterval(moveMe1,30,_root.ball4);
setInterval(moveMe2,30,_root.ball5);
setInterval(moveMe3,30,_root.ball1);
setInterval(moveMe4,30,_root.ball2);
setInterval(moveMe5,30,_root.ball3);
}


ball5.onRollOver = function () {
this.reverser_mc.gotoAndStop(1);
this.play(1);
}

ball5.onRollOut = function () {
this.reverser_mc.gotoAndPlay(2);
}

ball5.onPress = function () {
this.gotoAndStop(15);
}

ball5.onRelease = function () {
setInterval(moveMe1,30,_root.ball5);
setInterval(moveMe2,30,_root.ball1);
setInterval(moveMe3,30,_root.ball2);
setInterval(moveMe4,30,_root.ball3);
setInterval(moveMe5,30,_root.ball4);
}



Return to posts index

lajoiet
Re: movieClips acting crazy!!
on Oct 10, 2006 at 10:28:15 am

Well, I've done very smilar things using the Tween Class which allows you to tween things from one location to another over a period of time (but since I was turned on to the FUSE tweening engine, I can see it as the ideal way to do what you're trying to do, if you want to learn about that go to Lee Brimelow's tutorials at http://www.gotoandlearn.com and watch the 2 video tutorials on using FUSE).

That said, looking at your code and figuring as much as I can (I prefer to stay away from intervals, so I'm not that up on their coding) it looks like you aren't giving the intervals an instance name when you create them, and along the same lines, you are never removing them. So as your code runs over and over, the intervals keep piling up and competing with each other. To keep your code the way it is, I would look into giving your intervals variable names and setting the functions (like moveMe1) to check to see if the object has reached it's destination and if so, clear the interval.

If you're looking to re-work your code a bit on this project and make your future code animating life easier, look into the FUSE Engine.

>Todd
_____________________________________

I'm filling a need. Without me there would be no bad examples.
_____________________________________


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]