Archive for the 'Learnings' Category

Flash: More Efficient Blur filter Values

Friday, February 27th, 2009 by Luis

Last year during the development of a project where blur filters were used extensively we put into practice several tips and tricks to be able to render this visual effects quicker.

What caught my attention on top of everything was something really obviuos, in fact it is mentioned in the Flash documentation (I never read every single line), values that are a power of 2 (such as 2, 4, 8, 16 and 32) are optimized to render more quickly than other values.

Having this into account, the problem (a fairly common problem in systems programming) was to locate the "next highest power of 2", whenever I need the value to be dynamic.

Here there are a few AS3 algorithms to find the next highest power of 2:

Actionscript:
  1. var powerOf2:int=1;
  2. var val:int=456;
  3. while ( powerOf2 <val )
  4. {
  5.     trace(powerOf2 <<= 1);
  6. }


Actionscript:
  1. function nextPowerOfTwo( value_ : int ):int
  2. {
  3.     value_--;
  4.     value_ = (value_>> 1) | value_;
  5.     value_ = (value_>> 2) | value_;
  6.     value_ = (value_>> 4) | value_;
  7.     value_ = (value_>> 8) | value_;
  8.     value_ = (value_>> 16) | value_;
  9.     value_++;
  10.     return value_;
  11. }


Actionscript:
  1. function nextPowerOfTwo( value_ : int ):int
  2. {
  3.     return int(Math.pow(2,Math.ceil(Math.log(value_) / Math.log(2))));
  4. }


Flash Switcher extension and Vista

Thursday, February 26th, 2009 by Luis

Flash Switcher extension is a well known Firefox extension to switch between various Flash player versions. Also very useful to save or remove the current installed Flash plugin.

In the last two months I have found people around my friends network having a lot of trouble making the extension work with Windows Vista, getting this two common errors while installing the extension:

Component returned failure code: 0x80520008 (NSERRORFILEALREADYEXISTS) [nsILocalFile.copyTo]

Access to folder C:Windowssystem32MacromedFlash is denied. Consider to use an user accesible plugins folder instead (for example: ~/.mozilla/plugins/ )

The solution to get ridd of this error messages is very basic, you just need full access to the macromed folder in your system.

  • Go to C:\Windows\System32\Macromed
  • Right-click "Flash" folder to open the properties panel.
  • Click the "Security" tab.
  • Click "Edit" Button.
  • Select the current user in "Group or user names:"
  • Change folder permissions, normally I change it to have full control.
  • Click "Apply" and "OK"

Another question that comes together with this errors is how to customize the Flash Switcher extension.

The default download for Flash Switcher includes a fair variety of player versions but not all and you may need to add newer players to fit your development needs, for example the new 10r22_87 version.

First you need to download the player from the following Flash Player archive:

Archived Flash Players available for testing purposes.

Download Flash Player 10 (debugger versions) (60 MB).

