8.10.15

VBoxed

VirtualBox IE Test Platform

If you don't yet have VirtualBox yet, follow this link first.

Once you have VirtualBox and the OS installed, you can point your VM to your mac.

  1. In VBoxMgr menu, goto `VirtualBox|Preferences` from the menu and choose the Network tab
  2. Be sure you have at least one adapter under Host-only Networks (If not, press the + icon on the right to add one, remember the name it assigns and press OK)
  3. Right click on your vm instance and choose Settings|Network|Adapter 2 and be sure you have a Host-only Adapter (if not choose the Enable Network Adapter checkbox. It should assign the adapter name from the previous step. Click OK)
  4. Remember the name of the Host-only adapter (mine was vboxnet0)
  5. Open Terminal (on your Mac) and type ifconfig vboxnet0 where vboxnet0 is your Host-only adapter name from step #4. It should output something like this
    vboxnet0: flags=8943 mtu 1500
    ether 0a:00:27:00:00:00 
    inet 192.168.56.1 netmask 0xffffff00 broadcast ###.###.##.###
    Note the ip address next to inet: Mine was 192.168.56.1
  6. Launch your VM and create a desktop shortcut to add the virtual hostnames that point to your Mac. (Right click on desktop New|Shortcut. In the dialog enter notepad C:\Windows\System32\drivers\etc\hosts Press Finish)
  7. Add your Macs virtual hosts beside the IP from step #5. (Right click the new shortcut and choose Run as Adminstrator This opens notepad with your hosts file. (You need admin privileges to edit this file.) At the end of the file add your Macs virtual domains prefixed with the inet ip addresses. Save and close.
    # Virtual Hosts that live on my Mac
    192.168.56.1 dev.google.com
    192.168.56.1 mydomain.dev
    
  8. Open cmd (Click the windows icon and type `cmd` in the "Search Programs and files" field at the bottom. When it opens, type ipconfig /flushdns and close.
  9. Restart IE on your VM and browse to your Macs virtual domains.

13.7.13

Tricky

Sass

It's official… I've been REALLY nerding out on Sass… It's a cozy love hate thing.

Anyway.

Can you guess the resulting output of this Sass snippet?

.big-margins {
 background-color:purple;
 margin:100px;
}
.bar {
 background-color:red;
 margin:10px;
}
.foo {
 @extend .bar;
 @extend .big-margins;
 padding:0px;
}

Since we extended big margins last we might be under the impression that big-margins would win. That's the CSS way right?

Not necessarily. It depends on which extended definition comes first.

The output is...

.big-margins, .foo {
  background-color: purple;
  margin: 100px; }

.bar, .foo {
  background-color: red;
  margin: 10px; }

.foo {
  padding: 0px; }

I figured this out when it wasn't generating the output I thought it should...

.big-margins {
 background-color:purple;
 margin:100px;
}

.bar {
 background-color:red;
 margin:10px;
}

.foo {
  background-color: purple;
  margin: 100px;
  padding: 0px;
}

At first I was like "wow how smart!"

But now that I know about this I like the way I think its supposed to be better.

THE FIDDLE

9.11.12

Snippets

CSS


@font-face {
  font-family: 'MrDafoe-Regular';
  font-style: normal;
  font-weight: 400;
  src: local('Mr Dafoe Regular'), local('MrDafoe-Regular'), url(../fonts/MrDafoe-Regular.ttf) format('truetype');
}
#sel {
 font-family: 'MrDafoe-Regular', Arial, "Bitstream Vera Sans", "Bitstream Vera Sans Mono", Helvetica, sans-serif;
}

5.10.12

Create a sublime plugin

Date Timestamp Sublime Plugin:

import sublime, sublime_plugin, datetime class TimeCommand(sublime_plugin.TextCommand): def run(self, edit): self.view.insert(edit, 0, str(datetime.datetime.now())) # 2012-10-05 06:59:26.453598

31.8.11

Waving Flag


