Archive for the ‘AS2’ Category

Sunday, January 13th, 2008

Here is an interesting look to start the new year at Google Trends for some common keywords to this blog audience. Comparing AS2, AS3, Silverlight and actionscript you can see that there is some pretty interesting things happening.

as3 as2 actionscript silverlight  

First off, AS2 and AS3 are clouded because they are also related to EDI and EDI-INT so they get a bit inflated. Silverlight though is pretty unique in the naming. So from this graph we can see this happening:

  • Silverlight and AS3 are growing rapidly
  • Silverlight is crossing over as3 or meeting it
  • The market looking for Silverlight is about 8-10 times as large as actionscript/as3/as3
  • Silverlight and AS3 are growing, AS2 has no growth left and is an EOL language (end of life)
  • AS2 (even with crossover to EDI trends for “as2″) leveled out, where AS3 is starting to lift to a larger market. This is strongly due to it being a fun language based on ES4 and interests programmers.
  • The as3 effect started right in March-April 2007 (hrm I started this blog in April 2007 coincidenc? j/k :))

Another chart including Flex shows a better picture of the keyword wars between flex and silverlight.

as3 as2 actionscript silverlight flex

So from this graph we can see this happening:

  • Flex has a large buzz
  • Adobe’s marketing efforts are many while silverlight is more unique and focused
  • Flex, as3 and Silverlight are popular, and growing in their support (the growth market for technology is in these areas, not in tech from Flash 8/as2)
  • AS2 still taking a nosedive

Flash and Flex programmers and designers should know that with Silverlight 2.0 release coming and the capabilities of Silverlight 2.0 more competitive, flashers should be working on Flex, Flash9 or at least AS3 if not Flex. The RIA competition market will heat up immensely this year with Silverlight 2.0 and possibly Flex3 and coding and programming for Flash and Flex is becoming more involved. It also has a very strong competitor in Silverlight 2.0 coming that will drive this market.

This is all great news if you are ready for it, if you are still coding actionscript2 (AS2) and paying no mind to Silverlight, Flex or at least actionscript3 (AS3) then you will see your market slowly start to fade as things are ramped up and more of a programming focus in the vector wars. If you are a flash coder and ignoring Silverlight, your solutions will suffer. If you are a silverlight coder or .NET coder and ignoring the Flex and AS3 rise your solutions will suffer. I have been playing in AS3, Flex and Silverlight for over a year on both now and they are an entirely new platform with great programming models. The competition puts focus on this market so it is a great time to be skilled in these areas.

Saturday, November 17th, 2007

The Proposal

Moses, the maker of FuseKit, is hoping to influence Adobe product lines to include a common base for animation and motion going forward. Currently the AS3 world is very alive and is inspiring developers like myself to build lots of toolkits and really creating reusable code and kits that can make things very easy from going to Flash to Flex. But wouldn’t it be nice if a part of these kits that have to be downloaded every time you have an application use them be part of the native Adobe applications, or a core animation kit that partially standardizes animation basics to build upon further?

Are we just asking for trouble or is this a good idea? I don’t’ think it can hurt to bring this to the surface. I know that common syntax and familiar kits can really help the developers and designers move from Flash to Flex to After Effects to Javascript, it could also help Adobe with usage and usefulness of their entire suite of products. Or further this could be a standard that allows Silverlight to also build upon (open standard) and may the best platform win.

I think it would be very wise for Adobe to:

  • Standardize animation toolkits across their products and
  • Start standardizing some of the basic tools of building motion and filter kits to native but still allowing a flourishing open source and community research and development aspect.

What MosesProposes:

Moses did speak with someone at Adobe about this and it is generally in the plans:

“It was also a pleasure to see Richard Galvan present the upcoming crop of Flash features: the sleek update to the animation timeline (better late than never?), support for columnated flowing text (double finally!) and the big one, native 3D player support for Display Objects as rotatable 2D planes. He ran out of time and didn’t get to a few others shown at Adobe MAX, such as built-in IK (inverse kinematics) and faster pixel-level drawing for texture-mapping and photoshop-like filter effects.

Talking to him after the presentation I learned that Richard has a keen awareness of exactly where each feature is at currently. We chatted about low-level animation mechanics of the Flash Player, and I found out that the holy grail of a time-based player is indeed on the distant horizon, but that each rev will need to be a small step toward this goal. The new Flash timeline features meld After Effects, Premiere and Live Motion, and from what I’ve seen I have to say that they are nailing this long-overdue upgrade with great design decisions and a level of usability we’ve never seen in Flash. Kudos, team!”

