Archive | May, 2013

VerifyError: Error #1102: Illegal default value for type int

07 May

Stubled across an AS3 compiler bug that I've seen before, but couldn't find a good explanation via Google for. If you get the above error, make sure you don't initialize an "int" to "null". Changing it from:

public function Quad( w:Number, h:Number, color:int = null )

to:

public function Quad( w:Number, h:Number, color:int = undefined )

will remove this stupid compiler error...

Flash Builder fails to start

25 Oct

Flash Builder fails to start

After upgrading my Mac to Mountain Lion, I keep having problems with the machine not going to sleep as it should. Instead, some process (that I never started) hangs the machine at full load. I usually find my machine with the fans blowing hot air and in an unrecoverable crash state. Many of my friends have the same problems with Mountain Lion, but I've found that the problem disappears if I unplug my external screen before putting it to sleep? I dunno why, but this works.

Anyway - yesterday I for got to unplug the screen and upon rebooting I could no longer start Flash Builder. It took a while to Google the correct result so here's the quickfix and link. If Flash Builder 4.5, 4.6, 4.7 or any other version fails to restart, it's usually your workspace that have become corrupted. The fix is simple. Open a terminal window and navigate to your workspace directory. In this folder, there is a hidden directory called .metadata. This is what is corrupt. Solve the issue by changing the name like this:

mv .metadata .metadata.old

On next restart, Flash Builder (or rather Eclipse) will recreate this file. Unfortunately it won't restore your projects so you'll have to manually import these again. There's also a more complex option for the command-line savvy. 

Away3D 4 Basics

12 Mar

Away3D 4 Basics

Finally taking the time to update the tutorials over at Flashmagazine to cover the Away3D 4 Beta that was released a few weeks ago. It's more than 40 code examples mixed into the 12 tutorials so it'll take some time to get through it all. It's mighty fun though and I'm really happy with the speed I'm seeing on both desktop and devices!

I've had a couple requests recently for how to do just a very basic 3D scene using Away3D v4, so here it is in case others need it too. It's just a cube that you can spin with either the mouse or keyboard, but it shows off quite a few of the differences in how to do things in v4. Materials, meshes, lights - there's differences for many core things. I'll summarize all these changes as I go through the code examples.

Arduino Companion - now out on Apple App store

17 Feb

Arduino Companion - now out on Apple App store

I knew about it, but it's facinating to experience firsthand the "Time To Market"-difference between Apple and Google. On Android, you can push things live on Market in a matter of minutes. Getting approval from Apple took 7 days. During that time I have received my first batch of feedback from Android users. I've gotten four 5-star reviews on Market, plus one 1-star review. The guy with the 1-star review didn't manage to install AIR on his handset for some reason. It hurts a bit to get a review like this when you're spending lots of time making something for the community to use for free, but it's better to know about the issue than not.

And - as my friend Paulo pointed out - export your app using Captive Runtime for Android. That'll include the correct version of AIR inside the app so the user never has to worry about it. It'll increase size, but reduce frustations so I'll certainly do that for the next version. Winter holidays and FITC Amsterdam is coming up now, but when I'm back I'll start working on the app again. I'll rebuild the views -system since I now know how I want it to work and I'll also add some more features. The plans are: a capacitor calc, a Volt/Ampere/Resistance/Watt calc and the first bits of a Hardware Reference!

Arduino Companion - my first app for devices is out

10 Feb

Arduino Companion - my first app for devices is out

Tonight I finally pushed the app out to Android Market and Apple's AppStore. It's already live on Market, but I guess it can take both days and weeks for it to hit the App-store? I hope others will find it as useful as I do. The idea of an offline Reference came about when arduino.cc experienced some server issues in January 2012. When I looked around for a way to browse the Arduino reference, I figured I could make something better than what was already available. I also had need for a Resitor calculator, so I've added that as well. That one I use many times a day thanks to my newfound hobby.

Making the app

I have lots of plans for new features I want in the app, but feel free to suggest improvements or new features in the comments. All sorts of feedback is very welcome! The app is pure Actionscript. I made parts of the app using Flex initially and the speed/responsiveness was nowhere near what I wanted. The data for the reference is structured using Expressionengine for easy editing/export. It took about 1,5 weeks to take the app to it's current state and more than half the time was spent on testing. Getting one app to work well across multiple screens is really quite a mess, so I hope I've tested enough?

The only known bug is that my Asus Transformer will report incorrect sizes when the app is rotated. It actually swaps the values for rotated and default orientation around? I only have this Android tablet to test on, so if you have an Android tablet and a few minutes to test - please do so and leave a message here. Apart from that bug, it works like a charm on iOS and Android. I haven't tested it on Playbook as I'm yet to receive from RIM the one I won just before GotoAndSki.

I'll probably spend some time getting it published to the other app stores as well such as Amazon, Nook and maybe also smaller ones like Samsung Apps. Any other suggestions?

Other apps?

