1046: Type was not found is grabbing random MovieClips
I'm pretty new to AS3, and I've been making a drag and drop game. I made 2 separate classes, each never referencing the other. One is for draggable items and one is for the menu.
Menu.as contains the code to bring the menu up and down at the press of the spacebar: function menuUp and menuDown
Draggable.as contains the startDrag and stopDrag codes connected to mouse clicks. The basic stuff.
When I test the movie, I get this error:
C:\Users\######\Documents\SonicMenu\Menu.as, Line 5, Column 2 1046: Type was not found or was not a compile-time constant: explosion1.
Explosion1 is a movieclip that is attached to the base class of Draggable, but is not referenced in Menu.as
Here is the line that Flash points to when receiving the error.
package {
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
*/this line is the error one/* public class Menu extends MovieClip {
public function Menu() {
stage.addEventListener(KeyboardEvent.KEY_DOWN, bring_up_menu_scn1);
stage.addChild(this)
}
Here are the entire class files. I know my code is really bad, but I really need this problem fixed.
Draggable.as
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class draggable extends MovieClip {
public function draggable() {
addEventListener(MouseEvent.MOUSE_DOWN, drag);
addEventListener(MouseEvent.MOUSE_UP, stop_drag);
}
function drag(evt: MouseEvent): void {
stage.addChild(this)
startDrag();
}
function stop_drag(evt: MouseEvent): void {
stage.addChild(this)
stopDrag();
}
}
}
Menu.as
package {
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
public class Menu extends MovieClip {
public function Menu() {
stage.addEventListener(KeyboardEvent.KEY_DOWN, bring_up_menu_scn1);
stage.addChild(this)
}
var menu_up: Boolean = false
function bring_up_menu_scn1(evt: KeyboardEvent): void {
if (evt.keyCode == 32) {
if (menu_up == false) {
menuUp()
} else {
menuDown();
}
}
}
function menuUp(): void {
x = 0
y = 0
menu_up = true
stage.setChildIndex(this, stage.numChildren - 1)
}
function menuDown(): void {
x = 550
y = 400
menu_up = false
}
}
}
I hope you can see how it works... It's really bad.