The Current Situation

Right now Tweener and TweenLite (and animation package and a few others) have a unique position in that they work the same almost for AS2 and AS3 (Flex or Flash – with minor property changes such as _x to x as that has changed in AS3). But it would be nice if these kits also had a version for After Effects (really bringing that tool into Flash/flex developer worlds) and Javascript and it would be great if Silverlight also were supported (AgTweener anyone?).

Tweener is leading the pack in this aspect of creating a similar experience from AS2 to AS3 in Flash and AS3 in Flex and even JSTweener for Javascript, and a kit for haXe which is becoming my favorite toy and the dark horse with the most upside potential, with haXe on the loose these points may all be moot as haXe can target any platform (except After Effects easily, correct me if I am wrong and Silverlight but it could easily be done so to do it for Silverlight 1.0 which is ES3 based).

I don’t use After Effects as much right now but if I could easily incorporate this into Flash/Flex and script and animate in a similar syntax and way I know After Effects would definitely have a boost in interest.

Also, the forgotten one Director, can we please get an ES4 based language in that application, or an update? Then kits and add-ons are much more possible. I really miss hardware accelerated 3d in browser as a pushed technology, Director is still around but it does not get the focus it needs. Feel the freedom and coolness just in this small test here in director, hardware accelerated 3d is the best, the Director application environment and Lingo and hacked in javascript are not the best. As a long-time Director user, hobbyist and professional I am disappointed in Director’s support at Adobe thus far, but I digress.

The Reality

The reality is right now the only problem with kits like Tweener, TweenLite, Tween, mx.transitions, mx.motion, etc is that the source has to be embedded in movieclips multiple times. Sometimes there are multiple animation kits per compiled SWF that have to be used for more advanced features. This adds bulk that if common might not need to be there (this comes into play still on mobile and large games/apps).

Let’s say you have an application that pulls in many disconnected SWFs and they all have animation in them, well if you have 20 of these let’s say, and you embedded a very small Tweener at 9k per SWF. That is about 200k of duplication of AS code. Due to the kits small sizes this is not a problem really but when animation kits like Animation Package come into play, you are talking 40k per SWF which would leave you with almost a meg of just duplicated animation code. I don’t think this is that major of a problem for kits like Tweener (9k compiled) and Tweenlite (3k compiled) but as projects get bigger and more depth of animation platforms needed this can be a problem. This can also be solved in architecture with a controller and dummy SWFs to animate but there are times when you need animation in the compiled SWFs and then also need it in many others and the controller.

The other reality is the animation kits (mx.transitions.easing, mx.transitions.tween) for Flex and Tween for fl are a little bloated, more difficult than needed to use and as has been seen, much slower than kits currently available in the community. My one fear about this is that if Adobe makes this, possibly like Microsoft’s toolkits and libraries they put out, they are always bloated and slower, then because they are embedded they are untouchable. If it was standard enough as building blocks that are faster because they are native, then this is the best option as embedded script would be hard pressed to beat native code in the players/applications.

The Future Plans

Some of this is underway….

Animation kits for future, Adobe is releasing Flash 10 called ‘Astro’ that has many new improvements in tweening with xml closer to flex or even Silverlight like transitions and storyboards. Aral Balkan, a sponsor of OSFlash, posted on this and even that Diesel Flash CS4 will include more Tween tools for IK/bones. Tweener , TweenLite, Animation Package, Animation System etc these are all helping to define the best way to do animation kits.

Physics toolkits have their own animation kits currently usually to handle the movement according to algorithms. FOAM, APE , Box2DFlashAS3 (just released very recently will be posting more on this after I check it) and Motor Physics (unreleased but heavily demoed at polygonal labs) are great physics toolkits and I like this being part of the community to get refined, maybe one of them or the best performing ones becomes part of the proposed Adobe Animation bundle. These will define the best way to do physics kits.

3d in flash toolkits have also been emerging rapidly in 2007 with Papervision3D, Away3d based on pv3d, Sandy, and even engines starting to get built on top of these platforms.

