www.fgks.org   »   [go: up one dir, main page]

June 2007


Flash & WIWTW13 Jun 2007 11:32 am

I’m starting a new category on my blog called “Why it Works that Way” (WIWTW). I was chatting with some of the user/community groups leaders yesterday and was saying that my favorite part of working on the Flash Player team is that I get to ask all of the questions I’ve wondered about but didn’t know who to ask. Now I just stroll down the hall and ask the person that wrote the feature something to the effect of “Why is the sky blue?”

Normally, I get an answer that makes a great wooshing sound as it goes over my head. Then in realization that I am a mere mortal, I get a really great answer that explains so much about how Flash works in general. You’d be amazed about how a question about transparency has big ramifications on accessibility. Realizing how useful this would have been when I was writing my own code for a living, I want to share some of the answers I’m learning.

So, today’s topic: Object.watch. Watch is a way of monitoring the value of a variable and if something tried to change it, a callback is invocked with the old value, new value, and property name. You can then validate, modify, or otherwise cleanup any values BEFORE they are made into values and any other part of the application can use the values. Anything you returned from the callback would become the new value of the variable.

I LOVED this method in ActionScript 2. I was horrified the first time I got a compiler error in AS3 and discovered my buddy was no longer there. Thinking that it was an oversight, I went and gave my plea/whine to many engineers. Surely everyone would recognize the inherent value of watch! (ok, so I am playing this up just a whee bit). I was really surprised to see that it wasn’t an oversight but a conscious decision and there was very strong feeling that it should never ever come back. I think the exact phrase was “over my dead body.”

Here’s why. Object.watch has a huge performance overhead.

My first reaction was, “well, what if I want to take on this performance overhead in my application to get its usefulness???” Then it was patiently explained to me that it wasn’t just my SWF that would slow down, it was player was always slower just because the capability was there. Removing Object.watch sped up overall Flash Player performance a few percentage points. Every time you set a veariable value, Flash Player was having to check to see if the variable was being watched. As that realization dawned on me I realized that my Object.watch buddy was really more of a little devil sitting on my shoulder tempting me into laziness.

Solution: The way in AS2 or AS3 to do the exact same thing in a more performance friendly way is to set up getters and setters for the variable and then do whatever operations you want. It is a little more work (typing), but actually does have some practical performance benefits. This does have the downside of not working for people that still use frame actions, but I think that is a minor trade off for an across the board speed improvement.

Future WIWTWs
If there is a question you want me to ask about the inner workings of Flash Player or ActionScript, go to this page and submit a comment. I’d like to keep comments on this post relevant to the post itself.

Adobe & Flash11 Jun 2007 12:19 pm

Last night we launched Flash Player 9,0,60,120, a public beta of our next update to Flash Player. There are some pretty interesting features in it, most notably an enhancement to the full Screen, and a new caching system to let you download the Flex Framework once.

Read on for some details, but also check out Tinic’s Blog and his article about Flash Player 9 Update 3 Beta.

Full Screen:
Full Screen itself is actually a few new features.

First the ActionScript API is updated to let you specify a target rectangle rather. This rectangle will be the only content shown in the full screen view. Even if you select a rectangle that is not the same aspect ratio as the screen, it will still only show your rectangle and will show the background color as bars when needed.

As the player transitions from the web page to full screen, you will notice the next feature, transition. The transition will zoom from the embedded SWF in the browser and quickly take over the whole screen. This transition will give the end user information about what is going on, and what caused the full screen behavior to occur. I like the idea of transitions a lot. This let’s your eye track any elements you are watching as you enter full screen. Otherwise there is some possibility of loss of orientation on the screen during a direct change to full screen.

Once in full screen, the fun really starts. While Flash is painting a LOT more pixels on the screen, you’ll actually see your processor levels fall. Flash Player 9 update introduces “hardware scaling,” and will very efficiently render your content to screen. I’ve seen some internal demos that are pretty amazing. There are a few caveats though.

  1. This is beta software!
  2. If you are using software like VMWare or Parallels, you may experience a crash. Before going into fullScreen mode, right click in the player and choose settings. In the Settings UI you will find a disable hardware scaling option. Make sure it is disabled to prevent the crash.
  3. As a developer, realize that not everyone viewing your content may be seeing it in hardware scaling. If the user’s video card does not support this functionality, the processing will be done through Flash’s traditional method.

Flash Player cache

Also as part of this beta release we are introducing a new way of caching Adobe platform components like the Flex framework. The framework is going to be an externalized file that Flash Player can download, verify and store on your local machine. The next time you need this file, from the same site, or any other site using this same file, you won’t need to download it again.

For Flex users, this means that the Flex framework will not be adding to your application from now on. You can take advantage of the UI components, but still deliver very small SWF files.

Wait, there’s more!
For the rest of the features and enhancements like recursive External Interface calls, multi-core support and more, take a look at the release notes.