I heard once that it's not a good idea to use country flags for a language chooser, if anyone has a good idea about why, with some conclusive evidence/links that support it, I would appreciate some feedback. I've heard that some loyalists don't appreciate the order of flags, or the fact that the country flag they associate with appears beside a flag of lesser status. OK whatever. Give me the scoop if you know it.

At the risk of offending, I created a class that you can use to make a Spark Image Component "wave in the wind". I've only tested it with small (16x16) flag images, so you might need to experiment with the DisplacementMapFilter and perlinNoise function to get the effect you're looking for.

Here is a sample:
http://95008.shanimal.com/flag.html

Happy coding!

The Wave Class


The MXML Application


21.4.10

Parsing XML in IE

Recently a friend that was using an old Wrox xml parser (zxml.js) ran into some errors with the release of the most recent version of FireFox and needed a fix. I recommended an upgrade to the latest library but realizing he was using a wrox library he wanted to find something that he could be fairly certain would be supported moving forward. (Nothing against wrox, he just felt for whatever reason the authors may stop supporting it someday.)

I recommended jQuery because of other features that no website should be without and I had read in several blogs that it was possible to parse XML with jQuery out-of-the-bag. After a short tutorial on how to parse XML using jQuery, it was pretty awesome to have a prototype running on FF 3.x. in a few minutes with some really basic parsing code like this:
    $(document).ready(function(){
$(strXML).find("id").each(function() {
var item = $(this);
alert(item.attr('name'));
});
});
My friend works for a large corporation so they were concerned with IE support all the way back to IE6 (at time of writing IE6 has an 8.9% market share.) Since its somewhat difficult to have more than one IE install on a PC and the fact that my PC was in pieces on my office floor, I took the lazy route and installed WineBottler. I am pretty happy with being able to test IE6 and 7 from the comfort of my cozy Mac.

I did a quick test in IE6, IE7, IE8 and to my dismay the XMLParser was failing. I hit Google again and found a solution to this problem. Which goes something like this:
    if($.browser.msie){
var xml = new ActiveXObject("Microsoft.XMLDOM");
xml.loadXML(strXML);
strXML = xml;
}
So this seems like a really simple fix and apparently its been a problem since IE6, so I don't understand why support isn't written into jQuery.

Its just another little IE burden, but isn't cross-browser-compatibility one of the primary goals?

5.3.10

Firefox about:config

I just found the about:config feature in Firefox. While searching google for a way to disable the backspace key in Firefox. (see about:config for details) I came across the Mozilla Support Forum

You don't know how many times I was in the middle of a post and pressed the backspace key and lost everything.

To disable the backspace key:
1. type about:config into your url bar.
2. find and double click browser.backspace_action
3. replace the "0" (zero) with a "1" (one)

That's it.

5.5.08

Anonymous Event Handlers

Oh Snap!



I've been at this (ActionScript) for a while and the longer I do it (and the more it allows me to) the more traditional I try to become. I often find myself writing a special class extended from some base class where the behavior is less than optimal and I always feel like I am really putting way too much into a simple problem to achieve a really simple goal.

This is especially true with event handlers where I need to wait for an event to make a function call with parameters. Just today I needed a generic handler for a TimerEvent. In one case the end goal was to call a function without any parameters and in the second pass an Array as an argument. Of course both cases threw an error because handler for case one expected no parameters and handler for case two expected an Array. As you know, the Timer event dispatcher blindly passes a TimerEvent to the handler. (In Flex this isnt a problem because you just bind the listener without the 'event' argument.)

Each case has a workaround, case one requires a new function (to scrub the event parameter) the second case requires a class to store a single instance of the array as a parameter. In an environment where developers loath new classes and lots of variable definitions I was searching for another way to handle these situations. I found this simple solution from Phantasmagoria
http://www.kongregate.com/forums/4/topics/6272?page=1

Basically its a function that takes the same parameters as the function you need to call and returns an anonymous function that accepts the Event type thrown by Timer. The returned function calls the function that you really want to call with a copy of the parameter(s) you specify (stored in a temporary scope.) At the end of the day your argument values are stored and your function is called without a new class or function call.