The general direction is moving towards another platform in there somewhere but I think much work is left to be done to standardized physics systems, 3d and advanced motion filter tweens and bezier, splines (Catmull-Rom), editors, etc. I think it is getting time for basic animation kits to become more standard though and in latest versions of flash this is included in the flex and flash scripts but not the native code.

Right now the standard in syntax and the broadest reach is Tweener and due to the bigger fish syndrome, haXe that can target any platform, it also has a Tweener and can create code for as2, as3 and any target written in if After Effects, Premiere or other apps get more robust and standard animation and motion kits. Tweener has kits made and contributed for AS2, AS3, haXe, Javascript and others.

There is also Hydra and the AIF Toolkit that are standardizing After Effects and Flash shaders and filters into a new shader language like Cg and reminiscent of processing.org.

As humans we trial and error and build new platforms in the market to step on to create better platforms to build cool stuff, it is evolving right now. AS3 is inspiring platforms within platforms of Flash and Adobe kits as well as on Silverlight and in the Javascript world with JSTweener, jquery etc. As these things are refined we build a level standard platform to build more stuff on. Eventually this will be there and whoever does the standard platform for animation will probably reap in users and abilitty to easily add new products and solutions where people already have training. Silverlight is an example with .NET developers. .NET was also an example with C# so similar to Java. ES4 based AS3 has proven it is inspiring all types of new platforms and kits and will continue to do so and it is an interesting time in this industry whichever direction it goes.

Monday, November 12th, 2007

Sandy 3.0 was released today. To go along with that a RedSandy (Red5 and sandy demo) has also been released. Sandy is the original 3d flash engine that was around before Papervision3D and Away3D and all the others. Sandy3d is an excellent library and it has many features that others do not have well particularly in the easier control of objects and importing all types of files such as ASE, WRL and 3ds in addition to COLLADA which other 3d engines like PV3d and Away3d support although it has been slower in the past 3.0 may change that.

Sandy 3D engine main features are :

  • Flash player 7 to 9 compatibility.

  • Both MTASC and Macromedia compilers compliant for AS2 and Flash CS3 and FlexBuilder for AS3 versions.

  • Several 3D primitives, allowing fast and parameterized object creation without any 3D modelisation knowledge.

  • Advanced and easy object management allowing some fantastic possibilities during your creations (scaling, rotation, translation, tween, etc.)

  • Advanced camera management ( rotation, motion on linear or bezier-curve path, movements, etc.)

  • Complex object loading thanks to the .ASE and .WRL files parser , but also Collada and 3DS files for AS3, (files generated by several 3D object modeling packages such as 3D Studio Max or Blender)

  • Material system to easily change your objects appearance. Several material are available allowing to create transparent faces, bitmap texture and video texture as webcam video stream.

  • Managment of Flash filters bringing some very nice visual effects

Red5 is the best multi-user media server out there right now and it is built with Java.

The cool and probably most interesting part is Sandy combined with Red5 to create multi-user environments in 3d for flash. There have been experiments with this and many attempts at this and is being done but an open source kit that does this is very helpful and these are two great flash toolkits in Sandy and Red5.

Get your game on!

