Gotcha: using shorthand notation with boolean operators
In ActionScript (as well as JavaScript), the boolean AND and OR operators have a special meaning. That is, they don’t necessary return true or false, but return one of the operands.
var op1:Boolean = true; var op2:int = 2; var op3:Object = null; var result_1or2:Object = op1 || op2; trace(result12); // output: true var result_1and2:Object = op1 && op2; trace(result); // output: 2 var result_3or2:Object = op3 || op2; trace(result); // output: 2 var result_3and2:Object = op3 && op2; trace(result); // output: null
So, if you decide to execute write something really terse, like
var result:Boolean = validateSomething() && validateSomethingElse();
and expect both functions to run, then you might be in for a surprise. If the first operand evaluates to false (false, null, 0 or "") then the second part is not executed.
The same caveat applies to the shorthand operator a &&= b(), which basically expands to a = a && b(). So if a is “falsy”, b() is not executed. So be careful with logical operators and don’t abuse them or they’ll bite back!
You have been warned.
Uninstalling Flash Player (like, really uninstalling)
If you’ve ever installed Flash Professional on your computer you know it has that nasty habit of overwriting your debug Flash Player (ActiveX) with its own mutant half-debug version. I don’t normally mind, because the plugin version is not affected and I use Opera (which is awesome, by the way). But I started noticing Flash Builder errors whenever I would open a project and try to debug it. Once you close and reopen Flash Builder, you can freely debug that project. The error is caused by the failure to write into the FlashPlayerTrust file and it gets annoying after a while.
Because I am constantly installing/uninstalling/reinstalling prerelease versions of Flash Professional CS5, I frequently run into this problem. So I have to install the “real deal” debug version of Flash Player after each Flash Pro reinstall, which I know is not the recommended approach but it’s the fastest one. Today I wanted to try Flash Player 10.1 beta 3 and I got an error that said:
The version of Adobe Flash Player ActiveX that you are trying to install is not the most current version.
LOL, WUT?
After countless tries and retries and googling and hair pulling I found the solution and it lies within TechNotes kb402435 and tn_14157. What you have to do is download the Adobe Flash Player uninstaller and run
uninstall_flash_player.exe /clean
from the command line.
Then all you have to do is install the desired version of Flash Player and you’re good to go!
Orange RO APNs for Android
Internet
Name: Orange Internet
APN: internet
APN type: default
MMS
Name: Orange MMS
APN: mms
MMSC: http://wap.mms.orange.ro:8002
MMS proxy: 62.217.247.252
MMS port: 8799
APN type: mms
Data binding and ActionScript 3
Data binding is really easy to do in MXML. But what do you do if you need to bind some dynamic objects at runtime using ActionScript? Here’s how I solved this particular problem in the following localization example.
Assume you want to add localization to a MenuBar component and the data provider is an Object. Let’s assume, for the sake of this example, that the Object that will act as dataProvider for the MenuBar component looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | private var menu:Array = [ { label: "FILE", children: [ { label: "NEW" }, { label: "OPEN" }, { label: "IMPORT", children: [ { label: "PROJECT" }, { label: "OTHER" } ] }, { type: "separator" }, { label: "EXIT" } ] }, { label: "EDIT", children: [ { label: "UNDO" }, { label: "REDO" }, { type: "separator" }, { label: "CUT" }, { label: "COPY" }, { label: "PASTE" } ] }, { label: "PROJECT", children: [ { label: "BUILD" }, { label: "CLEAN" }, { type: "separator" }, { label: "EXPORT" } ] }, { label: "LANGUAGE", children: [ { label: "ENGLISH", children: [ { label: "AMERICAN" }, { label: "BRITISH" } ] }, { label: "ROMANIAN" } ] } ]; |
Progress
For mrm’s TV Guide I needed a visual representation for displaying progress (i.e., saving data to the local database), so I used the built-in ProgressBar component. What’s nice about this component is that you can use three different methods to update the progress bar. You choose one of the methods by setting the mode property in MXML to one of the following values:
- event The control specified by the
sourceproperty must dispatch progress and completed events. The ProgressBar control uses these events to update its status. The ProgressBar control only updates if the value of thesourceproperty extends the EventDispatcher class - polled The
sourceproperty must specify an object that exposesbytesLoadedandbytesTotalproperties. The ProgressBar control calls these methods to update its status. - manual You manually update the ProgressBar status. In this mode you specify the
maximumandminimumproperties and use thesetProgress()property method to specify the status. This mode is often used when theindeterminateproperty is true
mrm’s TV Guide
Like any respectable person in this world, I don’t watch TV. But I do like some TV shows, so I watch them online or download them from various sources and watch them offline. Lately the number of shows I had to keep track of has grown substantially so I had a hard time doing it. (Actually, I’m just really lame and remembering 8 shows’ air dates is too big an effort for me)
So I had a few days off and I decided to build myself a little Adobe AIR app to help me out with my little problem. So without further ado, here’s the awesomeness of an application which I’ve dubbed “mrm’s TV Guide”:
Pretty Cool™, ain’t it? Yeah, I know. Now awarded with Softpedia’s “100% Clean” award!

So here’s how it works. Click to continue…
Hello world!
Why am I a hypocrite?
Well, because I always said blogs are a waste of time. But not all of them, just those “online diary” type of blogs. You know what I’m talking about, those “here’s what I did this morning”, “this is a picture of the sandwich I just ate; it was delicious”, “I’m so sad, please comfort me” etc etc.
This is not going to be one of those blogs. This is going to be one of them tecknical blogs. I’ll mostly be writing about Flex, ActionScript, JavaScript, web technologies and the sorts. It’s all so exciting and I’m really looking forward to it!
