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. }