Archive for July, 2012

[Unexpected File Format] Error | Opening Flash files | Flash Professional CS5.5

You may encounter errors when you attempt opening or saving files using Flash Professional CS5.5. This article explains about the errors and Flash CS5.5 updater released to handle such errors.

Firstly, here’s a list of all forum threads that were posted reporting similar issues:

ISSUES FORUM POSTS
“Flash cannot parse this document” http://forums.adobe.com/message/3564708#3564708
http://forums.adobe.com/message/3621958#3621958
“Failed to open document” error when trying to open file” http://forums.adobe.com/message/3593589#3593589
http://forums.adobe.com/message/3638332#3638332
“An error occurred opening file…” error when trying to open file http://forums.adobe.com/message/3593589#3593589
“Failed to open document” http://forums.adobe.com/message/3603110#3603110
http://forums.adobe.com/message/3615190#3615190
Unexpected File Format. Unable to open a file http://forums.adobe.com/message/3714690#3714690
http://forums.adobe.com/message/2892610#2892610

Solution

To address the above problem, Adobe released an updater for Flash Pro CS5.5 (version 11.5.1). This solves the issues related to XFL file corruption.

Adobe Update Description
9/15/2011 – This updater contains fixes for opening and saving some Flash Professional files (FLAs) in CS5.5 and other bug fixes.

Known Issues with the Adobe Updater

• CS5 & CS5.5: symbol saved in XFL format (compressed or uncompressed) is corrupted if its name has special character.
• Window only: XFL Compressed: Data loss when saving to a file with hidden checkbox checked in the Window OS properties dialog.
• Window only: XFL Uncompressed: cannot save fla error when saving .xfl fla with hidden checkbox checked in the Window OS properties dialog.
• (Win Only ) Unable to save a file on Network / desktop once we get unable to save error message while saving a fla to xfl 2nd time.

Recovering the damaged  or corrupt files

  1. Change the extension of .fla to .rar.
  2. Open it using the WinRAR application.
  3. Winrar throws a warning stating that you attempted to open damaged archive, you can safely Ignore the warning.
  4. Go to Tools->Repair Archive. This ensures that the archive and hence, the FLA is repaired.
  5. Change the extension to .fla.

Known issues in Flash Professional CS5.5

Here’s the complete list: http://helpx.adobe.com/flash/kb/known-issues-flash-cs5-5.html

Flash Professional CS6 | Publish to AIR | Errors | Failed to install AIR Application

If you are using Flash Professional CS6, you may encounter the following error when trying to install an AIR app published from Flash.

“This application cannot be installed because this installer has been mis-configured. Please contact the application author for assistance.”

 

 

 

 

 

 

 

 

 

Publishing to AIR – General Introduction

Helpful Links – http://helpx.adobe.com/content/help/en/flash/using/publishing-adobe-air-desktop.html

Problem Reason

The above problem arises when the same application is exported with different certificates and the new air application which is being installed conflicts with the old one.

Steps to resolve the above issue -

SOLUTION 1

Verify if the AIR application you were trying to install is already present on the system. To do so:

  1. Search for the application from its APP Name which is specified in the “AIR Settings” dialog and make sure that the application is completely uninstalled from the system.
  2. Install the AIR application again.

SOLUTION 2

Change the Application ID (APP ID – App ID is the identifier string for the application) in the Application Settings of the AIR Application

  1. Change the ID of the application in the application xml file and install it as a brand new app as if it had never been installed before.

Helpful Link – http://helpx.adobe.com/content/help/en/flash/using/publishing-adobe-air-desktop.html#creating_air_application_and_installer_files

SOLUTION 3

Create a new certificate for the AIR application. Steps for doing so:

  1. On the Signature tab, make the following settings:
    Certificate: Point to another valid AIR code-signing certificate or click the Create button to create a new certificate. Enter the certificate password in the Password field.
  2. Use this brand new certificate for signing the AIR application.
  3. Compile the App with the new certificate.

Helpful Link – http://helpx.adobe.com/content/help/en/flash/using/publishing-adobe-air-desktop.html#signing_your_application

Flash Professional CS6: Creating and using Spritesheets with starling

Flash Professional CS6 release brings in several exciting new features and one of the features worth elaborating is the Sprite Sheet Generator feature.

In simple words, A Sprite Sheet is a bitmap image file that contains several smaller graphics in a tiled grid arrangement. By compiling several graphics into a single file, you enable Flash Professional and other applications to use the graphics while only needing to load a single file.

The biggest advantage of using Sprite Sheets is that the GPU does not have to load all graphic assets on to the primary memory. By having to load only a single file, (the sprite sheet, that contains all necessary graphics), the performance of the GPU is enhanced significantly.

Here’s a bird’s eye view of how Sprite Sheets work:

How does spritesheet speedup the render

How does spritesheet speedup the render

As you can see spritesheets can be loaded into the GPU at once and hence, will reduce the draw calls as all Flash assets are loaded at once..

With the Sprite Sheet generator feature available with Flash Professional CS6, you can now contain all your Flash assets in to a Sprite Sheet at the click of a button!

Creating a Sprite Sheet

To create a Sprite Sheet of your assets in Flash Professional, follow the steps below:

  1. Select one or more symbols in the Library or symbol instances on the Stage. The selection can also contain bitmaps.
    <insert screen shots of the assets before the sprite sheet is created>
  2. Right-click the selection and choose Generate Sprite Sheet.
  3. In the Generate Sprite Sheet dialog box, select Starling as the Data Format.
  4. Click Export.

 

The picture below is how the spritesheet looks once generated from Flash Pro.

A typical snapshot of a spritesheet created using Flash Pro

A typical snapshot of a spritesheet created using Flash Pro

For more information, see Create a Sprite Sheet.

How to leverage the Sprite Sheet you just generated?

Starling is a pure ActionScript 3 library that mimics the conventional Flash display list architecture. In contrast to conventional display objects, however, all content is rendered directly by the GPU (Graphics Processing Unit) — providing a rendering performance unlike anything before. This is made possible by Stage3D technology available with Flash.  For more information, see http://gamua.com/starling/.

Starling provides a set of APIs to use the spritesheet generated using Flash Pro CS6. The APIs are similar to the AS3 Display List API.

Mapping Flash Professional library to Starling:

  1. Download and unzip the latest starling framework from http://gamua.com/starling/
  2. Launch Flash Professional CS6.
  3. In Flash Professional CS6, go to File > ActionScript Settings… > click the Library Path tab.
  4. Click the   button to add a new Library path.
  5. Enter the path to the location where you unzipped Starling or browse to the location by clicking the   button.
  6. Click Ok.
  7. Now that you have added the Starling framework to the library. You can start using spritesheet that you created from Flash Pro right back in it.
  8. Starling can consume spritesheet exported as JSON ( A png and an xml file combo ).

Using Starling to access the spritesheet using starling:

  • Create a new AS3 FLA with the name SpriteSheet
  • Create a document class SpriteSheet.as

In SpriteSheet.as put the following code:

package  {	
	import flash.display.Sprite;
	import starling.display.Sprite;
	import starling.core.Starling;

	public class Spritesheet extends Sprite 
	{
		private var myStarling:Starling;		
		public function Spritesheet() 
		{
			//Create a new instance of starling 
			myStarling = new Starling(SpriteSheetExample,stage);
			myStarling.start();
		}
	}	
}

Create the SpriteSheetExample class that the starling instance calls !

package  {
   import starling.display.Sprite;
   import starling.events.Event;
   import starling.core.Starling;
   import starling.textures.TextureAtlas;
   import starling.textures.Texture;
   import starling.display.MovieClip;
   import flash.display.Bitmap;

   public class SpriteSheetExample extends Sprite
   {
     [Embed(source="/mySpritesheet.xml",mimeType="application/octet-stream")]
     private var AnimData:Class;
     [Embed(source="/mySpritesheet.png")]
     private var AnimTexture:Class;		
     public function SpriteSheetExample() 
     {
	super();	
	this.addEventListener(Event.ADDED_TO_STAGE, initialize);
     }
     protected function initialize(e:Event):void
     {
 	var hungryHeroTexture:Texture = Texture.fromBitmap(new AnimTexture());
        var hungryHeroXmlData:XML = XML(new AnimData());
	var hungryHeroTextureAtlas:TextureAtlas = 
                                new TextureAtlas(hungryHeroTexture, hungryHeroXmlData);
        //Fetch the sprite sequence form the texture using their name
	var _mc:MovieClip = new MovieClip(hungryHeroTextureAtlas.getTextures("fly_"), 20);		 
	addChild(_mc);
	Starling.juggler.add(_mc);
     }		
  }	
}

Note:

  • The fly_ value in the getTextures method specifies the sequence of images that are present in the SpriteSheet. For example in this case it would be fly_1,fly_2 and so on. On specifying this parameter, the GPU loads the sequence of images from the SpriteSheet.
  • 20 value in the getTextures method specifies the frame rate of the animation or graphic that is loaded in to the GPU from the SpriteSheet. Substitute this value with the number of frames you have created for your graphic.

Test the movie and your animation should be running on GPU ! Make sure that you publish the movie with render mode as “Direct” . For more information on how you can use SpriteSheets created in Flash Professional CS6 with the Starling framework, see SpriteSheets in Flash Professional CS6 Video Tutorial by Hemanth Sharma.

See also:

For more information about creating and exporting Sprite Sheets to different target frameworks, see Create a Sprite Sheet.

Credits:
Hemanth Sharma, Gaming Evangelist @Adobe, for his extremely knowledgeable inputs and the really cool graphic assets used in this post (originally created for Hungry Hero the game). And to learn how to build the Hungry Hero game, see Starting with Starling tutorial series.