ACFan120
August 18th, 2010, 08:59 PM
I have this bit of coding for a game that I need help with.
The code is supposed to duplicate a movieclip, (that's already on the frame), on one end of the screen, move them to the other side of the screen, and move it back to the other side. The original file has the player at Flash 6. But when I increase the player to Flash 8, the player of the full Game, It doesn't appear to work. When I increase the SWF to full size, though, the Movieclip is at the Loading point of the screen. I don't know why it does this, and it's crucial that I recieve help. I will include a link to download the FLA down below, but in case someone could just look at the code, here it is:
Movieclip's coding:
onClipEvent (load) {
function reset() {
this._x = 575;
this._y = math.random()*335;
enemySpeed = (math.random()*6)+5;
}
reset();
}
onClipEvent (enterFrame) {
this._x -= enemySpeed;
if (this._x<-22) {
reset();
}
if (this.hitTest("bullet")){
gotoAndStop(8)
}
}
Frame's actionscript:
stop();
var numEnemy = 5;
_root.score = 0;
var fire = false;
var enemy = 10;
function moveHero(speed) {
//check if key is down
if (Key.isDown(Key.LEFT)) {
_root.hero._x -= speed;
} if (Key.isDown(Key.RIGHT)) {
_root.hero._x += speed;
} if (Key.isDown(Key.UP)) {
_root.hero._y -= speed;
} if (Key.isDown(Key.DOWN)) {
_root.hero._y += speed;
}
if (Key.isDown(65)) {
if (fire == false) {
fireBullets();
}
}
}
var i = 1;
function fireBullets() {
i++;
fire = true;
_root.hero.gotoAndPlay(2);
var newname = "bullet"+i;
_root.attachMovie("bullet", newname, i*100);
_root[newname]._y = _root.hero._y-5;
_root[newname]._x = _root.hero._x+12;
_root[newname].onEnterFrame = function() {
var bullet_speed = 9;
this._x += bullet_speed;
if (this._x>655) {
this.removeMovieClip();
}
for (var h = 1; h<=numEnemy; h++) {
if (this.hitTest(_root["enemy"+h])) {
this.removeMovieClip();
_root["enemy"+h].play();
//trace("enemy"+h);
}
}
};
}
function Enemys() {
for (j=1; j<=numEnemy; j++) {
var name = "enemy"+j;
_root.enemy1.duplicateMovieClip(name, j);
}
}
Enemys();
_root.onEnterFrame = function() {
moveHero(enemy);
};
Now for the download Link:
http://www.mediafire.com/?4hlot1wmgwdo6id
The code is supposed to duplicate a movieclip, (that's already on the frame), on one end of the screen, move them to the other side of the screen, and move it back to the other side. The original file has the player at Flash 6. But when I increase the player to Flash 8, the player of the full Game, It doesn't appear to work. When I increase the SWF to full size, though, the Movieclip is at the Loading point of the screen. I don't know why it does this, and it's crucial that I recieve help. I will include a link to download the FLA down below, but in case someone could just look at the code, here it is:
Movieclip's coding:
onClipEvent (load) {
function reset() {
this._x = 575;
this._y = math.random()*335;
enemySpeed = (math.random()*6)+5;
}
reset();
}
onClipEvent (enterFrame) {
this._x -= enemySpeed;
if (this._x<-22) {
reset();
}
if (this.hitTest("bullet")){
gotoAndStop(8)
}
}
Frame's actionscript:
stop();
var numEnemy = 5;
_root.score = 0;
var fire = false;
var enemy = 10;
function moveHero(speed) {
//check if key is down
if (Key.isDown(Key.LEFT)) {
_root.hero._x -= speed;
} if (Key.isDown(Key.RIGHT)) {
_root.hero._x += speed;
} if (Key.isDown(Key.UP)) {
_root.hero._y -= speed;
} if (Key.isDown(Key.DOWN)) {
_root.hero._y += speed;
}
if (Key.isDown(65)) {
if (fire == false) {
fireBullets();
}
}
}
var i = 1;
function fireBullets() {
i++;
fire = true;
_root.hero.gotoAndPlay(2);
var newname = "bullet"+i;
_root.attachMovie("bullet", newname, i*100);
_root[newname]._y = _root.hero._y-5;
_root[newname]._x = _root.hero._x+12;
_root[newname].onEnterFrame = function() {
var bullet_speed = 9;
this._x += bullet_speed;
if (this._x>655) {
this.removeMovieClip();
}
for (var h = 1; h<=numEnemy; h++) {
if (this.hitTest(_root["enemy"+h])) {
this.removeMovieClip();
_root["enemy"+h].play();
//trace("enemy"+h);
}
}
};
}
function Enemys() {
for (j=1; j<=numEnemy; j++) {
var name = "enemy"+j;
_root.enemy1.duplicateMovieClip(name, j);
}
}
Enemys();
_root.onEnterFrame = function() {
moveHero(enemy);
};
Now for the download Link:
http://www.mediafire.com/?4hlot1wmgwdo6id