Home > other >  Flash parameter number is not correct, should be zero
Flash parameter number is not correct, should be zero

Time:09-23

Of new for the first time to use flash as3 made a small game, but the flash always says error parameters is not correct, please everyone a great god help!!!!!! The following is a code

The import flash. Utils. The Timer;
//a few different types of variables, convenient for control the movement of the object of the game
//and level of display, as well as time and performance record
Var g: int=1;
Var v: int=0;
Var t: int=0;
Var tt: int=40;
Var level: int=1;
Var fen: Number=0;
Var jishi: int=0;
Var uu: int=80;
Var jia: Boolean=false;
Var peng: Boolean=true;
Var xing: Boolean=false;
//define several voice, used to invoke the sound file repository
Var flappyflap: Sound=new flappyflap1 ();
Var fall: Sound=new fall1 ();
Var coin: Sound=new coin1 ();
Var Pl: SoundChannel=new SoundChannel ();
//call obstacles in library
Gd: var guan=new guan (0);

//define a class, to hold obstacles
Var group: Sprite=new Sprite ();
AddChild (group);
//call customs clearance film clips in the library, and put it in place objects
Var tg: TongTuan=new TongTuan ();
Tg. X=557;
Tg. Y=149;

//set the order of the several display object
SetChildIndex (palyer, numChildren - 1);
SetChildIndex (TXT, numChildren - 2);
SetChildIndex (lve, numChildren - 2);
SetChildIndex (time_mc, numChildren - 2);
SetChildIndex (shan, numChildren - 2);
SetChildIndex (hengwen_mc, numChildren - 2);

//define a timer to record time
Var time: the Timer=new Timer (1000, 0);
Time. AddEventListener (TimerEvent TIMER, timeHandler);
Time. The start ();
The function timeHandler (event: TimerEvent)
{

Jishi++;
Time_mc. Text="time:" + String (jishi)//let the time displayed on the stage


;
}

Registration//stage to monitor events for the change of the control variables, and voice broadcast
Stage. The addEventListener (MouseEvent MOUSE_DOWN, DOWN);
The function DOWN (event: MouseEvent) : void
{
V=- 10;
T=0;
Pl=flappyflap. Play ();
}
Registration//stage frame monitoring time
Stage. The addEventListener (Event. ENTER_FRAME down);
The function down (event: the event) : void
{
T++;
Tt++;//control variables add
Lve. Text="close:" + String (level);//stage showed off several
Group. X=3;//control obstacles mobile
Palyer. + y=v + g * t;
//variable size, if greater than 80 start execution method statement within the
If (tt>
=80){
Jia=true;//the specified variable quantity
The news ();//call the method
Tt=0;//specified variable values
}


//determine the player's position range
If (palyer. Y & gt; 375 | | palyer. Y & lt; - 10)
{
Over ();//call the method
Time. Stop ();//stop timing
return;
}

//use the for loop iterates through the inside of the elves child objects
For (var i1: int=0; I1 & lt; Group. NumChildren; I1 + +)
{//to determine whether a child objects collide with the players and execute the following code if collision
If (palyer. Hit. HitTestObject (group. GetChildAt (i1)) & amp; & Peng==true)
{
Pl=fall. The play ();//play failure
Shan. The play ();//flash play
Peng=false;//the specified variable type
Time. Stop ();//stop timing

Stage. The removeEventListener (MouseEvent MOUSE_DOWN, DOWN);//remove to monitor events
return;
}
//judge whether the child objects of the elves in the x coordinate is less than the player position plus elves position, if meet, execute the following code
If (group. GetChildAt (i1). X & lt; Palyer. X + - group. X - 20 & amp; & Jia==true & amp; & Peng==true)
{
Jia=false;//specified type
Pl=". The play ();//play sound
Fen +=1;//points
TXT. Text="score:" + String (fen);//stage show score
}
//judge the position of the child object size, convenient to remove child objects
If (group. GetChildAt (i1). X & lt;=- group. X - 50)
{//remove child objects
Group. RemoveChild (group. GetChildAt (i1));
}
}
//close Numbers increase
If (fen>=level * 10)
{
Level++;

}
If (fen> Time=10)//integral for 10 in the background, obstacles spacing smaller
{

Uu=60;
Ditu1. Visible=false
;
}
If (fen> Time=20)//integral for 20 in the background, obstacles spacing smaller
{

Uu=40;
Ditu2. Visible=false
;
}
If (fen> Time=30)//integral for 30 in the background, obstacles spacing smaller
{

Uu=20.
Ditu3. Visible=false
;
}
If (fen> Time=40)//integral for 40 in the background, obstacles spacing smaller
{

Uu=10;

Ditu4. Visible=false
;
}
If (fen>=50)//integral of 50 time, in the background, obstacles spacing smaller
{

Uu=1;
Ditu5. Visible=false
;
}
If (fen>=60)//integral of 60 time, in the background, obstacles spacing smaller
{

Xing=true;//the specified variable type
Over ();//call the method
AddChild (tg);//the image is loaded into the stage of customs clearance
}

}
Generate obstacles//, customs clearance load control image, image size and rotation, and control to generate obstacles
The function of news ()
{
Gd: var guan=new guan (0);
Var gd1: guan=new guan (gd1. Height);
Gd. Y=432 - gd. Height;
Gd1. Y=gd1. Height - uu;
Gd1. Rotation=180;
Gd. X=- group. X + 400;
Gd1. X=- group. X + 400;

Group. The addChild (gd);
Group. The addChild (gd1);
}
//at the end of the game
The function over ()
{
If (peng==true)
{

Pl=fall. The play ();//play failure
}

Stage. The removeEventListener (Event. ENTER_FRAME down);//remove listening
Var JFB: jifenbang=new jifenbang ();//the result for the load to the stage, and in the right place
JFB. X=158;
JFB. Y=242;
//let the results in the table text display the corresponding grades
JFB. Jibie_tex. Text=String (lve. Text);
JFB. Fenshu_tex. Text=String (. TXT text);
JFB. Time_tex. Text=String (time_mc. Text);



AddChild (JFB);//load the record table

//remove unwanted objects
The removeChild (TXT);
The removeChild (lve);
The removeChild (time_mc);
//remove unwanted listening
Stage. The removeEventListener (MouseEvent MOUSE_DOWN, DOWN);
Stage. The removeEventListener (Event. ENTER_FRAME down);
//registered a replay of the surveillance function
JFB. Fh_btn. AddEventListener (MouseEvent. CLICK, fh);

The function fh (event: MouseEvent) : void
{
//remove don't need to display the object
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related