Flex/AIR Tips: Keyboard Codes

Posted by Daniel | Posted in Development, Flex | Posted on March 10, 2009

0

If you ever have the urge to capture a specific key pressed in Flex or AS3 in general, there is an excellent list of the keycodes, and costants you can use to represent them in your code here: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/ui/Keyboard.html

3-10-2009-5-36-24-am

You can use them statically(without instantiating an object) like so:

trace(Keyboard.TAB); // 9

Optimizing the SWF filesize for your Flex App

Posted by Daniel | Posted in Development, Flex, Pics | Posted on March 8, 2009

2

While wandering through the ginormous forest that is Flex I’ve noticed how the filesize grows exponentially when you start to add a lot of content, or some external libraries. This is annoying, especially when the app I’m making is supposed to be used by a large group of people at the company I work for. So, I went looking for ways to slim it down, and I have found a couple of gems that work really well. First of all there is an excellent video posted by Serge Jespers of the Adobe Platform Evangelism – European team that gives some detailed tips with an example of how to make your application smaller with Flex Builder.

Namely:

  1. Use “Release” build — by default the SWF is built with Debug mode and has debug & profiler code in it that your application doesn’t need.
  2. Move your panels into modules(see movie)
  3. Use the RSLs instead of compiling the Flex framework into your SWF

Using these suggestions has removed over 500K from my app.

The video shows you how to do all of these in Flex Builder.


Here is how you can perform the same optimizations in FlashDevelop:

Number 1 is fairly easy: Just find the only drop-down menu in the main interface, and change it from “Debug” to “Release”.

tip1

With number 2 you follow the same instructions, but you can get to the menu to add an item by right-clicking on your project in the “Project” pane of the right column, or by going to “File”->”New”.

tip2

Number 3 is slightly more complicated. First you need to get to your project’s properties menu, which you can do one of several ways. Here is a screenshot of going through the “Project” menu:

tip3-1

Then, click on the “Compiler Options” tab, and select the “Advanced Compiler Options” by clicking on it and clicking the “…” button. Then add the line “-static-rsls=false” to it as shown(or append it on a new line if you have other options set already).

tip3-3

Now, you have to copy the “framework_3.2.*.swf” and “framework_3.2.*.swz” files to the “bin” directory in your project, and upload them to your site when you upload your app. These contain the Flex framework that will be cached by the Flash Player when you run your app. They are located in “flex_sdk_3\frameworks\rsls” in the Flex 3 SDK folder. Note that whatever version of the SDK you compiled your app with is the version you have to use the RSLs from. If you compile your app on on build, and then try to use the RSLs from another one(ie. you switched machines/reinstalled the sdk/use another ide that uses a different sdk version, etc.) you will get a message when your app loads about RSL 1 loading(but it never will). So, if you reinstall the SDK, or any of the things I mentioned recompile your app with the new version. *phew*

I hope these tips are helpful to you!

Flex: getType() schmettype

Posted by Daniel | Posted in Development, Flex | Posted on March 7, 2009

9

I’ve started dabbling in Flex recently, and something that was apparent(and annoying at times) to meĀ  early on was it’s strongly-typed nature. Not type as in a keyboard, but variable types. Flex cares very much whether your variable is an Array, or ArrayCollection as it’s knowledge of types is key to it’s processing. This is quite the converse to a language like PHP, which is loosely-typed to say the least.

Anyway, I came upon a case where I needed to know the type a variable was so I could cast it properly(and for debugging), and I found that Flex doesn’t have a function to simply return a variable’s type. There is describeType(), but this returns an XML object with all of the information about the variable — not just the type. Plus you have to import the proper class to use it. So, I threw together this function quickly that will perform the import, and return/alert the type as needed:

private function getType(value:*, alert:Boolean = false):String
{
	import flash.utils.*;
	var description:XML = describeType(value);
	if(alert)
		Alert.show(description[0].@name);
	return description[0].@name;
}

I hope someone else can find it useful. :)

Fatal error: Cannot redeclare pclziputilpathreduction()

Posted by Daniel | Posted in Development, PHP, WordPress | Posted on January 25, 2009

6

I’ve seen this in a couple of places already, so I’ll go ahead an post it: If you’re getting an error with your WordPress install similar to: “Fatal error: Cannot redeclare pclziputilpathreduction()” and you’re using WP 2.7+, disable your WPAU – WordPress Automatic Upgrade plugin. This error is caused because in version 2.7 WordPress added the ability to update itself, so this plugin is no longer needed. Here is an image of what the deactivated plugin should look like on the plugins page:
wpau-deactivated

