I make a kind of simple game for assessing students, I can build the code based ActionScript 2.0. I hear from a fried that ActionScript 3.0 can be used on Android. So I hope my game can play in Android, this is my ActionScript 2.0 code
stop();
score=0;//skor total
step=1;//gerakan pemain
moveframe=4;
number=0;//dadu
a1.onPress=function(){
number=0;
number=number+1;
score=score+1;
step=step+1;
moveframe=moveframe+1;
_root.player._x = _root["square"+step]._x;
_root.player._y = _root["square"+step]._y;
_root.gotoAndStop(moveframe);
_root.soal.gotoAndStop(step);
trace(step);
}
b1.onPress=function(){
number=0;
number=number+1;
score=score+1;
step=step+1;
moveframe=moveframe+1;
_root.player._x = _root["square"+step]._x;
_root.player._y = _root["square"+step]._y;
_root.gotoAndStop(moveframe);
_root.soal.gotoAndStop(step);
trace(step);
}
c1.onPress=function(){
number=0;
number=number+1;
score=score+1;
step=step+1;
moveframe=moveframe+1;
_root.player._x = _root["square"+step]._x;
_root.player._y = _root["square"+step]._y;
_root.gotoAndStop(moveframe);
_root.soal.gotoAndStop(step);
trace(step);
}
d1.onPress=function(){
number=0;
number=number+1;
score=score+1;
step=step+1;
moveframe=moveframe+1;
_root.player._x = _root["square"+step]._x;
_root.player._y = _root["square"+step]._y;
_root.gotoAndStop(moveframe);
_root.soal.gotoAndStop(step);
trace(step);
}
e1.onPress=function(){
number=0;
number=number+1;
score=score+1;
step=step+1;
moveframe=moveframe+1;
_root.player._x = _root["square"+step]._x;
_root.player._y = _root["square"+step]._y;
_root.gotoAndStop(moveframe);
_root.soal.gotoAndStop(step);
trace(step);
}
In AS3 that would be something like that:
stop();
var score:int = 0;//skor total
var step:int = 1;//gerakan pemain
var moveframe:int = 4;
// this one is useless: number=0;//dadu
for each (var aButton:InteractiveObject in [a1,b1,c1,d1,e1])
{
aButton.addEventListener(MouseEvent.MOUSE_DOWN, onButton);
}
function onButton(e:MouseEvent):void
{
step++;
score++;
moveframe++;
root.player.x = root.getChildByName("square"+step).x;
root.player.y = root.getChildByName("square"+step).y;
root.gotoAndStop(moveframe);
root.soal.gotoAndStop(step);
trace(step);
}
Keep in mind that you need do much more than just that if you want to have your app running on Android smoothly. Yet if you're doing it just for your own fun, then yes, just migrating to AS3 will suffice.