Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c03/h01/mnt/55667/domains/blog.michaeljbowen.com/html/wp-settings.php on line 472

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c03/h01/mnt/55667/domains/blog.michaeljbowen.com/html/wp-settings.php on line 487

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c03/h01/mnt/55667/domains/blog.michaeljbowen.com/html/wp-settings.php on line 494

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c03/h01/mnt/55667/domains/blog.michaeljbowen.com/html/wp-settings.php on line 530

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c03/h01/mnt/55667/domains/blog.michaeljbowen.com/html/wp-includes/cache.php on line 103

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c03/h01/mnt/55667/domains/blog.michaeljbowen.com/html/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c03/h01/mnt/55667/domains/blog.michaeljbowen.com/html/wp-includes/theme.php on line 623
michaeljbowen.com » Flash

Archive

Archive for the ‘Flash’ Category

How to use Flash CS 5.5, AIR 3.2, and Starling for iOS, iPhone, iPad

March 10th, 2012

With the newly released AIR 3.2 SDK, you can take advantage of Stage3D and achieve (near) native performance on iOS devices.  As an example, I get a steady 58 frames per second on an iPad 2 when rendering 400 Sprites with Starling (Sprite size: 81×140 pixels).

However, getting Flash ready to export to your iOS device and take advantage of Starling is a bit of a challenge. You need to overcome these two challenges:

  1. Overlay the AIR 3.2 SDK onto Flash CS 5.5
  2. Get your app to use the “direct” render mode, which is required by Starling
Here’s how.
Step One: Overlay the AIR 3.2 SDK onto Flash CS 5.5
Follow these steps

Step Two: Get Flash to use the direct render mode in iOS
Starling requires a render mode of “direct.”
Unfortunately, Flash CS 5.5 doesn’t currently support the ability to choose this render mode when building for iOS.
See here: http://screencast.com/t/bJicMLHPevq
The solution is a bit of a hack.
You need to alter your app’s XML file and then make the file read only for PC, or locked on a Mac.
  1. Open your Flash project’s XML file.
    As an example, my FLA is called “starlingIpadTest.fla”, so the app XML file is called “starlingIpadTest-app.xml”.
    See here: http://screencast.com/t/fwceyJ76iZ
  2. Look for the <renderMode> tag. Set the render mode to “direct” like so:
    <renderMode>direct</renderMode>
  3. Make the file read only (PC) or lock it (Mac).
That’s it!
You can now deploy your app and test it on your iPhone or iPad.

Flash, iOS

How to Overlay AIR 3.2 SDK in Flash CS 5.5 Professional

March 9th, 2012

Getting the latest AIR SDKs to work with Flash CS 5.5 is a big pain.  The following steps will save you some trouble. (This is for Win 7, but something similar should work for Mac, I suppose)

Note: As always, make backups of anything that you overwrite.
It would be foolish to try this without a way to undo these changes.

1. Download the latest AIR 3.2 SDK here:
http://labs.adobe.com/downloads/air3-2.html

2. Extract the SDK

3. Rename the parent folder “AIR3.2″

4. Place the “AIR3.2″ folder in <FLASH CS5.5 DIR>\
(on Windows 7, this is located here: C:\Program Files (x86)\Adobe\Adobe Flash CS5.5)

5. Create a directory named “AIR3.2″ in  <FLASH CS5.5 DIR>\Common\Configuration\ActionScript 3.0\

6. Copy AIR3.2\frameworks\libs\air\airglobal.swc and paste it in the newly created <FLASH CS5.5 DIR>\Common\Configuration\ActionScript 3.0\AIR3.2 directory

7. Navigate to  <FLASH CS5.5 DIR>\Common\Configuration\Players\

8. Paste in the XML files found in this ZIP file: flashAirXML.zip

9. Remove (back up to somewhere) any other iOS XML file that already exists in  <FLASH CS5.5 DIR>\Common\Configuration\Players\
You can have multiple Android XML files here, but not iOS. I have no idea why.

That’s it.
You can now build to iOS with AIR 3.2 and take advantage of Stage3D!

Flash, iOS

Flash runtime errors show up in the darndest places

October 14th, 2010

My new HP Officejet 6500 Wireless printer comes with software called “HP Solution Center”.  Apparently, the creators of this app didn’t use the debug version of the Flash Player when developing. ;)

Bugs, Flash

Flash CS4 Bug: Kill the Compiler With One Line of Code

January 6th, 2009

I just found a nasty little bug in Flash CS4.  One line of code will result in a project that compiles with no errors and yet no trace statements work either.

Simply put the following line of code anywhere in your project (including in any class, or on any frame on the time line):

1
var version:Number = 0.0.1;

That’s it!  Your project will (seem to) compile with no errors.
You won’t get any trace output either.

