Posts Tagged ‘FLASH’
Flash 10 will be ready for mainstream hopefully by the end of this year, or early ’10 when the penetration numbers will be up in or around the 90% range via zeh fernando based on previous trajectories.
With that, Flash 10 has many great new things such as the Vector structure that allows a collection of a certain type, which results in a faster collection because of the known type. So anywhere where Arrays are used, that is a possible candidate for a performance increase within some code because you are asking the virtual machine to do less work on each loop (not having to dynamically find out the type).
ByteArray (Thibault Imbert) has demonstrated that for the JPEG encoding in corelib it is up to 2.5 times faster using Vectors than Arrays. Your mileage may vary heavily but it is almost a guaranteed speed boost due to less work. This obviously has great possibilities for speeding up code that uses lots of arrays.
Due to the performance boost the Vector does have some constraints in the typical give and take of coder flexibility with compiler and virtual machine overhead. Vectors are more explicit and strongly typed which is why they are fast, but this is also limiting.
In addition to the data type restriction, the Vector class has other restrictions that distinguish it from the Array class:
- A Vector is a dense array. Unlike an Array, which may have values in indices 0 and 7 even if there are no values in positions 1 through 6, a Vector must have a value (or
null) in each index.- A Vector can optionally be fixed-length, meaning the number of elements it contains can’t change.
- Access to a Vector’s elements is bounds-checked. You can never read a value from an index greater than the final element (
length - 1). You can never set a value with an index more than one beyond the current final index (in other words, you can only set a value at an existing index or at index[length]).
[ Vector docs ]
ByteArray not only used Vectors heavily but did other optimizations that are always good to do, even though optimization is evil when you are working with precious client side resources ensuring an optimized base starting point can be a good thing.
So what did I do ?
- I used bitwise operators as much as possible.
- I replaced all Arrays with fixed length Vectors.
- I used pre-incrementation rather than post-incrementation (thanks Joa for this one
).
- I casted to int all my Vector indices access.
- Other minor stuff you always do to optimize your code
Other sources as well for even more optimization or shall I say efficient AS3:
- Polygonal Labs Using Object Pools
- Joa Ebert Tweening and Object Pools
- Joa Ebert Optmization Wiki
- Sean Moore Efficient AS3 roundup (great list of resources for more at the bottom)
- Lost in Actionscript Efficient AS3 Tips
- Big SpaceShip Mouse Leave Tip (flash can hog resources so when it isn’t in focus then let is stop tasking the processor)
- Grant Skinner Idle CPU in AIR FPS Tip (set fps to a lower amount when it is out of focus)
Yogurt3D flash based 3d engine appeared recently and is another flash based 3d engine which is based on OpenGL called SwiftGL and is stated as open source.
The site mentions that OpenGL source can be converted to run in the engine. You can do this now with Alchemy although it is in very early stages. It is not clear if it is an automatic conversion or if it simply means it is similar in syntax and method signatures, objects etc.
I definitely will be watching and see how it progresses, there isn’t much other than a single post about the engine so far and no info on the api or sample code. Looking forward to seeing more, the z-sorting is quite nice. Doesn’t appear like collisions are there yet but it has a nice look.
Sometimes excellent toolkits come out of the blue like this such as Ffilmation (isometric flash engine) or Alternativa (flash 3d engine flash 10 focused) so you never know.
@bartek from everydayflash.com is an amazing 3d flash designer and developer. The latest from everydayflash is a sample using MouseConstraint in JiglibFlash the 3d physics engine for all major flash 3d engines.
It is easy to see how the latest version of JiglibFlash with MouseConstraint will be heavily influencing flash games and applications very soon. This is a very smooth and quick demo that feels very responsive on the controls. There are so many possible uses for JiglibFlash now that the MouseConstraint is available. It will evolve further but this version seems ready to start integrating into many flash game and interactive ideas and projects. Even though it is still alpha it has been heavily cleaned up and a plugin system added by bartek for pluggable 3d render engines. That is a huge step for 3d pipelines in flash.
Great work JiglibFlash team!
Torque3D seems to have full featured browser surfaces that you can use in the 3d engine seamlessly, see the video below (at :38). This is amazing stuff.
Making games that integrate content from the web is especially required these days. It is a difficult thing to do within the 3d render because of all the plugins, styling etc that needs to be rendered on a 3d surface. Well Torque3D has a killer feature in that it supports entirely full features browser render on a 3d surface. So now you can integrate html content, flash video etc in your game easily.
You can play content in flash player content easily and have stripped down html but it is limited, you can play videos and have content in Unity3d but it is limited, even larger engines like Unreal 3 have difficulty handling flash and html content. If this is a good implementation Torque3D has a killer feature on their hands! Flash is commonly used as user interface elements and content within games but it can be challenging. This is pretty exciting if it works as advertised. Think of how cool all the little consoles, mini-games and controls in 3d games could be in flash easily.
See at :38 in the video…
Libspark from Japan is a treasure trove of great flash advancements, they seem to realize the great things that can come from porting in existing solid libraries from C/C++ etc into flash and have been scoring lately including augmented reality in flash porting the ARToolkit to FLARToolkit. Recently a port of openCV for as3 called Marilena was found and it is for object detection and decent facial recognition (it is a computer vision library from intel) considering the processing power needed to do this.
Face Detection: Here is the sample included with Marilena showing facial detection on an image.
Lots of recent action has blown up on this front from Mr doob, quasimondo (optimizing the Marilena classes for better performance) and Boffwswana. Also there is a kit called deface by sshipman that is the first foray into this a year ago doing similar things but it was just a bit before it’s time and a bit slow in previous versions of flash, it performs decent now in this sample. Flash 10 performance of the AVM2 and future directions with Alchemy will lead to more interesting stuff just like this.
Mr. doob head tracking sample, be sure to check lots of other examples there
Boffswana example of head tracking Johnny Lee Wii style with only a webcam and flash, no wiimote needed since it uses facial detection to check where you are and how close you are in the screen and then moves accordingly.
This is stemming from the recent explosion of the FLARToolkit and augmented reality in flash as well as the gimmicks used by Nintendo with the wii and Johnny Lee’s great head tracking advancements. Porting great libraries to flash seems to be the phase we are entering now judging by the recent excitement around Adobe Alchemy and the LLVM along with the lead from the libspark.org contributors. We have also seen this heavily last year in ports of Box2D for 2d physics and other toolkits using established working code and porting that to flash now that is is mostly capable of handling the performance.
OpenCV (Open Computer Vision Library by Intel) is quite a powerful platform that allows you to do all this and now it is available in flash. There are other great libraries for nearly all platforms now. I have done some previous work with Aforge which is also a port of OpenCV mainly for motion detection. This was always around but not until the recent performance updates and the innovation that has come with Alchemy and the thinking that goes along with that (porting in libraries to flash from C/C++ etc), has allowed this to flourish in flash and thus the web.
The amazing new things we can do with flash by porting in existing libraries is only going to get more intense as alchemy and flash 10 are even more mainstream. It is almost as if Flash will eventually just become a web renderer and simplified front end to many great toolkits that exist in more native environments like C/C++ but with the speed and distribution access of the web with Flash. Exciting times ahead.
Alchemy is going to shake things up a bit. As witnessed before from Quake running in flash and now ODE compiled to run in flash using Alchemy (LLVM based). It is an early test but shows what could be possible.
Mihai Pricope has a post with sources on how he got the ODE (Open Dynamics Engine) a great open source physics engine for 3D, running on the AVM2 Flash Player virtual machine.
I’ve took Alchemy for a test and decided to compile ODE (Open Dynamic Engine). Just to add yet another physics engine to the Flash World. It was a hell of a ride but I finally got to produce some bouncing balls
. For a still unknown reason some as 3d libraries have been very slow to render 6 translucent walls and 2 balls. Papervision3D seems to move quite decent.
You can download the ode sources from here. To recompile them do (you need to have the Alchemy environment turned on):
Flash 10 will become mainstream shortly and with that the possibilities of using Alchemy in your projects is becoming a reality for production. But what specifically can you do with Alchemy, a project that helps to compile C/C++ code into AVM2 capable files?
Alchemy described from Adobe:
With Alchemy, Web application developers can now reuse hundreds of millions of lines of existing open source C and C++ client or server-side code on the Flash Platform. Alchemy brings the power of high performance C and C++ libraries to Web applications with minimal degradation on AVM2. The C/C++ code is compiled to ActionScript 3.0 as a SWF or SWC that runs on Adobe Flash Player 10 or Adobe AIR 1.5.
Alchemy is based on the LLVM Low Level Virtual Machine that allows new levels of code translation. Maybe this can lead to more effective and performing code to run on the iPhone with flash player 10. Or some type of system that allows flash developers to code in AS3 or take projects and get them ready to run on the iPhone much like some of the Java to Cocoa compilation systems and Unity3D using mono to compile down to iPhone capable code.
Looks like it is a javascript day here at *drawlogic. Here is an interesting example with some demos of a javascript and canvas based pseudo 3d engine. Anything this cool you know it has to be from Japan.
Also of note, it has been rumored that Silverlight 3 will have fully hardware accelerated 3d and canvas and javascript engines are getting much faster with great demos like this. Adobe needs to leap into hardware acceleration for flash on a broader scale soon.
But I digress, this demo it appears, was inspired by Papervision3D due to the naming and the javascript reference of “parpevision.js“. I wasn’t able to find much more information about this but it is very well done and this example even shows some environment mapping. It is not close to flash pseudo-3d engines like Papervision3D yet but at the rate of javascript engine development lately this could rival flash AVM2 in the next couple of years.
Demos
Code
- Sample iPod iTouch Mesh data (meshdata.js) – contains models
- Code from the main engine (parpevision.js)
- Sample Viewport and main app (touch.js from demo 3)
Here is the code for the parpevision.js file and the mini engine, it is an MIT license. (more…)
Box2D is responsible for inspiring many 2d physics engines including Motor2, Box2DFlashAS3 and others. Box2D the original toolkit is a solid c++ physics engine that has many great examples and features including real collision.
Now it has inspired a pure Javascript version of Box2D called Box2Djs to (using prototype dependency) to implement many of the same demos using the same functionality. So it appears Box2D if you want to find a baseline standard physics kit for 2D, it now has versions in many languages that might allow you to have 2d physics capabilities across many platforms.
Box2DJS is a JavaScript port of Box2D Physics Engine. To tell the truth, this is converted from Box2DFlashAS3_1.4.3.1 in an automatic manner. (The reason why not Box2DFlashAS3_2.0.0 based is simply because I overlooked the renewal.)
Dependencies
- prototype.js
- IECanvas (when you use a canvas tag to display the result of your physics simulation)
Links
How to use
- Download a zip file and extract it.
- Copy js/ and lib/ directories from the extracted directory to your app directory.
- Copy script tags in the header part of index.html in the extacted directory to your html file where you want to simulate physics.
Because this library does not have a lazy-loading system now, you should load all classes before starting your simulation. To make things worse, each library has a bit complicated dependency each other so that loading libraries in wrong order may cause a fatal error. To avoid such a trouble, it is strongly recommended to copy the header part of this file or `index.html’ including the downloaded zip file.
- Utilizing Box2D APIs, simulate the newton world as you like.
The Box2DJS APIs are completely same as those of Box2DFlashAS3. Please refer information about it.
Also the speed of your javascript engine makes a big difference just like the AS2 AVM1 to the AS3 AVM2 virtual machines. Chrome is much faster than FF3.
Video of Box2DJS in Chrome
Video of Box2DJS in FF3
Recently two compact tweening engines have been released. Grant Skinner’s GTweeny and laborat’s ByteTween. This adds to the two that focus on micro-tween kit sizes in TweenLite and TweensyZero
Basically these engines look to be micro and provide pretty nice features while being so small. Micro tweening engines like GTweeny (3k), ByteTween (1.7k), TweenLite (2.7k), TweensyZero (2.9k) and Tweener (9k) have varying levels of support of features (Tweener being the most loaded with color and filter support without other kits just init, also TweenLite with a nice configurator to include only what you need). Micro kits have benefits when used for banners, animated assets (where you have many assets and the per asset savings is worthwhile) and other places you just want really small output.
Light Transition ByteTween
(1.7k)
This kit has a c# version as well as a small as3 bytetween version.
The ByteTween static class eats only 1.7K of compiled clip! With this size it supports:
- Creation of tweens of any numeric property (not color/uint properties).
- Pause,Unpause,Cancel operations based on the tween target and property.
- Overlap system that cancel tweens of same property in order to avoid erroneous behavior
- Alpha tween with negative alpha support (negative alpha sets the MovieClip visibility to false)
- ’scale’ tween of both ’scaleX’ and ’scaleY’ properties.
- OnComplete callback with any number of parameters
- Easy interface for creating new tweens!
TweenLite
(2.7k) base
- SPEED – I’m not aware of any popular tweening engine with a similar feature set that’s as fast as TweenLite. See the speed comparisons yourself.
- Feature set – In addition to tweening ANY numeric property of ANY object, TweenLite can tween filters, hex colors, volume, tint, saturation, contrast, frames, and even do bezier tweening, plus LOTS more. TweenMax extends TweenLite and adds even more capabilities like pause/resume, rounding, event listeners, timeScale, and more. Overwrite management is an important consideration for a tweening engine as well which is another area where the GreenSock tweening platform shines. You have options for AUTO overwriting or you can manually define how each tween will handle overlapping tweens of the same object.
- Expandability – With its new plugin architecture, you can activate as many (or as few) features as your project requires. Or write your own plugin if you need a feature that’s unavailable. Minimize bloat, and maximize performance.
- Management features – TweenGroup makes it surprisingly simple to create complex sequences and groups of TweenLite/Max tweens that you can pause(), resume(), restart(), or reverse(). You can even tween a TweenGroup’s “progress” property to fastforward or rewind the entire group/sequence.
- Ease of use – Designers and Developers alike rave about how intuitive the GreenSock tweening platform is.
- Updates – Frequent updates and feature additions make the GreenSock tweening platform reliable and robust.
- AS2 and AS3 – Most other engines are only developed for AS2 or AS3 but not both.
TweensyZero
(2.9k) base
Here are some simple steps to help you get started with creating your first animations with TweensyZero. TweensyZero is a light weight version of Tweensy most core features found in Tweensy are available to TweensyZero. Documentation for TweensyZero can be found under the folder ‘documentation/zero’ or online
gTweeny
(3k)
gTweeny is gTween‘s lightweight younger sibling. It strips a lot of the secondary features of GTween (proxy, timing modes, etc) in favour of smaller file size. It is currently under 3kb…
Here is a list of all open AS3 “Micro” Tweening engines < 5k
- ByteTween (1.7k)
- TweenLite (2.7k)
- TweensyZero (2.9k)
- gTweeny (3k)
Here is a list of all open AS3 Tweening engines and base kits
- Animation Package
- AS3 Animation System 2.1
- AS3Easing
- Go (base animation kit – create your own tween engine)
- gTween
- KitchenSync
- Twease
- Tweener (9k)
- Tweensy
- TweenLite (TweenMax)
The decision on which to use can be affected be features you want, how it feels (many use the same object syntax so it is dynamic), what performance do they have (all are orders of magnitude faster than the built in tween (flash) or transitions (mx/flex)), which size is ok, author/community support needed (some are more active than others adding features or simplifying and tweaking performance methodically), and many other factors. There are definitely plenty to choose from.
Speed Tests for many Tween Engines
- Green Sock Tweening Comparison Tool
- Moses Benchmarking Tool (relative comparison against SimpleAS3Tween sample)
For more on each features see their sites or these previous lists on tweening engines:
Don’t know how I missed this but just this last month a new site has launched called wonderfl that allows quick as3 compilation side by side that is encouraged by community and similar to a demo scene.
This could be great for generating new ideas much like machima and demo scenes have done in the past. This stype of stuff goes down with the flash community anyways but being able to do it on a site and fork and evolve scripts and game it is a great idea.
Effects with filters, bitmaps, pixel manipulation, pixel bender and papervision would benefit greatly from the type of innovation that could happen here quickly in small doses. See what you can throw down, maybe some fireworks.












