Robots Rule | MindSculpt.net

New media has met its match.

The MindSculpt Design Syndicate focuses on code that works, from CSS, XHTML and JavaScript tips and tutorials to Flash and ActionScript how-to's. Robots not included.

Category: Flash AS2


How to publish Flash .exe and .app files for fullscreen viewing

May 11th, 2010 — 2:46pm

The following article assumes you have a solid understanding of Flash AS2 and the Flash interface and skips all basic Flash setup instructions and explanations in effort to provide you with quick, concise information.

You’ll occasionally find your client asking you for an executable version of the application you built them. Chances are they’ll also want that executable to open fullscreen. Flash can quickly compile executable files for Windows and Mac environments.

Step 1: Adding Some ActionScript
In the actions layer of your application, specify the following (place it at the top, underneath your class import statements, for consistency and best practice):

AS2:

  1. // prevents resizing regardless of HTML embed code settings
  2. Stage.scaleMode = "noScale";
  3.  
  4. // align the .swf to Top Left
  5. Stage.align = "tl";
  6.  
  7. // call fscommand from flash
  8. fscommand("fullscreen", "true");
  9. fscommand("allowscale", "false");

AS3:

  1. // import flash classes
  2. import flash.display.*;
  3.  
  4. // prevents resizing regardless of HTML embed code settings
  5. stage.displayState = StageDisplayState.FULL_SCREEN;
  6. stage.scaleMode = StageScaleMode.NO_SCALE;
  7. stage.align = StageAlign.TOP_LEFT;
  8.  
  9. // call fscommand from flash
  10. fscommand("fullscreen", "true");
  11. fscommand("allowscale", "false");

Detailed information about fscommand() and its additional parameters is beyond the scope of this article.

Step 2: Publish Settings (AS2 and AS3)
In the Formats tab in Flash’s publish settings (File > Publish Settings), you’ll see a bunch of options. The last two checkboxes allow you to export a .exe (Windows) or .app (Mac) version of your application.

If you just need to provide a .exe, you’re all done with the export step and you can skip to Step 4. If you’re providing a .app version instead/in addition, move on to the next tricky step…

Step 3: View Package Contents of .app File (Mac Executables Only, AS2 and AS3)
Now that you’ve published out your .app file, locate it in the publish directory you’ve specified in the Publish Settings panel. This file will launch to fit your monitor’s window, however with uncertain inconsistency and most likely with a browser title bar. No problem, here’s the fix:

  • Right click on the .app file and choose Show Package Contents
  • Locate the Info.plist file and open it in TextEditor or a similar editor
  • Browse towards the end and locate the end of the <array></array> node
  • Add the following node, alphabetically, as an additional <key> node:
  • <key>CSResourcesFileMapped</key>
    <true/>
    <key>LSPrefersCarbon</key>
    <string>YES</string>
    <key>CSResourcesFileMapped</key> <true/> <key>LSPrefersCarbon</key>
    <string>YES</string>

    <key>LSUIPresentationMode</key>
    <integer>4</integer>

    <key>NSAppleScriptEnabled</key>
    <string>YES</string>
    <key>NSHumanReadableCopyright</key>
    <string>Copyright 1996-2009 Adobe Systems Incorporated and its licensors. All Rights Reserved.</string>

  • Save your file
  • Now test your app

Note that your XML list may differ from the example above. As long as you drop the <key>LSUIPresentationMode</key> node above in the right alphabetical order, it will yield the desired results.

Step 4: Packaging your files for delivery
Now that your executable files are ready for delivery for either platform, it’s time to package them up and get them ready for hand-off.

Create a new folder to house your .exe and/or .app files. These files act like a .swf, so don’t forget to include all external-loading files (XML, folders, images, etc.) in your delivery package. You’re all set.

Share this post:
  • Twitter
  • Facebook
  • del.icio.us
  • Digg
  • LinkedIn
  • Reddit
  • StumbleUpon
  • Technorati
  • Google Bookmarks
  • Yahoo! Buzz

Comment » | Flash AS2

Flash Rich Media Banner Optimization Guidelines

May 7th, 2010 — 7:29am

If you’re a Flash developer, at some point in time you’ve had to build and optimize rich media banners for your clients.

