-
error 1069, i need help :(
i'm making a rythem game using gesture swipe function, but i get an error:
eferenceError: Error #1069: Property arrowCode not found on flash.display.Shape and there is no default value.
at bocahversi2_fla::MainTimeline/makeLvl()[bocahversi2_fla.MainTimeline::frame4:120]
this is my package code
Code:
package{
import flash.display.MovieClip;
import flash.events.*;
import flash.display.Shape;
public class Arrow extends MovieClip{
public var _root:Object;//we'll use this to refer to main timeline
public var arrowCode:int;//the keys that needs to be swiped
public function Arrow(){
this.addEventListener(Event.ADDED, beginClass);
this.addEventListener(Event.ENTER_FRAME, eFrame);
}
private function beginClass(e:Event):void{
_root = MovieClip(root); //typing _root is much easier than MovieClip(root)
stage.addEventListener(TransformGestureEvent.GESTURE_SWIPE, checkSwipe);
}
private function eFrame(e:Event):void{
this.y -= _root.arrowSpeed;//move it up the stage
//if game is over or it's off the stage, destroy it
if(_root.gameIsOver || this.y < 0){
//if off the stage
if(this.y < 0){
_root.scoreString = 'Bad';
}
destroyThis();
}
}
private function checkSwipe(e:TransformGestureEvent):void{
//checking if a certain key is down and it's touching the receptor
if((e.offsetX == 1 || e.offsetX == -1 || e.offsetY == 1 || e.offsetY == -1) && this.hitTestObject(_root.mcReceptor)){
//checking if the correct key is down
//if the user hits it about perfectly
//the receptors y coordinate is about 10 px away from the
//symbol's y coordinate.
if(this.y <= _root.mcReceptor.y + 15 && this.y >= _root.mcReceptor.y + 5){
_root.skor += 10;
_root.scoreString = 'Perfect';
} else if (this.y <= _root.mcReceptor.y + 25 && this.y >= _root.mcReceptor.y-5){
_root.skor += 8;
_root.scoreString = 'Great';
} else if (this.y <= _root.mcReceptor.y + 40 && this.y >= _root.mcReceptor.y -30){
_root.skor += 6;
_root.scoreString = 'Nice';
} else {
_root.skor += 4;
_root.scoreString = 'Good';
}
destroyThis();//remove it from stage
}
}
private function destroyThis():void{
this.removeEventListener(Event.ENTER_FRAME, eFrame);
stage.removeEventListener(TransformGestureEvent.GESTURE_SWIPE, checkSwipe);
_root.removeChild(this);
}
}
}
and this is my in frame code
Code:
stop();
stage.focus = stage;
//VARIABLES
//The array for the first level of the game
var lvlArray0:Array = new Array(2,4,1,1,3,4,2,3,1,3,2,4,1,4,2,4,3,1,2,3,1,4,3,3,2,4,1,2,3,4,3);
//The array holding all of the lvl arrays
var lvlArrayAll:Array = new Array(lvlArray0);
//sTime is the current frame that is being played
//Once it reaches sTempo, then it will be reset
//and a note will be created
var sTime:int = 0;
//sTempo is how many frames it takes before
//a note is created. Because it's 12, and
//the frame rate is 24, it will take a half of a second
//for a note to be made
var sTempo:Number = 12;
//sNote is the current arrow of the level that is created
//0 makes no arrow
//1 makes a left arrow
//2 makes an up arrow
//3 makes a down arrow
//4 makes a right arrow
var sArrow:int = 0;
//arrowSpeed is how fast the arrow moves up the screen
var arrowSpeed:Number = 40;
var skor:int = 0;
var scoreString:String = '';
//Booleans checking if the arrows are touching the receptor
var swipeLeft:Boolean = false;
var swipeUp:Boolean = false;
var swipeDown:Boolean = false;
var swipeRight:Boolean = false;
function beginCode():void{
addEventListener(Event.ENTER_FRAME, makeLvl);
//make the level array longer
lvlArrayAll[lvlCurrent].push(0,0,0,0,0);
}
function makeLvl(e:Event):void{
//code here will create the level
if(sTime < sTempo){
//if the required time hasn't reached the limit
//then update the time
sTime ++;
} else {
//if the time has reached the limit
//then reset the time
sTime = 0;
//if an actual arrow can be made
if(lvlArrayAll[lvlCurrent][sArrow] != 0){
var currentArrow:MovieClip; //this will hold the current arrow
if(lvlArrayAll[lvlCurrent][sArrow] == 1){
//place a left arrow onto the stage
currentArrow = new arrowLeft();
//set the _x value of the arrow so that it is in the
//right place to touch the receptor
currentArrow.x = 460;
//set the arrow's y coordinate off of the stage
//so that the user can't see it when it appears
currentArrow.y = 350;
//setting the key that needs to be pressed
currentArrow.arrowCode = 1;
addChild(currentArrow);//add it to stage
} else if(lvlArrayAll[lvlCurrent][sArrow] == 2){
//place an up arrow onto the stage
currentArrow = new arrowUp();
currentArrow.x = 460;
currentArrow.y = 350;
currentArrow.arrowCode = 2;
addChild(currentArrow);
} else if(lvlArrayAll[lvlCurrent][sArrow] == 3){
//place a down arrow onto the stage
currentArrow = new arrowDown();
currentArrow.x = 460;
currentArrow.y = 350;
currentArrow.arrowCode = 3;
addChild(currentArrow);
} else if(lvlArrayAll[lvlCurrent][sArrow] == 4){
//place a right arrow onto the stage
currentArrow = new arrowRight();
currentArrow.x = 460;
currentArrow.y = 350;
currentArrow.arrowCode = 4;
addChild(currentArrow);
}
}
//get the next arrow if it the song isn't finished
if(sArrow < lvlArrayAll[lvlCurrent].length){
sArrow ++;
} else {
//then remove this enter_frame listener
removeEventListener(Event.ENTER_FRAME, makeLvl);
}
}
//checking if mcReceptor is touching any arrows
//first we reset the variables we got last time just in case they aren't true anymore
swipeLeft = false;
swipeUp = false;
swipeDown = false;
swipeRight = false;
//this for loop will be used for the hit testing
for(var i:int = 0;i<numChildren;i++){
var target:Object = getChildAt(i);
if((target.arrowCode != null) && target.hitTestObject(mcReceptor)){//if the object is an arrow and the receptor is touching it
if(target.arrowCode == 1){//if left arrow
swipeLeft = true;
} else if(target.arrowCode == 2){//if up arrow
swipeUp = true;
} else if(target.arrowCode == 3){//if down arrow
swipeDown = true;
} else if(target.arrowCode == 4){//if right arrow
swipeRight = true;
}
}
}
txtScore.text = " "+skor;
txtScoreString.text = scoreString;
}
Multitouch.inputMode = MultitouchInputMode.GESTURE;
stage.addEventListener(TransformGestureEvent.GESTURE_SWIPE, checkSwipe);
function checkSwipe(e:TransformGestureEvent):void{
//if the left key is down and no left arrows are touching the receptor
if(e.offsetX == -1 && !swipeLeft){
scoreString = 'Bad';
} else if(e.offsetY == -1 && !swipeUp){//and so on
scoreString = 'Bad';
} else if(e.offsetY == 1 && !swipeDown){
scoreString = 'Bad';
} else if(e.offsetX == -1 && !swipeRight){
scoreString = 'Bad';
}
}
beginCode();
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|