Getting started video with Sandy 3.0 with a wise robot
[youtube=http://www.youtube.com/watch?v=vPz4VwIlrQg]

Thursday, October 25th, 2007

Flash is great, but accessibility can sometimes be a problem if it is not paid attention to. Direct linking, deep linking, back button support, these are very important to wire up in your applications. I am seeing many new RIAs, apps, sites, interactives still not do this and it is quite annoying.

The great thing about the web is that is gave users the ability to control the presentation and the context, from outside the presentation. By allowing users to use the back button and change urls in the address bar this was empowering. Empower your users and ad campaigns to get to different places of your application easily with deep linking, it is required for usability.

But this is hard right? Not really with great tools. What are you waiting for, SWFObject and SWFAddress make up THE platform right now for deep linking, embedding and back button support. These kits have been exhaustively tested and are very compact scripts to help you embed and then provide deep-linking, back button support and direct linking instantaneously almost.

Download SWFObject

Download SWFAddress

Both of these kits are well tested and provide instant small simple components of which to build complex systems on top of. SWFAddress builds on SWFObject tested embedding script and provides the tools you need to get deep linking running in your application in no time.

Note of caution, design implications (architecture design)

When you drive off the URL such as with direct and deep linking in Flash it does change your order of how you handle operations when you have to take into account the URL state. The first thing you have to do is when you receive an onChange event from SWFAddress that the URL has changed, you need to parse it and take action. However if you plan to deep link and provide usability throughout your flash site or app (even in the forms or multistep processes driven by URL) then you need to plan for this event and work this into your architecture for the url handling within the flash framework for your site.

A scenario might be:

  1. User using your flash app
  2. User clicks link or new section of your flash application
  3. INSTEAD of just animating the state in the flash application, you have to just update the section or URL (location.hash in javascript that provides the # name linking allowing the browser to stay put, or in this case SWFAddress.setValue((“/sectionname/page1″)),
  4. THEN the flash app or site is REACTIVE to the URL, reads in “sectionname/page1″ parses it and then animates to sectionname/page1.
  5. Or detect if the change came from the app or the URL directly and handle that differently in the onChange event with a subsystem.

Rather than just animating the app state or changing it, or showing that next photo on the button event, your button event would change the URL, then the flash monitoring the URL would push the onChange event. After that either animate in the next section or take appropriate action per the user requested action.

It isn’t like this for all areas or states of your application but you have to decide what is directly linkable, and when you want a state directly linkable then you have to wire it this way. Obvious choices are navigation items in your site, but they might also be specific cases like a multi-page form wizard that you want to link to step 3 directly, or a movieclip that someone can pass #3m2s to advance the movie by the url. There are many cases where you might want to provide deep linking into your flash application.

I know it sounds complicated? but it really isn’t, just a reversed way of thinking which we will highlight in the future with a tutorial and a fluid flash template. The SWFAddress site has great samples and examples, SWFAddress sets up the onChange handling in these samples and examples of how to do it in AS1, AS2 and AS3 so pick it up.

Download SWFObject

Download SWFAddress

Enable Deep Linking in Flash in 8 lines of code to start with SWFAddress:

From SWFAddress Documentation

1) Insert the SWFAddress script in your page directly after the SWFObject file.


2) Include or import one of the provided ActionScript classes. SWFAddress comes with versions for AS1, AS2 and AS3.3) Write your own navigation logic that will be executed when the address is changed.

SWFAddress.onChange = function()
{
    // Your code goes here.
}

3) Call the SWFAddress setter method from every button or action that requires deep linking.

this.onRelease = function() {
    SWFAddress.setValue('/portfolio/');
}

Check out the Asual blog (makers of SWFAddress) for more on good practices and bad practices with deep linking and more tips.Tips like:

Bad Practice: Address values naming using camelCase or other forms of custom convention

SWFAddress samples clearly define the best naming convention for deep links. Web addresses are case insensitive and the standard is lower case. For readability and Google SEO compatibility reasons the convention ‘my-deep-link’ is more appropriate than ‘myDeepLink’ or ‘My_deep_link’. The format http://domain.com/#/my-deep-link/?param=value is the only one fully compatible with the SWFAddress SEO rewriting.

Silverlight Deep Linking

This is also very simple in Silverlight to deep-link using javacript tools kits for Silverlight 1.0 which is javascript only, on location.hash change using a timer you could call an application method that might change the state or call certain transitions or move Canvases around, hide/show them, load content in, etc. Again, something you want to think about early on.

Other notes

SWFObject 2.0 beta5 is out and after 5 betas hopefully is nearing release

Pick up the code here for SWFObject 2.0

SWFObject 2 (script based) is the name again after a small switch and merge with UFO (standards based) to SWFFix but as Geoff Sterns pointed out, this seems to assume that something is broken.

SWFObject 2.0 is the new name again and let’s hope many more great tools are built on SWFObject 2.0 like SWFAddress which handles direct linking and back button support (using location.hash as most AJAX/RIA apps do to get deep linking and back button support).

Tuesday, October 23rd, 2007

Flash 9 has reached 93%/94% penetration rates. If 90% wasn’t good enough from July then September and now Oct/Nov numbers are at 94% and probably 95% by now. To put it in perspective last December Flash 8 was at 94%.

If you aren’t using Flash9 and especially AS3 now for performance and code reuse you are hurting yourself and your clients. The recent animation package comparisons in AS2 to AS3 show us the type of power that AS3 has. Now you can jusify it by the numbers…and the tests that compare and show 10 times improvement in scalability compared to AS2, even for small motion apps, getting the most out of performance is important.