Update: This appears to be fixed in the latest version of the plugin. I was able to enable the plugin and browse around without getting errors. But I don’t see the need for this plugin in WP installs newer than 2.6 anyway.

Happy Holidays

Posted by Daniel | Posted in Life, PHP | Posted on December 27, 2008

1

I’d like to say Happy Holidays to you and yours this season. No matter your religion, race, nationality, whatever… I wish you the best in the new year.

happy-holidays-tux

PHP.net’s holiday logo was finally updated this year. The previous one was a bit dated.

12-27-2008-11-10-27-pm

100cc of Browser Security, Stat!

Posted by Daniel | Posted in Software | Posted on December 18, 2008

0

Both Microsoft and Mozilla have released patches for their flagship browsers in the past 24 hours or so.

Microsoft’s patch was a response to a security hole that could allow an attacker to steal passwords from your computer using a drive-by download initiated on an infected site you might visit, or be sent to. Every version of IE, from IE5 to IE8 beta 2 is affected, so you should update immediately if you don’t use Automatic updates(or if you have it set for a long time in between updates).

Firefox versions 2 and 3 both had patches released too, though the security flaws fixed in FF were unrelated to the IE security flaw. So make sure you grab the latest version of either of those as well. Mozilla says this will be the last update to the 2.x codebase of Firefox.

Even if you don’t use either FF or IE as your primary browser, if you have either installed, update them immediately.

Another year, another accident. Wait, what?

Posted by Daniel | Posted in Life | Posted on November 17, 2008

0

Today, on my birthday of all days, I got hit while driving (back)to work. I was coasting along, doing the speed limit, and a lady pulled out from a crossroad just soon enough to hit my back-right side and spin me about 150 degrees. Neither of us was hurt, and the immediately obvious damage to my vehicle was negligible. Her vehicle, on the other hand, is going to need a new bumper, front end, and a paint job. The nice police officer issued her a citation for “Failure to yield right of way”. It has been pointed out by two people already that “at least it was a memorable birthday”, and that it was.

Also, thanks to my awesome friends who made it out for my birthday dinner(you know who you are =]).

Minefield

Posted by Daniel | Posted in HTML/CSS, Software | Posted on October 25, 2008

0

The busy developers over at Mozilla are at it again. They recently released a pre-alpha version of the next iteration of Firefox 3, dubbed “Minefield”. It’s pretty fast(I’m using it to make this post), although Firefox is pretty fast itself if you run it with no extensions. The extensions available for Minefield at the moment are pretty limited. There were some complaints about it being unstable(come on, it is pre-alpha after all), but I haven’t had any problems with it thus far. You can download it here, but be forewarned that it will alter your current Firefox installation to become the default version that gets launched.

PHP 5.3alpha

Posted by Daniel | Posted in PHP | Posted on September 21, 2008

0

The next minor version of PHP5(5.3; currently in the alpha stage) will include support for NOWDOC, Lambda functions & Closures, and the much anticipated ternary shortcut(?:). NOWDOCs are basically HEREDOCs, but without interpolation. It’s like using single-quotes versus double-quotes in your strings. Lambda functions allow you to define a single-use function so that it doesn’t have to be defined in the global scope of the script throughout execution. You can exectute things like loops or callbacks without having to define the function ahead of time, and you can return the value of your loops or callbacks to a variable directly. The Ternary shortcut is to allow you to perform a quick if() & return the result, which is what the Ternary operator(s) does already, but you don’t have to specify an “else” value. Most(all?) of these features were discussed for inclusion in PHP6, but it looks like they’ve been backported, which is good. :)

Also included will be “limited GOTO” which, as I understand it, will entail using the break language construct to jump to a certain position in the script. The information that I’ve seen is minimal, but this feature could be useful to a lot of people as well.

More Hurricane Devastation

Posted by Daniel | Posted in Life, Pics | Posted on

0

So I came across a picture taken recently by a reporter in a helicopter over Galveston. Apparently this house was just recently built, and was built to withstand a category 5 hurricane. The rest of the houses in the area… not so much:

This second one is an overhead view from a satellite:

Images courtesy of the internets and NOAA.

Page optimized by WP Minify WordPress Plugin