ok im kinda lost here i have my game a simple race avoider type thing if anyone remembers the old games where the background scrolled along and the objects came at you and the you had to avoid them well thats what mi trying to recreate. i did it once before but then itried cs3 and it ruined my fla so i couldnt use it anywhere and even the swf got screwed so now im stuck at my duplicating the movie clip randomly inside of the playing area. ill put up the code then explain.
onClipEvent (load) {
vx = 5;
vy = 5;
friction = 0.55;
i = 0;
rand = 0;
}
onClipEvent (enterFrame) {
vx *= friction;
vy *= friction;
this._x += vx;
this._y += vy;
if (Key.isDown(Key.RIGHT)) {
vx += 5;
}
this._x += vx;
this._y += vy;
if (Key.isDown(Key.LEFT)) {
vx -= 5;
}
this._x += vx;
this._y += vy;
if (Key.isDown(Key.UP)) {
vy -= 5;
_rotation = -3;
}
this._x += vx;
this._y += vy;
if (Key.isDown(Key.DOWN)) {
vy += 5;
_rotation = 3;
}
if (!Key.isDown(Key.UP) and (!Key.isDown(Key.DOWN))) {
_rotation = 0;
}
_root.topwall_mc._x -= 20;
if (_root.topwall_mc._x<15) {
_root.topwall_mc._x = 275;
}
_root.botwall_mc._x -= 20;
if (_root.botwall_mc._x<15) {
_root.botwall_mc._x = 275;
}
_root.lines_mc._x -= 20;
if (_root.lines_mc._x<15) {
_root.lines_mc._x = 275;
}
if (_root.car_mc._y<=155 or _root.car_mc._y>=290 or _root.car_mc._x<=0 or _root.car_mc._x>=400) {
friction = -1;
} else {
friction = .44;
}
if(i<=4){
rand = Math.round((Math.random()*(290-155))+155)+1;
_root.object_mc.duplicateMovieClip(object1,i);
setProperty(object1, _x, rand);
trace(object1._x);
i++
}
if(i>=5){
i=0;
}
ok so theres my code the first part is just my movement which is friction movement for realism and the rotation makes my car turn when you move but thats not the problem if you look at the last block of code starting at if(i<=4){ thats where my code starts and im trying to get this to duplicate the movie clip and if i put in a normal ‘object’+i and trace it itll give me all the instance names naturally but if i trace the x position it just says undefined and also if anyone could tell me how you call ‘object’+i in a statement that would be awesome but if anyone could help me im still pretty new at duplicate movie clip but have a pretty good idea of actionscript. any help would be great.