Forum Moderators: open
I got it to work with one box by saying box1._x ++ and so on, but I want there to be an argument in the move function that asks for the box number. here's what I have so far:
var xcoords = 100;
var ycoords = 100;
var speed = 1;
xmax = 540;
xmin = 0;
ymax = 400;
ymin = 0;
function populate (); {
boxes = new Array [
[
}
function moveObj (num) {
if (xcoords>xmax) {
xcoords = xmax;
} else if (xcoords<xmin) {
xcoords = xmin;
}
if (ycoords>ymax) {
ycoords = ymax;
} else if (ycoords<ymin) {
ycoords = ymin;
}
curx = _root.boxnum[num]._x;
cury = _root.boxnum[num]._y;
if (curx>xcoords) {
_root.boxnum[num]._x -= speed;
} else if (curx<xcoords) {
_root.boxnum[num]._x += speed;
}
if (cury>ycoords) {
_root.boxnum[num]._y -= speed;
} else if (cury<ycoords) {
_root.boxnum[num]._y += speed;
}
}
and its called from:
onClipEvent (enterFrame) {
_root.moveObj(1);
}
this does nothing. the coords work, and the limits work, but nothing moves. help me please!
//import transition classes----------------
import mx.transitions.Tween;
import mx.transitions.easing.*;//control clip--------------------
function moveclip(xfinish:Number,yfinish:Number) {
var xstart:Number = test_mc._x;
var ystart:Number = test_mc._y;
var xMove:Tween = new Tween(test_mc, "_x", Bounce.easeOut, xstart, xfinish, 3, true);
var yMove:Tween = new Tween(test_mc, "_y", Bounce.easeOut, ystart, yfinish, 3, true);
}//button function-------------------
moveit_btn.onPress = function(){
moveclip(300,200)
}