Flash Player 6 Flash Player 7 Flash Player 8 Flash Player 9
Mature Markets1 99.1% 99.1% 98.4% 93.3%
US/Canada 99.0% 99.0% 98.5% 94.1%
Europe2 99.2% 99.2% 98.2% 93.7%
Japan 99.5% 99.5% 99.0% 93.7%
Emerging Markets3 Not surveyed in this wave

<!–

Notes

  1. Does not include Flash Player 5 and Emerging Markets.
  2. Supports Adobe Flash Video (FLV).

–>[source]

I won’t even go into the business reasons that include AS3 being Adobe’s main focus compared to AS2 and the AVM1, from now on AVM2 will be the staple of focus at Adobe for the Flash team. Support will continue but don’t get smoked by AS3 interactives that AS2 ones can’t compete with. Get your AS3 learn on

Monday, October 22nd, 2007

MosesSupposes posts a flash animation kit, TweenBencher, for benchmarking speed performance for Flash Animation Kits in AS3.

He also is calling for standards in Flash Animation kits but this is good and bad. I agree a common syntax should be used and the base components should be agreed upon and integrated into Flash, but standards need to be extremely simple and performing systems. We have seen how packaged Tween bloats and I think the Go approach mentioned below is a good direction for that. Adobe seems more open to this though talking about including SWFObject and possibly helping other kits like Papervision3D with performance enhancements.

I think that a standard is already emerging out of the AS3 toolkits leading the way Tweener, TweenLite, AS3Easing , Animation Package, Animation System, Twease and possibly Go (as Fuse had many users) which is the replacement in AS3 for Fuse that is unreleased. I think the developer market will decide that. Also, the big draws to good kits are simplicity, size, performance and maybe most important, the community and author’s willingness to get out there as technology changes. Right now Fuse is a bit behind in the last aspect, I think people are already enjoying the smaller Tweener, TweenLite kits that have simple syntax and are extremely small. Go is going the right direction in making the pieces much smaller as I agree when you have to use two kits there is extra uneeded duplication.

MosesSupposes might release a Fuse 3 still (built from Go?) but that is still in an private beta stage ( for Go- not Fuse) fairly recently and seems a bit unsure as to whether it will be released or not per the blog.

To forewarn the fanbase, this is not a release announcement, no major progress to announce at this time.

I’ve been holding my cards close since I came up with these concepts around January of this year but it’s time I layed ‘em on the table.

Fuse 3 (if built) will be a combination Physics + Tweening Engine with 2D + 3D animation & sequencing capabilities.

The idea is that all details are registered with a central class (probably FuseCentral) that monitors and prevents overlap between various handlers during runtime.

From the description of Go it seems pretty flexible and useful with making your own syntax but sometimes flexibility there creates a partitioned platform as syntaxes emerge, but it can also change with the best simple syntax. I think making it pluggable is more important than custom syntax, actually I wish animation kits all used the same syntax. Right now that is the biggest hurdle getting people to switch. Also, syntax that still works in AS2 is a bit attractive such as Tweener and TweenLite so that work in AS2 and AS3 does not hinder maintenance.

I have an idea cooking, now in private beta, called Go. I will be posting shortly with some background information on what led me to this approach, but right away let me share the concept and architecture with you.

  • Go is a lightweight – around 4k – portable set of base classes for creating your own AS3 animation tools.
  • Go provides an agile, purposeful architecture that is highly extensible.
  • Go is not a does-it-all Kit (a la Fuse), but such a kit can be built using Go. If Fuse was a vending machine, this is more like a knife and a pan and a way to cook for yourself.
  • Go does not require special syntax to use. You can instead, design your own.
  • Go’s engine is efficient, capable of processing a jaw-dropping 10-20,000 individual animations on a typical system. (Disclaimer: it remains to be seen how Go will perform in a real-world setting.)
  • Go is designed to encourage developers to use tweening, physics and 3D together.
  • Go is inspired by the popular Cairngorm framework in its approach. That tiny set of classes does so much, truly useful without dictating your code.

At this point in the Animation Kit game for Flash, real tests matter, and performance will start to become the main focal point as well as simplicity from released and completed packages that have strong communities and user bases. I think the kits that have succeeded well and created platforms have been the most simple and compact (the evolution is this way) that can be used as base kits in other larger systems. Starting with simple core systems that perform is good systems design to help minimize complexity as long as the pieces together aren’t too complex to use for general coders in Actionscript. Looking forward to watching this space progress.

Sunday, October 21st, 2007

