Copy link to clipboard
Copied
I made ten mini games and test each of them one by one on android,all it's work fine.But problem is when I put ten games in to the one game.The some games extremely slow in mobile.I'm using Adobe Flash Professional CS6 and main fla size about 31 Mb and 48 mb with AIR.How can I fix that ? By the way,I tried with every render mode CPU,GPU,Direct but nothing change.
Copy link to clipboard
Copied
If you mean 10 different games, does the first game play ok the first time you use it? If it does, and it only becomes slow after playing other games, check to make sure that when you leave a game you remove all the event listeners the game needed.
Another tip, if you are using timers a lot you could think about changing to an enterframe listener instead. Timers will add to the duration of the current frame, whereas enterframe runs during the showing of the current frame.
Copy link to clipboard
Copied
I have played slow game first from main menu.So another scenes exist other games but I not play any of them before the that game.I could remove timers and use event frame.But I have the same problem another game and it's not have any timer it's just motion effect about 40 frame and just rotation.
Copy link to clipboard
Copied
Colin I have been thinking about use load code for each game from main menu.So main fla just like
var request:URLRequest = new URLRequest("game1.swf");
var loader:Loader = new Loader()
loader.load(request);
addChild(loader);
var request2:URLRequest = new URLRequest("game2.swf");
var loade2r:Loader = new Loader()
loader.load(request2);
addChild(loader2);
and add some mouse event's for buttons.
Is that helpful ?
Copy link to clipboard
Copied
That might work for Android, I'm not sure, but it would be a shame to use a technique that won't work on iOS, if you ever want to publish to that.
A similar approach, the one that I often use, is to publish each game as a SWC. The stage of the game would have nothing on it, and the game would start with:
var game:MovieClip = new Game1() as MovieClip;
addChild(game);
'Game1' would be a movieclip in the library that is the entire game 1, with its linkage set to be Game1. You can test that as normal, with Test Movie, and it will run as a SWF for testing. In Publish Settings you would check the box for SWC, and set its publish path to the deploy folder of your main app FLA.
Eventually you will have a folder with:
game1.swc
game2.swc.
and so on. In the ActionScript 3.0 Settings of the main app FLA you would go into Library Path and add each of the SWCs. Then when you want to play a game you would start it the same as the test version:
var game:MovieClip = new Game1() as MovieClip;
addChild(game);
Now, each game should have its own function to get rid of any public variables and listeners. A function like:
public function destroy(){
removeEventListener(Event.ENTER_FRAME,enterframe);
// that's just an example
}
In your main FLA you could take this approach to switch from one game to another:
public var currentGame:MovieClip = null;
private function playGame2(){
if(currentGame!-null){
currentGame.destroy();
removeChild(currentGame);
}
currentGame = new Game2();
addChild(currentGame);
}
I just typed all that here, so don't just copy and paste! But hopefully you get the two idea:
Use SWCs instead of external SWF and Loader.
Tell the current game to clean itself up, before starting the next game.
There are complications I didn't get into, such as what if the currentGame doesn't have a parent at the time, or how to use getDefnitionByName as a way to have one function that can play any of the games. But it should get you started.
Copy link to clipboard
Copied
I removed most of timers as much as I can.I use event frame instead.Now I'll convert vectors to bitmap.Then I'll work on your advice I hope it will work much better.Thank you colin.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now