I know both languages and I think it really depends on what you want to do. If you're going with actionscript though I suggest using AS3 it's faster compared to AS2. Actionscript 3 is rather similar to Java, so you don't need to worry too much about garbage collection unless you really want to optimize the game and such. I think it's like a cross between Java and javascript.
actionscript is quite good for browser games, also it might be easier for your friends to use as well cause you can just put all your game assets in the library, although it makes the swf file larger. I think another advantage would be for mapping, since in the flv file you can set up grids. So it would also be easier for your friends to design maps and stuff without using third-party tile mapping software like mappy.
There's a big difference though when it comes to game logic in flash though. Well and that is actionscript doesn't have a main function. Also you won't have a simple game loop like in C++.
in C++ your game loop may look something like
1 2 3 4 5 6 7 8 9 10 11
|
bool gameOver = false;
// initialize game
while(!gameOver)
{
// get user input
// update
// render
// sleep
}
|
which is rather clear and easy to understand. However you can't do that in actionscript. In actionscript you need to use the ENTER_FRAME event, or a Timer event. So lets say you have some symbol in your library called HeroSprite. You'll need to attach an enter frame event listener to it like.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
var hero:HeroSprite = new HeroSprite();
// center our hero sprite on the stage
hero.x = stage.stageWidth/2;
hero.y = stage.stageHeight/2;
// add an event listener to our hero
hero.addEventListener(Event.ENTER_FRAME, heroAnimation);
// add the hero to the stage
addChild(hero);
// define the heroAnimation function
function heroAnimation(event:Event):void
{
// do your hero animation here
}
|
Well that's for the enter frame event. By the way, the enter frame event triggers every frame. So if you have 30 fps, 30 enter frame events will be triggered in one second. It's not good to rely on the enter frame event though cause if someone is viewing your game in like 3 frames per second the animation would be very slow. So basically you end up using Timers, however timers trigger depending on how many milliseconds you set it to trigger, So there may be problems with consistency, like if someone is viewing your game in 3 fps, then the animation would be very jerky and abrupt with huge increments in the movement. The solution to that really is like getting the starting point, then the end point of the movement and basically compute the amount of increment, depending on your time and fps.
Also you'll have to apply this to each animated sprite on your game. So the game loop isn't as simple and well structured as in C++ if you ask me. And when you're trying to make the transition from C++ to actionscript it would be difficult to grasp at first because you'll need to understand these differences in the game loop structure. So I think that's one thing to keep in mind as well.