Establishing a consistent workflow and following some simple guidelines is the key to success in banner optimization. Most of these techniques are basic and common knowledge to seasoned developers, but should be a great starting point for novice to advanced programmers.

Although not meant to be a definitive list, I’ve found the following steps work well when optimizing rich media banner units:

1. Always request specs for file size before development begins:

  • Banner dimensions
  • File sizes
  • Frame rate
  • Player version

2. Polite downloads (when available): is 30-40k initial, 70-100k additional (client specs may vary)

  • Base .swf should be the 30-40k max, and the additional content should load in via a second .swf

3. If you are doing simple animation, use TweenNano instead of TweenMax when programming dynamically to save a few k

4. Recreate assets in vector whenever possible, unless it is a complex vector, then it may make sense to import the asset as a bitmap

5. Combine images whenever possible

6. Remove all complex bitmap filters from bitmaps in Photoshop, and replicate them with Flash’s filters using the Properties menu (you’ll need to convert all bitmaps to MovieClips before you can apply a Flash filter)

7. Only include the text characters you are using when embedding fonts in dynamic text fields

  • Occasionally it makes sense to flatten text into bitmaps (even though this is bad practice) to get the files under spec

8. Under publish settings, do the following:

  • Set the target Flash player to the version spec’d out by the client
  • Change bitmap compression settings as needed (individual bitmap settings may need to be enforced as necessary)
  • Check Omit trace actions (occasionally knocks off a few k)
  • Check Generate size report to review asset weight in your .fla and allow you to locate and resolve problem areas contributing to file size overages

Following these guidelines should keep you out of trouble. If you’ve found any other tips that have worked well for you, please let me know and I’ll update the list. Enjoy.

Share this post:
  • Twitter
  • Facebook
  • del.icio.us
  • Digg
  • LinkedIn
  • Reddit
  • StumbleUpon
  • Technorati
  • Google Bookmarks
  • Yahoo! Buzz

2 comments » | Flash AS2, Flash AS3

AS2 Refresher: Loading External Bitmaps with loadClip()

February 15th, 2010 — 9:05am

The following article assumes you have a solid understanding of Flash AS2 and the Flash interface, and skips all basic Flash setup instructions and explanations in effort to provide you with quick, concise information. It also assumes you have images ready to be loaded into your swf.

The AS2 refresher series aims to consolidate basic, everyday snippets for the most common tasks used by Flash developers working with legacy files. Basic explanations are included in the comments, since after all, who wants to read through a bunch of crap when you are just after the code? Enjoy.

AS2 sendAndLoad with LoadVars Snippet:

  1. // variables
  2. //——————————————————————————————————————————-
  3.  
  4. // create a var to hold the name of the bitmap we want to load
  5. var imageName:String = "image1.jpg";
  6.    
  7. // set a reference to the folder your images are in ›› the slash (images/) is added below when we assemble the path
  8. var imagePath:String = "images";
  9.  
  10. // set a new MovieClipLoader and immediately load the image into a movieclip on the stage named ‘container_mc’
  11. var mcLoader:MovieClipLoader = new MovieClipLoader();
  12.    mcLoader.addListener(this);
  13.    mcLoader.loadClip(imagePath + "/" + imageName, container_mc)
  14.  
  15. // functions
  16. //——————————————————————————————————————————-
  17.  
  18. // when the image has loaded, begin the ad unit animation
  19. function onLoadComplete(mc:MovieClip) {
  20.    
  21.    trace("image loaded from: " + imagePath + "/" + imageName);
  22.    trace("image loaded into: " + mc);
  23.    
  24.    // load has completed, call init() and start the app
  25.    init();
  26. }
  27.  
  28. // called while image is loading ›› insert preloading actions here
  29. function onLoadProgress():Void {
  30.    
  31.    trace("image loading…");
  32. }
  33.  
  34. function init():Void {
  35.    
  36.    // start your app
  37.    
  38.    // for additional progress event listeners associated with loading external bitmaps,
  39.    //    visit: http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001381.html   
  40. }
Share this post:
  • Twitter
  • Facebook
  • del.icio.us
  • Digg
  • LinkedIn
  • Reddit
  • StumbleUpon
  • Technorati
  • Google Bookmarks
  • Yahoo! Buzz

Comment » | Flash AS2

Back to top