PDA

Volledige versie bekijken : Errors wegwerken..


ChiCka
%Europe/Berlin %523 %2010, 13:34
Hoi!

Ik moet voor mijn opleiding een spel in elkaar knutselen voor een doelgroep van 4/6.
Nu ben ik de grootste leek in actionscript, en heb een 25tal errors waarvan ik niet begrijp waarom ze er zijn.

Is er iemand die deze er misschien voor mij uit wilt halen?

Edit: Het gaat overigens om dit script; http://www.flepstudio.org/forum/tutorials/515-flash-game-tutorial.html

Dauntless
%Europe/Berlin %564 %2010, 14:33
Welkom op FlashFocus.

Als je de tutorial goed volgt zal je hoogstwaarschijnlijk geen fouten krijgen. Daarom is het belangrijk dat je jouw script en jouw fouten hier op het forum post.

ChiCka
%Europe/Berlin %324 %2010, 08:46
Tja, ik sta erom bekend om altijd errors te veroorzaken.. En dan heb ik de pech dat ik de code ook niet snap. Dus ik kan ze niet zelf oplossen.

Goed;
Mijn script + de fouten;


stop();
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.utils.Timer;
import flash.events.*;

public class Main extends MovieClip
{
private var timer:Timer;
private var timer_uova:Timer;

public static var livello:int=1;
private var cambio:Number;
private var numUova:int=10;
public var punteggio:int=0;

private var isPressed:Boolean=false;
private var direzione:Boolean=true;
private var destra:Boolean=false;
private var sinistra:Boolean=false;

public function Main()
{
init();
attivaTimer();
listeners();
lanciaUova();
}

private function init():void
{
stage.frameRate=31;

gallina_mc.x=stage.stageWidth/2;
gallina_mc.y=gallina_mc.height+10;

cambio=1000+Math.floor(Math.random()*6000);

cambia_livello_mc.visible=false;
game_over_mc.visible=false;
punteggio_txt.text='punteggio: '+punteggio;
}

private function attivaTimer():void
{
livello_txt.text='livello: '+livello;
timer=new Timer(cambio,1);
timer.addEventListener(TimerEvent.TIMER,lanciaNume ro);
timer.start();
}

private function lanciaNumero(t:TimerEvent):void
{
cambio=1000+Math.floor(Math.random()*4000);
livello*=-1;
attivaTimer();
}

private function listeners():void
{
this.addEventListener(MouseEvent.MOUSE_DOWN,settaF ocus);
gallina_mc.addEventListener(Event.ENTER_FRAME,muov iGallina);
cesto_mc.addEventListener(Event.ENTER_FRAME,muoviC esto);
stage.stageFocusRect=false;
stage.focus=this;
this.addEventListener(KeyboardEvent.KEY_DOWN,contr ollaTasto);
this.addEventListener(KeyboardEvent.KEY_UP,azzeraT asto);
}

private function settaFocus(m:MouseEvent):void
{
stage.focus=this;
}

private function muoviGallina(e:Event):void
{
gallina_mc.x+=livello*4;
if(gallina_mc.x>=stage.stageWidth-gallina_mc.width/2)
livello*=-1;
if(gallina_mc.x<=gallina_mc.width/2)
livello*=-1;
}

private function muoviCesto(e:Event):void
{
if(isPressed&&direzione)
e.target.x+=Math.abs(livello)*5;
if(isPressed&&!direzione)
e.target.x-=Math.abs(livello)*5;
}

private function controllaTasto(k:KeyboardEvent):void
{
isPressed=true;
if(k.keyCode==39)
{
destra=true;
direzione=true;
}
if(k.keyCode==37)
{
sinistra=true;
direzione=false;
}
k.updateAfterEvent();
}

private function azzeraTasto(k:KeyboardEvent):void
{
if(k.keyCode==39)
destra=false;
if(k.keyCode==37)
sinistra=false;
if(!destra&&!sinistra)
isPressed=false;
}

private function lanciaUova():void
{
timer_uova=new Timer(1000-Math.abs(livello)*100,numUova);
timer_uova.addEventListener(TimerEvent.TIMER,sganc ia);
timer_uova.start();
}

private function sgancia(t:TimerEvent):void
{
var uovo:Uovo=new Uovo(this,timer_uova.currentCount);
}

public function passaLivello():void
{
timer.stop();
this.removeEventListener(MouseEvent.MOUSE_DOWN,set taFocus);
gallina_mc.removeEventListener(Event.ENTER_FRAME,m uoviGallina);
cesto_mc.removeEventListener(Event.ENTER_FRAME,muo viCesto);
this.removeEventListener(KeyboardEvent.KEY_DOWN,co ntrollaTasto);
this.removeEventListener(KeyboardEvent.KEY_UP,azze raTasto);

cambia_livello_mc.visible=true;
cambia_livello_mc.addEventListener(MouseEvent.MOUS E_DOWN,avanza);
}

private function avanza(m:MouseEvent):void
{
livello=Math.abs(livello);
livello++;
attivaTimer();
listeners();
lanciaUova();
cambia_livello_mc.visible=false;
}

public function gameOver():void
{
timer.stop();
timer_uova.stop();
this.removeEventListener(MouseEvent.MOUSE_DOWN,set taFocus);
gallina_mc.removeEventListener(Event.ENTER_FRAME,m uoviGallina);
cesto_mc.removeEventListener(Event.ENTER_FRAME,muo viCesto);
this.removeEventListener(KeyboardEvent.KEY_DOWN,co ntrollaTasto);
this.removeEventListener(KeyboardEvent.KEY_UP,azze raTasto);

game_over_mc.visible=true;
game_over_mc.addEventListener(MouseEvent.MOUSE_DOW N,riprova);
}

private function riprova(m:MouseEvent):void
{
livello=1;
punteggio=0;
punteggio_txt.text='punteggio: '+punteggio;
attivaTimer();
listeners();
lanciaUova();
game_over_mc.visible=false;
}
}
}
En mijn fouten;
Scene=spelmeisje, layer=Actions, frame=1, Line 8 Attribute used outside class.
Scene=spelmeisje, layer=Actions, frame=1, Line 9 The class or interface 'flash.display.MovieClip' could not be loaded.
Scene=spelmeisje, layer=Actions, frame=1, Line 10 The class or interface 'flash.utils.Timer' could not be loaded.
Scene=spelmeisje, layer=Actions, frame=1, Line 11 The class or interface 'flash.utils.Timer' could not be loaded.
Scene=spelmeisje, layer=Actions, frame=1, Line 13 The class or interface 'int' could not be loaded.
Scene=spelmeisje, layer=Actions, frame=1, Line 15 The class or interface 'int' could not be loaded.
Scene=spelmeisje, layer=Actions, frame=1, Line 16 The class or interface 'int' could not be loaded.
Scene=spelmeisje, layer=Actions, frame=1, Line 31 A type identifier is expected after the ':'.
Scene=spelmeisje, layer=Actions, frame=1, Line 45 A type identifier is expected after the ':'.
Scene=spelmeisje, layer=Actions, frame=1, Line 48 The class or interface 'flash.utils.Timer' could not be loaded.
Scene=spelmeisje, layer=Actions, frame=1, Line 53 The class or interface 'TimerEvent' could not be loaded.
Scene=spelmeisje, layer=Actions, frame=1, Line 60 A type identifier is expected after the ':'.
Scene=spelmeisje, layer=Actions, frame=1, Line 71 The class or interface 'MouseEvent' could not be loaded.
Scene=spelmeisje, layer=Actions, frame=1, Line 76 The class or interface 'Event' could not be loaded.
Scene=spelmeisje, layer=Actions, frame=1, Line 85 The class or interface 'Event' could not be loaded.
Scene=spelmeisje, layer=Actions, frame=1, Line 93 The class or interface 'KeyboardEvent' could not be loaded.
Scene=spelmeisje, layer=Actions, frame=1, Line 109 The class or interface 'KeyboardEvent' could not be loaded.
Scene=spelmeisje, layer=Actions, frame=1, Line 119 A type identifier is expected after the ':'.
Scene=spelmeisje, layer=Actions, frame=1, Line 121 The class or interface 'flash.utils.Timer' could not be loaded.
Scene=spelmeisje, layer=Actions, frame=1, Line 126 The class or interface 'TimerEvent' could not be loaded.
Scene=spelmeisje, layer=Actions, frame=1, Line 128 The class or interface 'Uovo' could not be loaded.
Scene=spelmeisje, layer=Actions, frame=1, Line 131 A type identifier is expected after the ':'.
Scene=spelmeisje, layer=Actions, frame=1, Line 144 The class or interface 'MouseEvent' could not be loaded.
Scene=spelmeisje, layer=Actions, frame=1, Line 154 A type identifier is expected after the ':'.
Scene=spelmeisje, layer=Actions, frame=1, Line 168 The class or interface 'MouseEvent' could not be loaded.

Dauntless
%Europe/Berlin %334 %2010, 09:01
De code is AS3, dus dit hoort in het AS3 forum thuis. (Ik verplaats even het topic).

Daarnaast moet de code in een extern .as document, zoals de tutorial beschrijft. Ik gok dat je dat niet gedaan hebt.

ChiCka
%Europe/Berlin %340 %2010, 09:10
Waarom moet het extern? En hoe laad je het dan alsnog in?

Stom dat het AS3 is, de rest van mijn spel is AS2. Wat is dan de juiste manier om de boel samen te laten werken?

Dauntless
%Europe/Berlin %350 %2010, 09:25
Het is NIET mogelijk om AS2 met AS3 te combineren.

De classe wordt gekoppeld aan je .swf via de Document class setting die je moet invullen.

ChiCka
%Europe/Berlin %351 %2010, 09:26
Hmm k, dankjewel voor de informatie.