i need help please
hi , how guys ? hope fine..
here
i have 2 problems first 1 why sounds files change after importing flash
and how can fix that
second problem why flash asking me add semicolon !! first time , (i guess) because of static type , because problem when did that(trying access variable class) couldn,t fix after adding semicolon
here 2 classes
main class
package
{
import flash.display.movieclip;
import flash.events.event;
import flash.events.keyboardevent;
import flash.ui.keyboard;
import flash.media.sound;
import flash.media.soundchannel;
public class main extends movieclip
{
var linkconvert:linkconvert = new linkconvert
var checkpoint:boolean
var fireballindex:array = new array
var ele:int
var i:int = 0
var firebird:firebird = new firebird
var scream:scream = new scream
var soundchannel:soundchannel = new soundchannel
public function main()
{
addeventlistener(event.added_to_stage,onaddedtostage);
}
public function onaddedtostage(event:event):void
{
addeventlistener(event.enter_frame,onenterframe);
stage.addeventlistener(keyboardevent.key_down,onkeydown);
firebird.stop()
}
public function onenterframe(event:event)
{
firebird.x = hero.x
firebird.y = hero.y
if (hero.electricalshield.stage){
healthbar1.width -=1
}
if (bat1h != null){
if (bat1h.stage){
if (hero.electricalshield.stage){
if (hero.hittestobject(bat1)){
bat1h.width -= 5
}
}
}
}
if (bat1 != null){
if ( bat1h != null){
if (bat1h.width == 0){
removechild(bat1h)
removechild(bat1)
removechild(bat1b)
bat1b = null
bat1 = null
bat1h = null
}
}
}
if (bat1 != null){
if (bat1.stage){
if (hero.hittestobject(bat1)){
healthbar1.width -= 5
}
}
}
if (bat1 != null)
{
if (hero.electricalshield.stage){
if (hero.hittestobject(bat1))
{
healthbar1.width -= 1;
}
}
}
if (healthbar1.width >= 80 && healthbar1.width <= 100)
{
zelda1.gotoandplay(1);
}
if (healthbar1.width >= 60 && healthbar1.width <= 80)
{
zelda1.gotoandplay(2);
}
if (healthbar1.width >= 40 && healthbar1.width <= 60)
{
zelda1.gotoandplay(3);
}
if (healthbar1.width >= 20 && healthbar1.width <= 40)
{
zelda1.gotoandplay(4);
}
if (healthbar1.width >= 0 && healthbar1.width <= 20)
{
zelda1.gotoandplay(5);
}
if (hero.hittestobject(portal3))
{
if (bat1 != null)
{
var map4:background = new background ;
removechild(bat1);
bat1 = null;
// doesn't need done unless added listener outside bat1 classs
}//normal
}//normal
}//func
public function onkeydown(event:keyboardevent):void {
if (event.keycode == keyboard.e)
{
if (hero.visible){
if(checkpoint){
soundchannel = scream.play()
hero.visible = false
addchild(firebird)
}
}
if (!hero.visible){
if(firebird.stage){
if(!checkpoint){
if(hero.marioflying == false){
soundchannel = linkconvert.play()
hero.visible = true
removechild(firebird)
}
}
}
}
checkpoint = !checkpoint
} //if event...
}//fun
}//class
}//pack
hero class
package
{
import flash.display.movieclip;
import flash.events.keyboardevent;
import flash.ui.keyboard;
import flash.events.event;
import flash.sensors.accelerometer;
import flash.media.sound;
import flash.media.soundchannel;
public class hero extends movieclip
{
var mariohasfallen:mariohasfallen = new mariohasfallen;
var static marioflying:boolean = true;
var vy:int
var roaring:roaring = new roaring
var nightjungle:nightjungle = new nightjungle
var heromovesduringfirefly:boolean
var electricalshield:electricalshield = new electricalshield;
var fball:fireball = new fireball();
var fballa:fireball = new fireball();
var fballb:fireball = new fireball();
var fireshooting:boolean = false
var lastpos:int
var fireballsound:fireballsound = new fireballsound
var speed:int = 3;
var fireballindex:array = new array
var dir:int;
var electricity:electricity = new electricity;
var soundchannel:soundchannel = new soundchannel
var firespeed:int = 10
var totalfirespeed = 0
var i:int
var fdir:int
var fireballflying:boolean; // keep track of fireball
public function hero()
{
addeventlistener(event.added_to_stage, onaddedtostage);
}
public function onaddedtostage(event:event):void
{
addeventlistener(event.enter_frame, onenterframe);
stage.addeventlistener(keyboardevent.key_down, onkeydown);
stage.addeventlistener(keyboardevent.key_up, onkeyup);
gotoandstop(4);
}
public function onenterframe(event:event):void
{
if(visible){
if(y <325){
y += 10
if(marioflying){
soundchannel = mariohasfallen.play()
marioflying = false
}
if(y>=325){
y = 325
marioflying = true
}
}
}
if(fball.width > 55){
fball.width = 55
}
if(fball.height > 55){
fball.height = 55
}
y += vy
x += dir * speed
if (fball.stage)
{
fball.x += firespeed * fdir;
fball.width += 0
fball.height += 0
totalfirespeed += 1
}
if (totalfirespeed == 20)
{
if (fball.stage)
{
movieclip(parent).removechild(fball);
totalfirespeed = 0;
// fireball done flying
fdir = dir
fireballflying = false;
fireshooting = false;
}
}
}
public function onkeydown(event:keyboardevent):void
{
if (event.keycode == keyboard.right)
{
gotoandstop(2);
// fireball flying?
if (fireballflying == false)
{
fdir = +1
}
dir = 1;
speed = 10
if (electricalshield.stage)
addchild(electricalshield)
if(movieclip(parent).firebird.stage){
speed =30
}
movieclip(parent).firebird.gotoandstop(2)
}
if (event.keycode == keyboard.left)
{
gotoandstop(1);
// fireball flying?
if (fireballflying == false)
{
fdir = -1
}
dir = -1;
speed = 10
if (electricalshield.stage)
{
addchild(electricalshield)
}
movieclip(parent).firebird.gotoandstop(1)
if(movieclip(parent).firebird.stage){
speed =30
}
}
if (event.keycode == keyboard.up)
{
if (movieclip(parent).firebird.stage)
{
vy = -30
}
}
if (event.keycode == keyboard.down)
{
if (movieclip(parent).firebird.stage)
{
vy = 30
}
}
if (event.keycode == keyboard.q)
{
if(visible){
speed = 30;
addchild(electricalshield);
soundchannel = electricity.play()
}
}
if (event.keycode == keyboard.w)
{
// tell myself fireball shot
fireballflying = true;
if(!fireshooting){
fireshooting = true
fball.name = "fb" + string(i);
fball.width = 25;
fball.height = 25;
fball.x = x + 20
fball.y = y + 10
fireballindex.push(fball);
if(this.visible == false){
if (movieclip(parent).firebird.stage){
fball.width += 30
fball.height += 30
soundchannel = roaring.play()
}
}
movieclip(parent).addchild(fball);
if(this.visible == true){
if (!movieclip(parent).firebird.stage){
soundchannel = fireballsound.play()
}}
if(this.visible == false){
soundchannel = roaring.play()
}
i++;
trace(i)
trace(fball.name)
}
}
}
public function onkeyup(event:keyboardevent):void
{
if (event.keycode == keyboard.q)
{
if (electricalshield.stage)
{
removechild(electricalshield);
if (soundchannel != null)
speed = 0;
soundchannel = electricity.play(1, 1)
}
}
if (event.keycode == keyboard.w)
{
}
if (event.keycode == keyboard.left)
{
speed = 0
gotoandstop(3);
if (electricalshield.stage)
addchild(electricalshield)
movieclip(parent).firebird.gotoandstop(1)
}
if (event.keycode == keyboard.right)
{
speed = 0
gotoandstop(4);
if (electricalshield.stage){
addchild(electricalshield)
}
movieclip(parent).firebird.gotoandstop(2)
}
if (event.keycode == keyboard.up)
{
vy = 0
}
if (event.keycode == keyboard.down)
{
vy = 0
}
}
//لا اله الا الله
// there no god except 1 god
}
}
and here error message
c:\users\owner n\desktop\project (4) \hero.as, line 39 1086: syntax error: expecting semicolon before marioflying.
thank guys in threads
you need indicate line 39 of hero class code.
More discussions in ActionScript 3
adobe
Comments
Post a Comment