Open your Flash Switcher extension plugins directory, located at (remember I'm talking about Windows Vista):

C:\Users[username]\AppData\Roaming\Mozilla\Firefox\Profiles\xxxxxxxx.default\extensions\flash_switcher@sephiroth.it\plugins\win

Create a new folder and name it 10.0 r22 debug, which is the new version to install. (Released February 24, 2009 due to security vulnerabilities)

Next you need to install the Flash player (flashplayer10r2287win_debug.exe) which goes to C:\Windows\System32\Macromed\Flash

Now copy the NPSWF32.dll file from the "Flash" folder to the Flash Switcher extension plugin directory that you just created.

And that's all, now your Flash Switcher extension should work without problems in Windows Vista.

Flash: Transparent Video

Tuesday, September 26th, 2006 by Luis

How to make a transparent flash video using Adobe After Effects 7.0 Pro and Flash, by Paul Jenkins.

Read the tutorial here.

Flash: tabIndex and IE workaround

Tuesday, June 13th, 2006 by Luis

Problem:

In Internet Explorer after the last tabIndex, focus goes to the browser address bar.

Solution:

An easy workaround is to create an empty MovieClip which receives keyboard focus and automatically gives focus to the first selectable (editable) text field, button, or movie clip.

Example:

[flash]http://www.blog.lessrain.com/wp-content/upload/test_01.swf,250,100[/flash]

Actionscript:
  1. import mx.utils.Delegate;
  2.  
  3. var timeline:MovieClip = this;
  4.  
  5. var myformat:TextFormat = new TextFormat ();
  6. myformat.font = "Verdana";
  7. myformat.size = 10;
  8.  
  9. var tf1:TextField = timeline.createTextField ("tf1", this.getNextHighestDepth (), 10, 10, 200, 18);
  10. tf1.type = "input";
  11. tf1.selectable = true;
  12. tf1.border = true;
  13. tf1.setTextFormat (myformat);
  14.  
  15. var tf2:TextField = timeline.createTextField ("tf2", this.getNextHighestDepth (), 10, 40, 200, 18);
  16. tf2.type = "input";
  17. tf2.selectable = true;
  18. tf2.border = true;
  19. tf2.setTextFormat (myformat);
  20.  
  21. tf1.tabIndex = 0;
  22. tf2.tabIndex = 1;
  23.  
  24. var tabHackMC:MovieClip = timeline.createEmptyMovieClip ("tabHackMC", timeline.getNextHighestDepth ());
  25. tabHackMC.tabIndex = 2;
  26. tabHackMC.onSetFocus = Delegate.create (this, focusLast);
  27. function focusLast ():Void
  28. {
  29.     Selection.setFocus ("timeline.tf1");
  30. }


Flash: Uninstall and Install for testing purposes

Tuesday, April 25th, 2006 by Luis

Untill now I've been using Flash Plugin Switcher to uninstall and install the Flash Player in order to test some stuff such as Express Install and the Flash Player detection.

Recently I downloaded the latest version of Flash Plugin Switcher which for some weird reason destroyed completely my IE making impossible to install or uninstall any Flash player version.

From now on I will install and uninstall the Flash player using a different method:

Flash: Back Button and Deep Links Topic

Tuesday, March 28th, 2006 by Luis

I know this is an old topic, but I feel like posting about it. Since a few months ago I tried to make flash websites a little bit more usable and functional taking advantage of some new Flash 8 features and going back to old topics such as the browser back button support and deep linking support.

So far we have tried to implement this features in the last two projects we have done for redbull with 95% success, as usual MAC and Safari still very problematic.

Today I found this article in Jens Franke's blog where he points to a good solution for the Back-Button Support which apparently works in Safari.

Realated entries:

Other articles:

Flash: FE labs

Tuesday, March 28th, 2006 by Luis

Robert Taylor, creator of FlashExtensions.com has set up a small Open Source library of resources regarding Flash and its capabilities such as Drag n' Drop Selected Text , Detect Line Number and Position of TextField or a set of algorithms to display the right color of text for the right background.

Worth to take a look.

Flash: Nasty XML load bug in Internet Explorer

Thursday, November 17th, 2005 by Thomas

Loading XML files in Flash over an SSL Connection in Internet Explorer fails if the Pragma:no-cache or Cache-control:no-cache HTTP headers are set on the XML file.

Wow! I've been chewing on this one for a while... We have a Flash site running on https with dynamically generated XML content. The server always returned the Pragma:no-cache header so that the dynamic data isn't cached in the browser.

The bug is especially hard to find because the request goes out to the server successfully, but the XML object in flash remains undefined for no apparent reason. Only after removing the header output on the server it started to work.

Not nice.

This MS bug report seems to be related.

[edit]

This post has been replaced by a more recent one, including an application to test the caching behavior of Flash in different browsers.

Flash loading and browser cache test-suite

[edit]

Some more posts on the topic:

Marc Speck

Adobe Technote

Flash: Video Articles

Wednesday, October 12th, 2005 by Luis

Macromedia has released a couple of new interesting Flash Video articles:

Flash: How to de-interlace video in real-time

Sunday, October 9th, 2005 by Luis

Fabio Sonnati has a very nice and useful article in his blog about how to de-interlace video in real-time using the Convolution Filter in Flash 8.

Worth to read: Flash real-time deinterlacing best-practice.

Related Articles:

Flash: Flash 8 garbage collector benchmark

Saturday, October 8th, 2005 by Luis

Interesting benchmark test, by Frédéric Saunier, to demonstrate how the new GC behaves when we fill an array with many new instances of an object and we destroy the array.

Flash 8 garbage collector benchmark.

Related articles:

Flash: Video Tutorials [UPDATED]

Friday, October 7th, 2005 by Luis

Flash Extensions

New set of Video Tutorials by flashextensions.

Updated, Flash 8:

Previous related entries: