Current location: Oslo, Norway

Playing with a Wiimote in AS3 on OS X

Posted on Tuesday, December 09, 2008 @ 15:51 CET

So I've finally gotten around to playing with using a Wiimote with Flash. I started looking at the WiiFlash project but the server is Windows only and since I'm on a Mac I kept looking and eventually found MoteDaemon.

Now due to security restrictions with the Flash player, all socket servers need policy files and although the source is provided for MoteDaemon I didn't want to mess around with it in Xcode so I just made a quick AIR app that lets you play with it. The MoteDaemon included ActionScript library is AS1, so I ported it to AS3, which you can view source and download here.

To get it up and running:

  1. Download MoteDaemon from SourceForge and install it
  2. Run MoteDaemon and pair your Wiimote
  3. Download, install and run the AIRWii test app. Then click connect.

Now you should be able to see what's going on with the Wiimote. Next step is to do something with this data :)

The AIR app also has the source included for funsies.

- paulo

Extending your own MXML component inline or in another custom component

Posted on Monday, November 24, 2008 @ 18:57 CET

Earlier I was trying building a custom MXML component in Flex 3 with some basic functionality, lets call it MainComponent. The thinking was that it would handle all that stuff and then I could create "children" of it that would extend this functionality and contain their own content and extra methods.

I tried simply extending the MXML component, by setting the root node of another custom component to MainComponent but this failed with the following:

"Error: Multiple sets of visual children have been specified for this component (component definition and component instance). at mx.core::Container/initialize()"

Googling around a bit I found this post over at Tink's about extending your own MXML components. As it turns out its not possible to do this as I was thinking, but instead you create an internal Array of children to add to the main component and handle it yourself. You add stuff to this array in MXML using the property name as a tag, but as Ely Greenfield pointed out in a comment on that post, you can bypass this by using the [DefaultProperty] metadata tag. He wrote:

When you specify a default property, you are essentially telling the compiler that when someone uses your component in MXML, whatever they put inside the tag is really a value to be assigned to your defaultProperty.

So when you extend your custom component inline you can avoid those tags. However for some reason I didn't get around this when creating a child component as its own MXML file, but whatever - its one tag, I'll live.

Check out the example here (right-click for source) and you shouldcheck out Ely's comment which was very helpful.

- paulo

More dialog FAIL

Posted on Tuesday, November 18, 2008 @ 13:11 CET

Not sure why but lately I've been coming across more and more of these horrible dialogs. For example, I had this fantastic error pop up in FlexBuilder:

And last week this great one when trying to use Nordea's net-bank:

Dialog FAIL indeed.

- paulo

Adding .as and .mxml support to QuickLook

Posted on Tuesday, November 18, 2008 @ 11:49 CET

I love me some QuickLook, but after installing TextMate (and I don't know if this is what broke it) all I get is a Text Document icon when trying to QuickLook AS and MXML files. I came across a plugin called QLColorCode that adds color highlighting to XML files, and this other post that shows you how to hack it to do MXML too.

I simply followed the same instructions to add .as support, except for the language highlighting file since that already existed for ActionScript although doesn't seem to be used.

In any case, if you want to skip editing the contents of QLColorCode, then grab this file, unzip it and put it in /Library/QuickLook.

Oh, standard disclaimer applies - if it breaks your machine its on you :) But it works for me.

- paulo

More iTunes dialog fun - Sync Override

Posted on Tuesday, October 21, 2008 @ 19:59 CET

So today I get home from work, pop the iPhone in the dock to do a quick sync of some videos and I get the following dialog box:

What the hell? It synced fine this morning... Hmm, I wonder what the Override button does? Well, it overrides whatever happened and now it syncs again.

Very weird.

- paulo

Introducing swfversion.com

Posted on Wednesday, October 15, 2008 @ 16:11 CET

Last week I spent way too many hours trying to figure out why this SWF from an agency wasn't working when being used in a client's CMS. Turns out the CMS used another SWF that loaded in all other Flash content. The reason behind this was to show a generic preloader when loading Flash-based content across the board. Fine, makes sense but why doesn't it work?

Sound familiar? Loading SWFs into other SWFs doesn't "just work". Now we have two virtual machines, AVM1 for SWFs upto and including Flash 8, and the awesome, super-fast AVM2 for Flash 9 and above. Loading AVM1 stuff into AVM2 works fine (just don't try talking to it), but AVM2 into AVM1 not so much.

And that's what was going on. After much debugging, decompiling and tearing hair out I decided to check the version and of course that's what was going on. The SWF8 preloader was trying to load in a SWF9 and that was causing all the weird behaviour. So after talking to Chris we figured something had to be done to avoid wasting time on silly things like this in the future.

Enter swfversion.com. You'll need to upgrade to Flash Player 10 first, and then you can load any SWF whether its online or on your local filesystem to find out what version of the Flash Player its targeting, along with what version of ActionScript and frame rate.

Hopefully it will be as useful for the community as the excellent playerversion.com (Aral Balkan's tool for getting at the installed Flash Player info) and James Ward's Is It Flex (to check if that SWF was made in Flex).

As has been my thing lately, you can also use iCanHaz - simply use
http://icanhaz.com/swf/<URL>

Enjoy :)

- paulo

I Can Haz Awesome

Posted on Tuesday, October 07, 2008 @ 16:55 CET

While in Brighton during Flash on the Beach I got to hang out with David Stone, aka @builtbydave as I knew him, who along with Josh Russell are the guys behind icanhaz.com. If you haven't used iCanHaz its like TinyURL or bit.ly on steroids.

So lets start at the top, TinyURL is great because it creates, ahem, tiny URLs from long ass ones. So the URL to your Google Maps search for Oslo may be http://maps.google.com/maps?f=q&hl=en&geocode=&q=oslo&ie=UTF8&z=9&iwloc=addr, but if you were gonna post that to Twitter you'd run out of characters fast. Using TinyURL you can convert that same link to http://tinyurl.com/3r4wmy. Pretty cool and bit.ly does the same thing, except it accepts norwegian characters too while TinyURL seems to choke on these.

All well and good but the code after http://tinyurl.com/ is hardly memorable. Enter iCanHaz. If I want to make a tiny URL to http://paulofierro.com I can use http://tinyurl.com/4lx94j, but with iCanHaz I can have http://icanhaz.com/paulo. How cool is that? And easier to remember too.

The length of those is pretty close though so its not that much of a time saver. But this is where iCanHaz reveals its true power. Try http://icanhaz.com/google/kittens or http://icanhaz.com/w/Calculus. The first one searches Google for kittens and the second link searches Wikipedia for Calculus. Ok, you can already do this your browser's search bar but that's not the cool part, iCanHaz supports dynamic parameters!

This means you can set up your own custom dynamic URLs. For example, if you want to search this blog for posts on "flex" you have to do the following:

  1. goto http://paulofierro.com
  2. type "flex" into search box
  3. hit search

Or simply goto http://icanhaz.com/paulo/flex. To search Seb's blog for "papervision" posts, simply goto http://icanhaz.com/seb/papervision. I think that's pretty sweet :)

Setting up your own is simple:

  1. goto http://icanhaz.com
  2. set up a link to your site first, just in case people don't want to do a search, so point http://icanhaz.com/yoursite to http://www.yoursite.com/
  3. find out how the search works on your site. It might be yoursite.com/?q=XXX or yoursite.com/cgi-bin/search.pl?XXX, etc where XXX is the search term
  4. now forward http://icanhaz.com/yoursite/%s to http://yoursite.com/?q=%s (if that's how your search works)

To test that I remembered this correctly I forwarded http://icanhaz.com/flashmag/%s to http://www.google.com/custom?domains=www.flashmagazine.com&q=%s&submit.x=0&submit.y=0&client=pub-1013303726815967&forid=1&sitesearch=www.flashmagazine.com&channel=5419954328&ie=ISO-8859-1&oe=ISO-8859-1&flav=0000&sig=-b0bDMPNCXP_y3ci&cof=.... etc, etc, etc

Phew. So to search FlashMagazine for Away3D posts, you can simply go to http://icanhaz.com/flashmag/away3d.

And this is only search.

As far as I know it only accepts one parameter at the moment and you need to drop your email address in case you want to edit the URL it points to at a later date since this is still a manual process but its still damn cool.

So here's a short list of iCanHaz tips Dave showed me:

Yup, Skype support. It does this by using the skype:// pseudo-protocol which works if you have Skype installed.

I was telling Dave how this was awesome because the link to Mike Chamber's Flash Platform Community Chat™ used a long XMPP URL (xmpp:flashplatform_chat@conference.mikechambers.com?join) which you could use to join via a chat app that supported XMPP like Adium. At the time there was no support for it but a few minutes later Dave set it up and now iCanHaz does XMPP so to join the chat simply goto http://icanhaz.com/flashchat.

I also made /file/XXX. That displays a simple page with a link to the file so you can right-click to save it. Its kinda useful from time to time.

Anyways, that's it for me. If you have more tips please drop them in the comments and if you like iCanHaz join the Facebook fan club.

- paulo

FUGN Talk - TubeTheVote.com case study

Posted on Tuesday, October 07, 2008 @ 13:41 CET

Yesterday at the monthly Flash User Group Norway meet-up I did a quick case study on TubeTheVote.com. Going through the reasoning behind the project and how it was put together, going a little more in-depth than my previous post on it.

I tried to cover the following:

Sadly Perk was sick so he couldn't go through his Papervision3D renderer he built for it, but hopefully he'll be able to go through that at next month's meet-up.

Anyway, you can get the slides here (with notes so it makes sense) and the links I refer to in the slides are in the list above.

- paulo

FlexBuilder dialog fail

Posted on Tuesday, October 07, 2008 @ 13:15 CET

Flex dialog fail

Yesterday I was trying to activate my copy Flex Builder 3 and came across even more dialog box fail. Spot the error for 10 points.

- paulo

iTunes dialog fun

Posted on Thursday, September 25, 2008 @ 02:46 CET

So I was trying to update some iPhone apps earlier seeing that I had 3 updates available in iTunes. Clicking the "Download all free udpates" didn't work - I kept getting some kind of error. Figuring it was some weird bug I just pressed the "Get Free Update" button for each app and managed to get the following dialog, showing that yes even Apple gets it wrong sometimes:

- paulo