Here is a performance test by Jack at GreenSock who created TweenLite and TweenFilterLite that tests Tweener, TweenLite, Fuse/ZigoEngine and Twease animation kits for flash. This test is only AS2 but in this test TweenLite is quite a ways ahead in means of performance for many tweens via code. I would like to use this in AS3 to check the speeds there as well but from the onset it appears if you have many tweens that the smaller TweenLite kit compared to the AS2 version of Tweener and Twease is the better bet for performance.

Personally I don’t do much AS2 other than maintenance or converting to AS3 so I will be digging into this further this week in AS3 to check the speeds.

In Jack’s AS2 benchmark it appears they are pretty even up until around 150-200 Tweens per half second. If your application is built in AS2 and has more than 200 Tweens per second (very possible in gaming and just to have processing left over for other things) then TweenLite seems like it has less overhead. TweenLite is pulling in a respectable 10FPS on this machine at 500 tweens per .5 seconds.

UPDATE: Jack has updated the test to include AS2 (the dog) and AS3 for Tweener and TweenLite. This version in AS3 the threshold is much much higher and Tweener at 1200 tweens comes in around 10fps on this machine while TweenLite comes in at 1200 tweens at 15-20fps. They again are pretty even until around 800 tweens per second on this test machine where a critical mass is hit, at that point TweenLite starts scaling a bit better and around 1200 tweens is roughly double the FPS. I need to look further at the benchmark test as it is made by one of the authors but Jack is a respectable source and offers the source so anyone is willing to look at this. Results will vary but I think this still shows Tweener has a slightly smaller overhead (which when you compound it with many short tweens it adds up) but does not negate the use or quality of Tweener as 1200 tweens per half second is very respectable thanks to the new AVM2 virtual machine in AS3, but it is always important to perform to save up room for other kits such as Papervision3D and memory for more assets. I think this has been a very worthwhile exercise and I think that a need for a comparison tool for all animation kits in AS2 and AS3 (or just AS3 as we move forward), it will only improve both toolkits. Also, not just straight tweens but bezier, color, filters and general movement.

As always thanks Zeh, Jack and Nate for your excellent toolkits and work that you put out there.

Wednesday, October 17th, 2007

Currently working on some motion detection with flash/c# and webcams right now. Here’s a basic overview of some motion detection source files and tricks. Most motion detection is based on snapshots and finding brightness of a pixel with all combined colors, then comparing that to previous snapshots to detect enough variance and thus movement. If you have a webcam hooked up, this sample in Flash AS3 highlights this well showing the camera on the left, then the brightness snapshots on the right. It also has an indicator to the amount of movement due to much brightness.

C#

Here is a nice example of motion detection using various motion detection algorithms in C#. This is built on the very slick AForge.NET Computer Imaging Library.

If you ever wanted your own motion detection or recording it is all possible with the basics of checking brightness and snapshots in the most simple form checking how much change or variance their was to bright pixels or the count of bright pixels compared to previous snapshots.

// Calculate white pixels

private int CalculateWhitePixels( Bitmap image )
{
    int count = 0;
    // lock difference image
    BitmapData data = image.LockBits( new Rectangle( 0, 0, width, height ),
        ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed );
    int offset = data.Stride - width;
    unsafe
    {
        byte * ptr = (byte *) data.Scan0.ToPointer( );
        for ( int y = 0; y < height; y++ )
        {
            for ( int x = 0; x < width; x++, ptr++ )
            {
                count += ( (*ptr) >> 7 );
            }
            ptr += offset;
        }
    }

    // unlock image
    image.UnlockBits( data );
    return count;
}

Flash AS2

In Flash this is also possible here is a good article from Flash8 that explains cycling through each pixel to compare the image data and implement motion detection from a webcam.

For instance the basics here show how you can compare each pixel and the change in the brightness for each pixel:

//accuracy
tolerance=10;

//color of the current pixel in the current snapshot
nc=now.getPixel(x,y);

//red channel
nr=nc>>16&0xff;

//green channel
ng=nc>>8&0xff;

//blue channel
nb=nc&0xff;

//brightness
nl=Math.sqrt(nr*nr + ng*ng + nb*nb)

//color of the same pixel in the previous snapshot
bc=before.getPixel(x,y);

//red channel
br=bc>>16&0xff;

//green channel
bg=bc>>8&0xff;