While this is the first one that has been  published, I've also worked other AIR-based apps for devices. Next out will be my game project MineGunner and start to play with Genome2D. I had to take a break from that when I discovered that I needed hardware to get it where I wanted. The demos I saw of Stage3D / Genome2D at GotoAndSki totally blew me away! Who will need more than 6000 sprites running at 60fps on an iPad? Not me! :-D

My thoughts on HTML5 and Flash’s future

29 Nov

Given the mess that Adobe has put us Flash developers in these days, I want to add to the conversation that I’ve never had a better time as a Flash developer! While Mike and Ben provide some good background on the choices, this does not compensate for how poorly this was communicated. Way to kill a devoted community Shantanu!

This should have been handled in a much different way and it puzzles me that there’s still nobody in Adobe talking about Flash’s unique strengths. It’s all about HTML5 these days and the 750 layoffs is probably just a start. Luckily for Flash as a platform, there’s others doing Adobe’s job in this area.

I should add that I’ve done dynamic HTML sites ever since I started in this business about 15 years ago. The Rock City project (in the previous post) uses ExpressionEngine as a backend and I also do smaller sites based on Wordpress on a regular basis. The new Away3D.com website is EE driven and I’ve written several EE plugins in PHP as I’ve needed them. It’s all about using the right tool for the job at hand.

I enjoy making sites and apps using HTML, but I could never do that every single working day. Flash is what brings fun to my job. Things I do with jQuery, CSS and CMS systems are really just something I do for bread and butter and to stay up to date. I’ll keep doing this as well as play around with other languages like Haxe and Processing (for Arduino and other things)

I still see Flash as a solid part of my future, especially with the new Stage3D and other gaming related features now in Flash Player 11. I’m thoroughly impressed by the performance I can get out of the AIR apps I write for Android and iOS and I love NativeProcess and the possibilities it gives. All the fun things I’ve done this year are thanks to the Flash platform and I don’t see that change in the near future. I’m pretty sure there’s no other tool that is as capable when it comes to multi-platform publishing that can actually utilize hardware features such as cameras, audio, video, p2p, multitouch, hardware 3d and much more on so many platforms - all with the same consistent rendering.

And the best part - the stuff that I made in Flash more than 10-12 years ago still works on 99% of all desktop machines as well as quite a few Android phones and tablets (for now).

Simple data storage from Flash to ExpressionEngine

26 Aug

Am working in a great project at the time. The backend is my fav cms ExpressionEngine and I play with audio programming, mutitouch, and phidgets all day. Good times!

Just thought that I’d post some experiences in getting data from Flash to ExpressionEngine since I’ve spent some time on that. The initial idea was to use SafeCracker with EE. This works to some extent, but there are a couple hiccups. Mostly it’s because of the XID required to do safe forms and 302 redirects. Due to this, we had to find a another path. For anything more advanced, we’ll use AMFie (ActionScript Remoting for EE, developed by bjornbjorn) but for the simple stuff, we’ll just use the Metaweblogs API plugin that comes with EE. It’s simple, but it’s all you need to just save some text easily (Getting it out is super easy with a custom template).

I was a little puzzled that there were only AS1 and AS2 libraries for XMLRPC. If you know of an updated AS3 Metaweblog API for Flash, please post it in the comments. Documentation for the Metaweblog API was rather crappy since the main site is broken but I found a couple resources that helped me solve how the XML were supposed to look. If you want to see how it’s done, there’s code in the extended entry. This is no API, but it does show how to insert data. It’s the same for the other methods.

Here’s the code snippet I use with the Metaweblog API:

        /**
         * Stores the users progression
         * Uses the Metaweblog API module in ExpressionEngine
         *  
         * @param session_id The id returned from getSession();
         * @param key A key you define for use with your application
         * @param value A value for the key
         * 
         */    
        public static function saveContent( session_id:String, key:String, value:String ):void
        {
            // The message that the MetaWeblog API wants
            var payload:String = "";
            payload += "";
            payload += "    metaWeblog.newPost";
            payload += "    ";
            payload += "        ";
            payload += "            2";                    // EE channel
            payload += "        

";
payload += "

"; payload += " myuser"; // EE user payload += "

";
payload += "

"; payload += " mypass"; // EE password payload += "

";
payload += "

"; payload += " "; payload += " "; // Struct with members per field payload += " "; payload += " title"; payload += " "+session_id+" - "+key+" - "+value+""; payload += " "; payload += " "; payload += " mt_excerpt"; payload += " "+session_id+""; payload += " "; payload += " "; payload += " description"; payload += " "+key+""; payload += " "; payload += " "; payload += " mt_text_more"; payload += " "+value+""; payload += " "; payload += " "; payload += " mt_keywords"; payload += " mt_keywords"; payload += " "; payload += " "; payload += " "; payload += "

";
payload += "

"; payload += " 1"; payload += "

";
payload += "

";
payload += "

";

var req:URLRequest = new URLRequest("http://example.com/?ACT=45&id=1"); // This value, you'll find on EE's metaweblog api module info page
req.method = URLRequestMethod.POST;
req.data = payload;

// Flash will add User-Agent and Content-Length for us, but Content-Type we set ourselves
var contentType:URLRequestHeader = new URLRequestHeader("Content-Type", "text/xml");
req.requestHeaders.push(contentType);

xml_request = new URLLoader();
xml_request.addEventListener( Event.COMPLETE, saveContentResult );
xml_request.addEventListener( IOErrorEvent.IO_ERROR, error );
xml_request.addEventListener( HTTPStatusEvent.HTTP_STATUS, httpResponse );
xml_request.load(req);
}