Imagine burying this line of code in a random class in a project that has hundreds of classes.  How could anyone find it?

I’m Tellin’ Y’all It’s a Sabotage.

Bugs, Flash

Modules in Flash

December 22nd, 2008

Modules are SWF files that can be loaded by an application but cannot run indepedently.  Modules are built in to Flex 3, but it takes a bit of finagling to use modules in Flash.

I have been able to use modules successfully in Flash.  Below are the steps to follow.  I have also included the sample source code:
http://michaeljbowen.com/examples/modulesInFlash.zip

Step 1
Grab the latest Flex SDK.  I used 3.2:
http://www.adobe.com/products/flex/flexdownloads/

Step 2
In the Flash IDE (I’m using CS4), create a reference to the Flex SDK:
File > Publish Settings > Flash > Settings > Library Path
Add a reference to frameworks\libs (see the following image)

Advanced ActionScript 3.0 Settings

Advanced ActionScript 3.0 Settings


Step 3:

Create a module by creating a class that extends mx.modules.ModuleBase.

1
2
3
4
5
6
7
8
9
10
11
12
13
import mx.modules.ModuleBase;
...
public class ModuleAlpha extends ModuleBase implements IModuleAlpha
{
   public function ModuleAlpha()
   {
      trace("ModuleAlpha created.");
   }
   public function addNumbers(a:Number, b:Number):Number
   {
      return a + b;
   }
}

Step 4:
Compile the module using the mxmlc command line compiler.
Note: If you’ve placed your source in subdirectories, you will need to let the compiler know your source path.
In my example, ModuleAlpha.as is located in the com.electrotank.modules package.
Thus, here is my command to compile:

1
>mxmlc "-source-path+=../../../" ModuleBeta.as

Step 5:
Create a “parent” application that will load in your module(s) via mx.modules.ModuleManager.
Here is an excerpt from the sample code provided:

1
2
3
4
5
6
private const URL_MOD_ALPHA:String    = "ModuleAlpha.swf";
...
_modules[URL_MOD_ALPHA] = ModuleManager.getModule(URL_MOD_ALPHA);
IModuleInfo(_modules[URL_MOD_ALPHA]).addEventListener(ModuleEvent.READY, onModReady);
IModuleInfo(_modules[URL_MOD_ALPHA]).addEventListener(ModuleEvent.ERROR, onModError);
IModuleInfo(_modules[URL_MOD_ALPHA]).load();

Step 6:
Create an instance of your newly uploaded module using the factory of IModuleInfo:

1
2
var modAlpha:IModuleAlpha = IModuleAlpha(IModuleInfo(_modules[URL_MOD_ALPHA]).factory.create());
trace(modAlpha.addNumbers(2, 3));

Done
That’s it!
Be sure to use your powers only for good and not evil.

Flash, Hacks

Flash 10 Speed Test: copyPixel vs. Scrolling Sprite vs. Scrolling MovieClip

November 29th, 2008

When Flash introduced the copyPixel operation a few versions ago, I was very excited.  Finally, I could create blazing fast games that worked more like “real” games instead of using MovieClips.  However, copyPixel is no magic bullet.

Here are the results of a simple test where I scroll a background image.  I guessed that copyPixel would yield the fastest results, but I was wrong.

Note that during initial testing it was difficult to get a big difference with an 800×600 drawing area.
Of course, that’s because I’m only moving 1 image around as opposed to hundreds as in an actual game.

Thus, to make the differences stand way out, I increased the drawing area to 1880×1024.
This will fill up Fire Fox if your resolution is 1920×1200, but you can still see the drawing area.

The frame rate is set to 120.
Note also that I am using a crazy big image of size 4095×4095 (3.5 Megs).

Various OSs and Browsers

# Method Mode Fps Fire Fox - Win Fps Internet Explorer - Win Fps Fire Fox - Mac
1 Copy Pixel opaque 21-23 36-38 36-37
2 Copy Pixel window 40-42 43-45 36-36
3 Copy Pixel direct 54-56 46-48 30-31
4 Copy Pixel gpu 27-28   (wtf?) 43-45 21-22
5 Sprite opaque 24-25 36-37 36-37
6 Sprite window 58-60 62-64 36-37
7 Sprite direct 80-84 58-60 35-36
8 Sprite gpu 120 solid  (wow) 61-63 33
9 MovieClip opaque 24-25 38-40 36-38
10 MovieClip window 58-60 55-62 36-37
11 MovieClip direct 80-83 58-60 36
12 MovieClip gpu 120 solid  (wow) 58-62 33

So, the really confusing thing for me is that copy pixel seems to drag down gpu mode!

Also, remember when “opaque” used to be the best wmode option for performance? Not any more (at least for this specific test).

Flash, Performance