Scott Ruttencutter - What The Flash?

Digital Complement to the Moleskine
  • rss
  • Home
  • About

Flash Builder 4 - Profiling won’t start for my Air App!

So I ran into an interesting problem today that I couldn’t find any information on out there for. I still don’t have a concrete idea of what is going on, but I do have a workaround.

This afternoon I was trying to launch the Profiler from within Flash Builder 4 to start looking at memory management optimization of the desktop application we are currently developing. To my surprise, when clicking “Profile Application,” the application would launch in adl but FB4 would not switch to the Flash Profile view.

I spent a couple of hours rebuilding the project files from scratch, but still no dice. Through all my testing I could build any number of new empty air projects and they would all build and profile properly.

But not my code.

So I created a new default app, launched with profiler…. And it worked! (But no code, of course).

It turns out that, for some reason, the initialization code for my application seems to be bogging down ADL so much that it is unable to connect with the profiler on launch.

My solution to the problem was to add a 1 second timer that would slow down the initialization of my application until the Profiler was able to connect–and it worked.

Strange workaround to a strange problem. If anybody else has any ideas, let me know.

Comments
No Comments »
Categories
Flash
Tags
Flash Builder 4, Profiler
Comments rss Comments rss
Trackback Trackback

Using Flash Components in Flex Builder

I ran into this again today and had to think it out, so figured it might help some folks.

If you are looking for the fl.controls.ComboBox or other fl.controls code in Flash Builder, you will find it conveniently absent.  The easiest way I have found to make available the code for the controls I want to use in a Flash project built in Flex Builder is to create a Components.fla file and then compile it out to a .swc.  You can then include the

1. Create an empty flash file called Components.fla

2. In the publish settings of your flash file, click the Flash tab, then check the Export SWC box.

3. Drag the components you want to use in your project to the stage (don’t worry, you can come back later and add more if you need to).

4. Save your file, then File>Publish.

5. In Flex Builder, right click on your project folder and go to Properties.

6. Click Actionscript Build Path on the left column, then the Library Path tab.

7. On the library path tab, click Add SWC and browse to the SWC file you just created.

Poof, now you have Flash Component code available in your Flex environment for code hinting, etc.

Comments
No Comments »
Categories
Uncategorized
Comments rss Comments rss
Trackback Trackback

True Random Integers in Flash AS3

So many people have this wrong, I have to post something right about this. I’m going to show you the example below and explain to you why it’s WRONG, and the simple change in logic required to make true random number generation happen for you.

THIS IS WRONG
var myRandomNumber:Int = Math.floor(Math.random()*(High-Low))+Low;

For example, if you wanted a number between 2 and 10:

var myRandomNumber:Int = Math.floor(Math.random()*(10-2))+2;

You will never get 10 as an answer.

Here is why:
The Math.random() function in AS3 returns a pseudo-random number, where 0 <= n < 1. This means you will never get 1 as your result of calling Math.random(). Without 1, you will never get any number greater than 10 to round down to 10. Everybody and their mom has the above formula as the 'correct' way to get a ranged integer number out of the Math.random() function.

So why not use Math.ceil, or Math.round? Math.ciel will give you the same problem, but at the beginning of your number range. Math.round sounds great, except you'll be left with 50% less chances to receive either your top or bottom number.

So what's the solution?

Easy. Add 1 inside your Math.floor call before you multiply with your random number. Then everything will have the same odds.

THIS IS RIGHT
var myRandomNumber:Int = Math.floor(Math.random()*(1+High-Low))+Low;

Think about it. Use it. And if there is a better way to do this, let me know. If I’m wrong, please tell me. I love to know when I’m wrong.

Comments
2 Comments »
Categories
Flash
Comments rss Comments rss
Trackback Trackback

Using fl.* library within Flex Builder 3 for Mac

Why this isn’t set up to work by default for Actionscript Projects is beyond me, but I found a need to use the fl.color Class this week in Flash and it sure was a challenge to get the fl.* libraries to work natively within Flex Builder 3 for Mac.

Here is how you do it:

1. Right click on your project folder in Flex, click “Properties.”

2. Click on the “Actionscript Build Path” menu item.

3. Click “Add Folder”

4. Navigate to: /Applications/Adobe Flash/Common/Configuration/Actionscript 3.0/projects/Flash/src/

5. Click “Choose” to select the /src/ folder and “Ok” to add this to your source path.

You can do the same thing for Windows based Flex Builder as well, the file path should be similar to this:
C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\ActionScript 3.0\Classes

P.S. Speaking of fl.color, fl.color.setTint() is a great trick to tinting without having to deal with the more complex colorTransform class.