Here's a sample AS3 application depicting the second case.

08.08.04 One thing I wanted to add to this post. Say you have an array of objects and you want to set up separate handlers for each object in the array. Don't get smart and use an anonymous function. Because the handler will be overwritten in the next iteration (even if you use the "var" keyword) and all your handlers will actually be references to the last handler created. Instead pass the variables you want to roll into a class function that returns the handler (like in the sample above.) This guarantees that function scope variables are in a new function scope, not in the scope of the iterator.

4.4.08

Assign a class to an instance

Phatness



So its been a while since I've posted anything. My new job has been keeping me really busy. I thought I would write about Object.registerClass and talk about how I am using __proto__ to allow a class to become a specific target.

For seasoned veterans this is probably a part of your AS2 library of tricks. Until recently I had become accustomed to using Object.registerClass to accomplish this. The process was pretty straight forward.

1. Register the library item
2. Attach the clip
3. Un-register the library item (so that we don't later inadvertently re-attach an instance of the class in a later call)




This works great for instantiating a new instance of a class without having to link a library item explicitly at design-time and it allows you to attach classes anywhere at will during run-time. But you have to make sure that every swf has "_blank" in its library and you can never instantiate as instance of a class at the root. There are other drawbacks which I wont go into here.

Introducing the super handy "register" function. You can name your function anything you like: ("infect","control","become","instantiateAs" etc...) you dont need any library items, no design time links, and so on and so on.



Of course you want to replace MyClass with your actual class name and its probably a good idea to create a "main" function or something to run your initialization code from. The register function is static so you wont have an instance of this, just call target.main() and create a non-static function in your class. Then to register a target as a specific class you just call its register function and pass it a target.



This one line of code will even instantiate _level0, (Yes, _root) as your class, now for AS2, that is about as good as it gets.

23.4.07

Booleans - Disturbingly Little

Nice



My apologies to all of you programmers out there who have been developing in real languages all along.

Today I posted to flexcoders that I was a little disturbed by the fact that Booleans initialize to false. Prior to AS3 you could compare a Boolean to undefined. The Flex compiler seems to complain if you even think about Booleans as undefined or null:

"1184: Incompatible default value of type Null where Boolean is expected..."
when creating this function: public function f(b:Boolean = null)

"1012: Variables of type Boolean cannot be undefined... (e.g. )"
when making this comparison: b==undefined

Nice that it acts more like a real programming language, not nice that I have to mend my AS2 ways of using the absence of assignment as some third value for a boolean. In hind-sight, this isnt good programming practice anyway because it requires interpretation to understand the third meaning. Interpretation is always a maintenance nightmare.

End of the day flexcoders answered with something I needed to hear: "use an enum". Don't think the thought wasnt met with some resistance.

"Enum? Shoo-oo-oot those aint in achunscript"

Now earlier today I had concrete ideas about what an Enum is, but I have no real experience creating one. This always drives me nuts because our minds are designed to constantly spin problems with our spare processor cycles (kind of like SETI@home) Unfortunately this intra terrestrial activity tends to reduce the amount of good sleep I get... and it keeps me up at night.

I dove in and came up with an enum example that you can extend to create your own enums. This is pretty straight forward.

I personally think you grasp something 70% by using it 20% by creating it and maybe if you're lucky, 10% wondering about it. In any case, it will be really nice to spend time using enums instead of over-rethinking this really simple concept.

12.4.07

allowNetworking
all | internal | none

Sweet


I recently created a widget for MySpace and other community sites. Some of these sites force the community posting flash widgets to set the object allowNetworking attribute to 'internal'. I needed to know ahead of time wether I could just provide a link or if I would need a button to allow the user to copy the destination to the clipboard.

I couldn't find a built in function to check the value ahead of time, but I noticed that when I tried to call navigateToUrl with this attribute set to 'internal' or 'none', Flex throws a SecurityError...

Cool, using this knowledge I created a simple function that tries to call navigateToUrl with an empty url. Flash won't try to go to '' (empty string) but navigateToUrl still throws the SecurityError. So my function uses a simple try/catch/finally to return true or false.

Check out the sample code here:

allowNetworking Sample

Let me know if AS3 provides other means for testing this value, I couldn't find one.

17.3.07

ApolloCamp (San Francisco, 3/16)

Psick

It looks like another successful alpha release for the Adobe guys. I think the biggest take-home (other than FB2) is that web programmers can now move their creativity from the browser onto the desktop.

So widgets and projectors are nothing new. There is a plethora of projector software out there and most do a pretty good job at the things Adobe is touting about Apollo. I beleive the core advantage to using Apollo is that it extends into JavaScript, HTML and CSS and really the wholeist client picture is being unvieled before our eyes in new applications that are truly awe inspiring.

In the end, the developers that use Apollo will determine the success of it. Thanks to ApolloCamp I have been given a taste of whats to come.

Im both nervous and excited to imagine how this changes everything.

9.3.07

360Flex (San Jose, March 5-7)

High



First Blog Entry Ever!

It seems like a few years ago I just dropped my head into Flash and never took the time to look up or around to see what other people were doing with it.

This week I went to Flex360 (San Jose, March 5-7) and was like "Shia, what happened?"

Now there's Adobe Labs, FlexCoders, Yahoo!, Flex, AS3, Tom Ortega, Roger Gonzalez and Grant Skinner and a huge (super supportive) community built tightly around the technology. I admit, Im blown away by it all.

Where there were two companies ...
It seems like ten years ago now... but when I heard that Macromedia became Adobe I was honestly freaking out. Don't get me wrong, I love all of my built-by-Adobe-it-only-takes-five-minutes-to-initialize-desktop-applications, but like everything else I was fearful that Adobe would bloat my precious little runtime (remember Reader?)

Wednesday at 360Flex Emmy Huang and Justin Everett-Church from Adobe had an open wishlist session during lunch . The topic of player feature creep/bloat briefly reared its head and without going as far as to say they forwardly shared our concern, they did seem quite interested to know where we developers thought that bloat threshold might be. Interestingly enough, someone said "2Mb" (download is currently 1.967.)

Anyway. Kudos to The Man. Thus far I am truly impressed with the takeover, Adobe's involvement with the community, and finally last and not least, free beer / h'orderves ...

To give a little back, I compiled this little list of blogs from the 360Flex schedule. A little directory of gurus and heroes that make these conferences possible.


Please ping me if I got any of this wrong...

360 Flex Presenters Blogs:


Anatole Tartakovsky http://flexblog.faratasystems.com/?author=2
Ben Forta http://www.forta.com/
Ben Lucyk http://esria.com/
Ben Stucki http://blog.benstucki.net/
Chafic Kazoun http://www.rewindlife.com/
Christian Cantrell http://weblogs.macromedia.com/cantrell/
Christophe Coenraets http://coenraets.org/
Clint Modien http://clintm.esria.com/
Danny Patterson: http://dannypatterson.com/Resources/Blog
David Zuckerman http://davidzuckerman.com/adobe/
Deepa Subramaniam (Adobe)
Ely Greenfield http://www.quietlyscheming.com/blog/
Grant Skinner http://www.gskinner.com/blog/
Harris Reynolds http://blog.harrisreynolds.net/
Jason Williams (Adobe)
Jesse Warden http://www.jessewarden.com/
Joe Berkovitz http://joeberkovitz.com/
John Wilker http://www.johnwilker.com/j/
Kevin Hoyt http://weblogs.macromedia.com/khoyt/
Kevin Schmidt http://www.flexinabox.com/
Mansour Raad http://webddj.sys-con.com/read/288053.htm
Mike Chambers http://weblogs.macromedia.com/mesh/
Mike Morearty http://www.morearty.com/blog/
Renaun Erickson http://renaun.com/blog/
Roger Gonzalez http://blogs.adobe.com/rgonzalez/flex/
Ted Patrick http://www.onflex.org/ted/
Tom Ortega http://lordbron.wordpress.com/