VM Ware Fusion

tldr; Shared directory sym links under windows for VMware Fusion
At my new work, it is mostly a Mac shop. And since I develop with a few tools that are Windows only, I needed a solution to cope with my needs. Dual boot/bootcamp wasn’t an option in no way did I want to be constantly restarting my system, and I also doubt that bootcamp drivers were even available for my Mac with retina display.

I could have gone with VirtualBox, my trusted VM solution of choice, for many years… but instead I had done some more research into the matter and discovered that VMware Fusion was a very specific but powerful solution. It is also a commercial product. Retailing just under the $50 mark, it isn’t terribly expensive for what you will be getting. And shadows in comparison to the cost of the Windows OS I would be needing to purchase as well.

I went the VMware Fusion route and have been exceedingly pleased. This product is not an end-all for any of my virtualization needs, VirtualBox will remain my vm of choice for Linux based hosts… But the performance and flexibility of VMware is smooth and beautiful, it provides better hardware drivers to things like the graphics card and it will run with Windows Aero enabled without even blinking an eye. Full screen or in Unity (interlaced / seamless) mode  it works great.

I have not tried gaming within the VM yet, but my guess is that it works well. Prob not perfect, but well enough to make it do-able.

One hurdle I had to overcome was shared directories.

Mapping a directory via conventional means didn’t work. I am a developer, so when using a source code compiler, it tends to be incompatible with network paths. Often it attempts to resolve it or use .bat scripts which cannot cope with network paths. So the solution is to map a network path to a local directory using a symlink under windows.

mklink /d “C:\Users\andy\Repositories” “Z:\andy On My Mac\Documents\Repositories”

The above command is an example of something I have used to resolve such an issue. The only downsides is that the IDE doesn’t pickup external changes automatically. If you change something outside of the IDE, you must refresh the directory. Not a big deal, since its the click of one button and changes are found. The other downside is compile time. What would normally be a 10 or 15 second compile turns into a 20 to 30 second compile. Nearly double. This is believed to be because it must loop through a virtual network adapter to give it the network-like features. There are ways around this as well, my IDE has a ‘bridge’ feature to allow compiling on the host, but I haven’t bothered to set that up yet because even though there is a slightly longer delay, the system works very well and is very stable.

AS3 Garbage Collection with Event Listeners

A quick word of warning to AS3 programmers. Don’t use anonymous functions with event listeners, because they WILL be garbage collected.

Took me forever to find this bug, it seemed that after 30 seconds or so all of a sudden my event listener would stop functioning. The event was never removed, still showed up in the debugger tools, everything. It wasn’t until after over 3 days of nailing my head against the keyboard that I finally figured it out.

Why use an anonymous function? Because that allowed me to pass variables seemlessly to my functions that I wanted to call. For example:

var aNumber:Number = 3;

aClip.addEventListener(
MouseEvent.ON_ClICK,
function(evt:Event):void {
callThisFunction(aNumber);
}
);

This is just a crude example snippit, but in this case if I have a MovieClip called “aClip” and I want it to call the function “callThisFunction” on the event of if it gets clicked, but I also want to pass it a parameter “aNumber”.

It was (in my eyes) a beautiful way to handle the situation, until the AS3 garbage collector stepped onto the stage (pun intended haha).

Hope this helps some desperate AS3 programmer that surfs Google like a starving vulture in a dessert looking for the smallest scrap of meat to appease their application from sporadic behavior.

AS3 blocking or yielding

Learned about a characteristic of ActionScript today. Although I have observed this attribute with the language, and had also learned how to work around it. I just had never had someone spell it out to me, and thus didn’t know the name/terms of “blocking” and “yielding”.

It makes sense from the overview of how AS3 is actually constructed and runs, but it is nice to have ‘closure’ of sorts and to have a full understanding as to why it acts this way.

Here is where I read about it
http://blogs.adobe.com/aharui/2008/01/threads_in_actionscript_3.html

Here are the important snips of the above article:

“… there is no yielding or blocking in Actionscript either. If the next line of code is supposed to run, you cannot prevent the next line of code from running. That means that when you call Alert.show(), the next line of code following that runs right away. In many other runtimes, the Alert window has to be closed before the next line of code continues.”

“…There is no solution to allow for blocking or yielding other than refactoring the application to be event-driven…”

Which with the event-driven solution mentioned above is actually what I have personally started using to solve this problem (or condition) before actually knowing about this content.

And so now you know.