New toy

03 Aug

eeepad.pngI’ve been working with various devices and Flash the last half year and today I got myself a brand new toy, the ASUS Eee Pad Transformer. It’s the first Android tablet that has appealed to me in any way and the keyboard dock actually makes it usable as something more than just an entertainment-toy like the iPad is to me.

Don’t get me wrong though. Android is still miles behind Apple in terms of usability on their tablet OS, but HoneyComb 3.2 really isn’t bad at all and I needed a high resolution tablet (1280 by 752 pixels) for device testing. Getting my projects onto the device was absolutely straightforward except for one important thing - the device didn’t show up in Flash Builder initially.

Thanks to Mark Doherty and Twitter I got an answer in just minutes but it wasn’t exactly detailed: “you’ll need to add the oem code to a file called adb_usb.ini”. It took a few minutes to figure this out so I figured I’d post how to add any USB device to the Android SDK and Flash Builder 4.5 (an others) for future reference.

Open a Terminal window and at the prompt type this:
cd /Applications/android-sdk-mac_86

If your Android SDK is in a different location, just substitute the path above. Next, make sure you stop the ADB server by issuing the kill-command:
./adb kill-server

Next you’ll create the adb_usb.ini file. Open another Terminal window. By default, Terminal windows open at your home path and that’s just where we want to be. In this folder there should be a hidden folder called “.android”. You can’t see this using the OSX Finder, but if you type:
ls -la

you’ll see all the files in the directory. Enter the folder using the cd-command:
cd .android/

If you type “ls -la” again and no “adb_usb.ini” exists, type the following to create the file:
touch adb_usb.ini

The next step is adding support for the tablet/device vendor of your choice. You can edit this file using any good text editor or you can do it simply via the Terminal by typing:
echo “0x0b05” >> ~/.android/adb_usb.ini

That will append the hex value to the text file. In the line above, the characters “0b05” adds support for devices from ASUS. The full (but not complete) list of manufacturers can be found here: http://developer.android.com/guide/developing/device.html and using this you should be able to add support for any other USB-based device.

You finish off by restarting the ADB server:
./adb start-server

and then ask it to list devices connected:
./adb devices

On my machine this produced a list like the one below and made the ASUS Eee Pad Transformer device show up in Flash Builder as it should:
List of devices attached
370668942427457 device

I hope this is of use to others as well grin

Of course I’ll gotoAndSki(switzerland)!

31 Dec

Back in June, me and Thomas Nesse organized a mini-conference up at JuvassHytta. The basic idea was to snowboard and network during daytime, and then meet in the evening for good sessions, beers and more networking. Despite a low turnout (yeah. we should have started earlier) and insane snow (mid-summer mind you!) it was a solid success.

The attendee that had travelled the furthest - Fernando from Switzerland - liked it so much that he’s now put on his own version in the Swiss alps and guess who is going? Me, Thomas, Martin (Visual FunkMaster), Peter MÃ¥seide, Paulo, Niqui and probably many more! I hope to see you there as well? I’ll definitely bring my brand new Airboard!

The speaker lineup looks really good with a solid focus on mobile development and for once I’ll just enjoy it all and don’t do any reporting for Flashmagazine (as I always do at conferences). The skiing is brilliant in the Jungfrau region, the chalet we’ll stay at looks lovely and Fernando tells the food is so good he occasionally skips his vegan diet because of it! Me, Thomas and Martin will rent a car to drive around a bit the days before and after the event to check out the neighboring valleys. This will be my first trip to the Swizz alps so I’m really looking forward to it!

gotoandskiswizz.jpg

An incorrect Embed can break text input in Google Chrome

02 Dec

Some weeks ago I had a weird bug in a project I worked on. It was impossible to enter a question-mark in one of my Flex apps. This only happened in Chrome on Windows (7 & XP). After some digging, it turned out that it was also impossible to enter scandinavian characters in Uppercase. Me and a colleague Google’d a bit but couldn’t come up with anything that could point us in the right direction. We also failed at reproducing the bug, so we put it in the backlog.

There it was until today when a campaign site I was working on got the same bug report. This was a competition and the users were unable to register since the @-key didn’t work. With Chrome now at 10% and soon much more I had to find a solution - and I did.

The culprit is actually the Embed-tag! Certain settings here can break certain keys in Chrome. I couldn’t find this logged anywhere so I added it to the bug base with my workaround and posted this on Twitter. It turned out that I wasn’t the only one experiencing this issue and it’s apparently been around for a while. So - I just thought I’d type this up for future reference in case anyone else has the same problem and is looking for an answer smile