Two questions; Don't have code this time but they should be simple.
1) AS3 wants me to subclass a class that extends Stage; I'm not figuring out how to do this because it gives the error on the line of the package... code is basically:
package
{
import flash.whatever.Stage
public class thisclass extends Stage
{
public function thisclass()
{
}
}
}
Not sure if I got all caps correct, I have the code at school. Do I need to put something in the function? If so what?
2) AS3 also wants me to use attributes for variables. var I:Boolean; if (I == true) The error is on the if line... Should I declare it as I.something? Change it to lower case? (would have tested but didn't think of it while I was at school)
UPDATE: I tried using .value and declaring and using the boolean as .something, nothing worked their, neither did trying to use lowercase... Couldn't get my blank stage class to work either... Another problem: what is the import flash.whatever.whatever for switch cases?
NEW STUFF:
package
{
import flash.events.*
import flash.ui.*
import flash.display.MovieClip
public class tank extends MovieClip
{
var ii:Boolean; var kk:Boolean; var ww:Boolean; var ss:Boolean;
public function tank()
{
this.addEventListener(Event.ENTER_FRAME, update);
stage.addEventListener(KeyboardEvent.KEY_UP, keyup);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keydown);
this.x = 500; this.y = 500;
}
public function update(event:Event):void
{
var rotang = 0;
var speed;
if(ii==true)
{
rotang = rotang + 1;
}
if(kk==true)
{
rotang = rotang - 1;
}
if(ww==true)
{
rotang = rotang - 1;
}
if(speed > 0)
{
speed = speed - 1;
}
if(speed < 0)
{
speed = speed + 1;
}
if(ss==true)
{
rotang = rotang + 1;
}
if(ii==true && ww==true)
{
speed = speed + 3;
}
if(kk==true && ss==true)
{
speed = speed - 3;
}
if(speed > 30)
{
speed = 30;
}
if(speed < -30)
{
speed = -30;
}
var vy = Math.sin(this.degreesToRadians(rotang))*speed;
var vx = Math.cos(this.degreesToRadians(rotang))*speed;
this.y = this.y + vy;
this.x = this.x + vx;
this.rotation = rotang * Math.PI / 180;
}
public function degreesToRadians(param1:Number) : Number
{
return param1 * Math.PI / 180;
}
public function keyup(event:KeyboardEvent):void
{
switch(event.keyCode)
{
case 87 :
ww = false;
break;
case 83 :
ss = false;
break;
case 73 :
ii = false;
break;
case 75 :
kk = false;
break;
}
}
public function keydown(event:KeyboardEvent):void
{
switch(event.keyCode)
{
case 87 :
ww = true;
break;
case 83 :
ss = true;
break;
case 73 :
ii = true;
break;
case 75 :
kk = true;
break;
}
}
}
}