Most of the time, Flash performance issues come from bad memory management.
Object instantiation take a lot of time, and since FlashPlayer work with a Garbage Collector, having tons of objects can make it go nuts.
Good practice is to remove all instantiation from loops, keep a minimum of object in memory and use serialization and bytearrays to keep some data.
This profiler show you what the VM is reporting as object being allocated and removed (garbage collected).
Here is what the profiler look like: 1.Search filter
Since there is a lot of different object type being managed by the VM,
just listing them would make it hard to find specific data.
This input box let you enter any text to filter the visible object using their QName
When the filter search is ON (there is text inside the box), the box appear green,
and only class name with the text in it appear in the list [...] Read more: New tutorial: Profiling memory with TheMiner
Hey!
It’s been too long since we’ve had a good
bandit raid
topical content here. I’m going to fix it!)
Today we’ll speak about SWF changing using as3swf code library, as you could already guess from this post topic.
Let me introduce this library first.
It was designed to parse, modify, and create SWF files on the fly. You could get all the tags and SWF properties (frameRate, version, etc.) after ByteArray with target SWF parsing. The good thing is that with as3swf you’re free to modify any SWF tags and properties and it is able to save all changes you did! It could even allow you to create a new SWF file from scratch.
as3swf is available for your experiments at github: https://github.com/claus/as3swf
Library is pretty alive and have a good communicative author (Claus Wahlers), so feel free to make Pull requests
BTW, he applied my LZMA compression (more on LZMA – here) support pull request yesterday.
You should wait for the Flash Player 11.4 release to try as3swf with LZMA-compressed SWFs though.
One thing as3swf could not provide is a DoABC Tag ABC parsing.
Author started so library project some time ago, but abandoned it, thus it is no longer supported or actual.
I should agree with Claus though since a great ABC parsing and creating on the fly library as3commons bytecode already exists and have updates periodically: http://as3-commons.googlecode.com/svn/trunk/as3-commons-bytecode/changelog.txt
I’ve used it some time ago and was really happy with it. But this is another case…
I’ll shed a bit of light on my as3swf using purposes: I had a task to replace one SWF tag with completely new data, it was the DefineBinaryData tag to be clearer.
This is how looks SWF parsing code: [...] Read more: SWF rebuilding with as3swf code library
Last April at the “World Wide Haxe conference 2012“, Yannick Domiguez and Alex Hoyau from Silex-labs presented Cocktail, a cross-platform library.
As I joined forces with the team of Silex-Labs aka Intermedia for a few weeks, I decided to dive into their resource.
…………………………………………………………………………………………………………………………………………………. COCKTAIL
………………………………………………………………………………………………………………………………………………….
Cocktail is divided in 2 parts with a “core” which is platform independent, and a “port” which is target specific. Its is then possible to compile the same code for Actionscript and Js without any conditional compilation.
This allows developers to create their applications on multiple devices and OS [...] Read more: Combining Cocktail Haxe with PhoneGap
Hi folks! Since my studies are over and my new portfolio online, I have time to focus on personal projects. Yep, it was time to contribute again to the Citrus Engine. I’ve worked 3 days at full time focusing on its big issue : mobile performances. I’m glad to say that now they are just an old memories! 6 months ago, I’ve made the CE compatible with Stage3D thanks to Starling and added some cool stuff. CitrusEngineV3 BETA 1 has been downloaded 3047 in 6 months, that’s not bad! However it didn’t see lots of Stage3D game, because it was missing the point : people wants to make mobile games. You will find all the sources at the end. Nape Nape is Luca Deltodesco‘s open-source physics engine written in haXe with the help of his preprocessor caXe. It is written with AVM2 in mind for performance, and utilising another part of his build chain provides a seamless API between AS3 and haXe though it does compile with hxcpp with other targets unknown. The idea behind Nape is to provide a high-performance, powerful and moreover friendly and safe physics engine.
Nape is faster than Box2D, and easier to handle. Adding it in the CE wasn’t hard, and we use it the same way than Box2D. Using Box2D (Alchemy version) & Stage3D with Starling in the CE you must take a look on Adobe Flash Player Premium announcement if you are targetting Browser games. With Nape, you are no more related to the “premium features license” from Adobe. Nape is ready to be use (no bug spotted!), however since I’m really new to Nape, there are some strange behavior whith NapePhysicsObject in the CE (you can see it in this demo). It’s not a problem for a performance test.
A NapeStarlingGameState Class exemple :
[...] Read more: Citrus Engine on Nape and physics performance improvement
Finite State Machines are series of design patterns often used in Game Development. In this article I’ll define what they are & how they work, go over 3 example implementations I have implemented in Corona SDK, and describe some of the pain points I’ve encountered using them. I’ve ported Cassio Souza’s ActionScript 3 State Machine to a Lua State Machine and included examples. This article has a companion video embedded below. What Are State Machines At their simplest form, State Machines are an Observer pattern with 2 values they watch internally: an Entity and the Current State. Whenever someone, somewhere changes the internal state, it’ll let the world know. The high level parts are:
States which contain/define the behavior for the Entity
Transitions which occur when one State changes to another
Rules which define which States can change to certain other States
Events which are internally or externally dispatched which trigger State Transitions
When creating State Machines, you usually know all the states up front, hence the word finite. Whether a list on paper or a bunch of boxes on a flow chart with arrows denoting where you can go from where. Some states can have parent child relationships. There can be a variety of rules that allow/prevent some states from changing to others can causing state transitions. Why Use State Machines There are 3 use cases State Machines. These are Artificial Intelligence, modeling simulations, and a refactoring path for game entities. For AI programming, you have the choice of deterministic or non-deterministic. Most video games have deterministic; meaning you know how the enemies will react based on different inputs. If they don’t see you, they’ll patrol. If they see you, they’ll attack you. If you hide and wait, they’ll eventually go back to patrolling. You can simulate fuzzy logic by using random numbers to change state to something random. For example, sometimes the enemy could use a grenade vs. a gun, or attack you immediately vs. sounding the alarm… or even run away to get reinforcements. Sometimes they could even talk to you instead. This randomness makes a State Machine non-deterministic, meaning you know all the States, but you don’t know exactly all the paths between States. For modeling simulations, whether complex machinery, or situations, you often have a ton of moving parts. You’re interested in the potential interactions when certain things are in certain states. Sometimes you want these situations to be repeatable. For example, for simulating hardware of large steel manufacturing machinery for training purposes, you want to setup the machine either in a specific state, or towards one to teach a new operator how to handle a certain negative situation in a safe environment to learn. You start a predefined set of actions to get the machine in a state where something bad is about to happen, and the operator has to learn how to push the right buttons or turn the right knobs to stop things from going bad. You can do the same at a macro level for emulating events. Think SimCity. This is also why unit testing deterministic state machines is pretty easy, albeit not as fun as non-deterministic, because you know all the paths ahead of time and the potential interactions. For the purpose of this article, we’re concerned with refactoring paths for game entities. Specifically, “dude, this code is too complex to manage and there are 50 billion boolean flags/if then statements to deal with…”. Using State Machines makes your code more manageable as it grows, more organized, and easier to debug. Behavior in a Class vs. Behavior in States Alan Skorkin has a great article on why developers often don’t use state machines. While he’s referring to software development as a whole, not just game development, he brings up a lot of valid points. Specifically, YAGNI, or if you don’t know ahead of time you’ll have a lot of behavior, you start out building only what you need. The issue becomes down the line, the effort towards refactoring it to a proper state machine is a lot of work. I experienced this from 2 angles. The first is what got me interested in state machines in the first place. My game entities were getting uber complex, and I asked around for advice. Colleagues recommended Finite State Machines to solve all my problems. During the refactoring, I started to learn why they’re great for lots of behavior in known states. I then tried implementing one in a brand new code base with only a little behavior… and it was overly complex. Then I reached this mid-point where the complexity was hard to manage, but I didn’t want to go back to a State Machine again. So I’ve had a frustrating experience and an extremely positive one. You can see a before and after example of how State Machines can really make your game entity classes smaller and more manageable as their behavior grows. Example 1: Simple State – Event Handler Let’s show a simple 1942 ‘esque example in Lua. You have an overhead view of an airplane that has 3 firing modes: a single bullet, faster dual-bullets, and a 3 pronged super-fast bullet mode[...] Read more: Finite State Machines in Game Development