Comments
2 Comments »
Categories
Flash
Comments rss Comments rss
Trackback Trackback

Capacity rebrands Cartoon Network

For possibly the most fantastic and satisfying work that you may see all year, check out Capacity and their visual rebrand of Cartoon Network.

Imagine animated Kidrobot vinyl dolls, with Cartoon Network skins and you will know what I’m talking about.

Comments
No Comments »
Categories
Amazing Work
Comments rss Comments rss
Trackback Trackback

Vista Gadget Downloading as a Zip? Here’s how to fix it.

Apparently Internet Explorer is REALLY smart. It knows that .Gadget files are REALLY .zip files. And since by default the Apache web server doesn’t know what kind of MIME headers to send for a .Gadget file, it doesn’t send any and IE has to figure it out. (More than likely IIS takes care of this automagically, so this fix is for all Apache based sites)

This generally results in a customer downloading a .zip file that they have no idea what to do with.

And apparently there isn’t much if any documentation on how to get around this problem. It is easy.

Create an .htaccess file, put it in the root of your website folder, and add the following line of text:

AddType application/x-windows-gadget Gadget

That’s it.

Enjoy.

Comments
No Comments »
Categories
PHP
Comments rss Comments rss
Trackback Trackback

levelHead - Spatial Reality Game


levelHead v1.0, 3 cube speed-run (spoiler!) from Julian Oliver on Vimeo.

 

This has to be one of the more inspiring things I’ve seen lately.  Very cool use of video technology and 3d perspective.  Bravo.

Comments
No Comments »
Categories
Uncategorized
Comments rss Comments rss
Trackback Trackback

Flash AS3 - CharCodeStrings Library (download)

A few weeks ago I was working on an interesting text typing widget for our new website (that isn’t up yet, still in the works). I came to find that there was a Keyboard.CharCodeStrings Array Constant in the AS3 Language reference–but it was only available within the AIR 1.0 runtime. Bummer.

So like many folks out there, I needed to roll a homegrown solution to match up CharCode result numbers with their character counterparts. Essentially a singleton class that you can use when you catch your event and turn the resulting CharCode into a literal string character.

Here is an example:

  1. package {
  2.  import flash.events.KeyboardEvent;
  3.  import flash.display.MovieClip;
  4.  import com.iq.CharCodeStrings;
  5.  public class CharCodeStrings_sample extends MovieClip {
  6.  
  7.   public function CharCodeStrings_sample() {
  8.    stage.addEventListener(KeyboardEvent.KEY_DOWN, traceKey);
  9.   }
  10.   public function traceKey(event:KeyboardEvent):void {
  11.    var myChar:String = CharCodeStrings.getChar(event.charCode);
  12.    trace(myChar);
  13.   }
  14.  }
  15. }

If this may be useful to you, there is a download link below. I built this to do what I needed for the project I was working on, so the character codes returned are for US English–but you could easily substitute another language by using the included sample app and replacing the characters. If you do set this up for use in another language feel free to shoot me the file and I will link it here.

Download CharCodeStrings

(Hint, when testing from within the Flash IDE turn off Keyboard Shortcuts when you run your movie to test or the preview window may not receive keyboard input. It is in the Control menu when your swf is playing.)

Comments
3 Comments »
Categories
Flash
Tags
Flash, Free AS3 Code
Comments rss Comments rss
Trackback Trackback

Google Maps API for Flash!

Looks like Google is releasing a Flash API for Google Maps.

This should be something fun to play with down the road.

Google Maps API @ Google Code

Comments
No Comments »
Categories
Flash
Tags
Flash, Google Maps API
Comments rss Comments rss
Trackback Trackback

What’s changing in PHP 6.0?

There is an interesting article up today about what major changes will be made in the upcoming release of PHP V6. Most of the changes won’t affect anybody developing with the current standards established with recent PHP V5 releases

New Features

  • Namespaces - Should be great for integrating libraries with third party code.
  • Soap - Now Standard instead of an optional compile-in feature.
  • XML - Now Standard instead of an optional compile-in feature.

Things Removed
These items are going to make a lot of standard open-source apps fall apart.

  • magic_quotes
  • register_globals
  • register_long_arrays
  • safe_mode

Read the article here >

Comments
No Comments »
Categories
PHP
Tags
PHP
Comments rss Comments rss
Trackback Trackback

« Previous Entries

Categories

  • Amazing Work
  • Cliché
  • Flash
  • PHP
  • Uncategorized

Links

  • IQ Foundry
  • IQ Games
  • Sticker Foundry
  • Time IQ

Meta

  • Log in
  • Entries RSS
  • Comments RSS
rss Comments rss valid xhtml 1.1 powered by Wordpress get firefox