Hey Everyone, My problem is that I get an error that says access of undefined property root, and what I’m trying to do is to recreate this tutorial in action script 3.0
http://www.kirupa.com/developer/actionscript/vertical_shooter.htm
My problem is that in the symbols, theres a actionscript code _root.activeArrows = true; and its not letting me run the game.
How can i replace _root so that the command works equivalently in as3 ?
Also, the names have been changed so in the tutorial, it was knight, but now its penguin, and dragon is now birds.
stop();
//---- variables ----
var steps:Number = 5;
var spriteX:Number = 265;
var spriteY:Number = 265;
var speed:Number = 25;
var arrowActive:Boolean = false;
var birds:Number = 3;
var i:Number = 0;
var score:Number = 0;
//TROUBLESHOOTING CODES
//---- properties ----
penguin_game.swapDepths(10);
//---- functions ----
stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKeys);
stage.addEventListener(KeyboardEvent.KEY_UP, checkKeys);
function checkKeys() {
if (penguin_game.keyCode == 39 && spriteX<510) {
spriteX += steps;}
else if (penguin_game.keyCode == 37 && spriteX>40) {
spriteX -= steps;
}
if (KeyboardEvent.KEY_UP && arrowActive == false) {
penguin.arms.play();
attachMovie("arrow", "arrows", 8);
arrows._x = spriteX;
arrows._y = spriteY+50;
//arrowActive = true
}
}
function updatepenguin() {
penguin_game._x = spriteX;
penguin_game._y = spriteY;
}
function updateArrow() {
if (arrowActive == true) {
arrows._y -= speed;
}
if (arrows._y<-10) {
arrowActive = false;
removeMovieClip(arrows);}
}
function initbirds() {
for (i; i<birds; i++) {
attachMovie("bird", "bird"+i, i);
[COLOR="Blue"]bird = _root("arrows")["bird"+i];[/COLOR]
updatebirds(bird);
bird.onEnterFrame = function() {
if (this.hitTest(arrows)) {
score += 1;
trace(score);
counter++;
trace(counter++);
arrowActive = false;
removeMovieClip(arrows);
updatebirds(this);
if(counter == 5){
this.gotoAndPlay(702);}
}
if (this._x>0) {
this._x -= this.velo;
} else {
updatebirds(this);
}
};
}
}
initbirds();
function updatebirds(which) {
which._x = random(100)+530;
which._y = random(80)+20;
which.velo = random(10)+2;
}
this.onEnterFrame = function() {
checkKeys();
updatepenguin();
updateArrow();
};