//blue channel
bb=bc&0xff;

//brightness
bl=Math.sqrt(br*br + bg*bg + bb*bb);

//difference in brightness between now and before
d=Math.round(Math.abs(bl-nl));

if(d>tolerance)
{
//there was a change in this pixel
}

Flash AS3

Here is a link to grab a conversion of the AS2 Flash motion detection above to AS3.

Source of AS3 motion detection here.

Grant Skinner has done some interesting things with motion detection with Flash and webcams in the past in the incomplet gallery.

C# or other hardware accelerated capable kits are faster but AS3 and Flash with the new AVM2 virtual machine  should be about 10 times faster than AS2 as much of the improvement in performance and the virtual machine is on iteration speed increases such as loops (i.e. pixel loop).

Friday, September 14th, 2007

Zeh has posted an excellent cheat sheet for Tweener Easing Penner equations based on the original cheat sheet by Nate Chatellier. This is a very nice visual lookup to see what easing equation you want to use on your motion animations. Usually it is a trial-error approach without some visualization like this unless you were going to Robert Penner’s site visualization tool. It is not specific to Tweener in visualizing the Penner easing equations as many kits use them such as Fuse (AS2), TweenLite, Animation Package etc.

View the large demo here

Download from Tweener on Google Code

Download the source

View Robert Penner’s Easing Visualization Tool

Thanks Zeh/Nate one again and always Robert Penner!

Tuesday, September 11th, 2007



Flash Performance and HD (H.264) Video Progress

Fast performance is needed for good video combined with interactivity especially. Quickly comparing AS2 to AS3 shows that AS3 and the AVM2 virtual machine in Flash9 is much faster. If you are combining Flash and video especially when it is time to go HD, you will need performance.

Compare AS2 to AS3 rendering: AS2 & AS3 Note the as2 item only has 10000 pixel operations, the as3 item has 50,000 and is considerably more usable, in fact the AS2 version isn’t usable since it is slow. [source] This is a good test because it checks the movement of every pixel on the screen which leads me to video performance.

Flash HD in the FLV format is pretty nice looking today in Flash9 with AS3. But to keep up there are more formats and a move to support H.264/MPEG-4 AVC I am sure for online TV/Movie market.

The reason to bring up performance and video is because the video battle on the web is heating up even more between Adobe and Microsoft with Flash Video and Silverlight Video. The recent released info regarding HD on Flash is to combat Silverlight HD video that is looking pretty good.

Silverlight Performance and HD Video VC-1

View this Halo 3 video in Silverlight HD:

View it->

Recently Silverlight came out last week officially on Wednesday, really the 1.0 release is just a video and javascript release but when you view the videos below you will see that they have a short coup de tat on Flash video at the moment in terms of HD quality video.

Silverlight also has been pushing TV on the internet. See these samples that are actual TV on web pages already using Silverlight.

  1. Home Shopping Network Online
  2. ET Emmy’s coverage
  3. They also have WWE and MLB.com baseball already using Silverlight video.
  4. Netflix online video uses Silverlight

Flash video is cool and you can do great fun things like neave.tv (flash 8) and high definition FLV video in flash9 with AS3 and on occasion AS2 if it is just video with full screen flash but when you are talking TV and movie quality, it is still up for grabs but both are looking good especially Silverlight and that Halo 3 video.

Flash video is updating to H.264 [source]

Tinic Uro reports the beta player of flash that has HD now. Currently the FLV format is the web leader (you tube, Google video) but is not as good quality as Silverlight until they update to H.264 at least in terms of standards video. This is probably 6 months off?

Video literally changed in the internet in the last two weeks with the Flash announcements and Silverlight launching. I am surprised at Silverlight’s adoption rate and partnerships so far with the 1.0 offering which lacks many programming tools, but I see why on the video front why they did it. When 1.1 comes out it has all the programmer toys, and it will attract a lot of attention I think. It is all about performance and HD video right now.

Yes yes… Quicktime has done HD/H.264 video for a while but Quicktime is just a video format really, it will be able to be used in the new flash video as well as other formats but it doesn’t have the interactive platform behind it like Flash and Silverlight have.

The difference is the choice of format and standards. Silverlight with VC-1 and Flash going to H.264 codec. They are largely competing standards that are both “HD”.

The good news is we have competition to bring really high quality video to the web, the mashups with HD video in interactive games, demos, advertising etc will be very fun.