Archive | August, 2014

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...

Unexplainable errors in Flash Builder 4.7

11 Feb

For reference: if you have unexplainable errors in Flash Builder 4.7 (and other versions) make sure you turn off "Marc Occurences" in the IDE. Turning this feature off holds the key to removing errors such as:

"com.google.common.collect.ComputationException: java.lang.NullPointerException" and several more.

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.

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

Away3D interactive MovieMaterial issue

16 Jun

It has been a busy winter/spring, but I’ll get back to that very soon. Just thought I’d post a quick solution to an Away3D issue that bit me recently and finding the bug took forever. The problem was in an Away3D FlipBook project where I used the excellent AS3DMod made by Bartek. It’s a fairly complex project featuring video, zoomable images and much more and it also has some clever coding to ensure that it never tries to load more pages than it needs at any given time and it’s all configured via XML. But - on to the problem:

I was tasked with adding a dynamic Table of Contents to the Book. No problem I thought - all the pages are using the MovieMaterial so I’ll just generate a MovieClip or Sprite that has the TOC and then I’ll Jump to pages based on that. The problem was - no matter what I did, I couldn’t get the MouseEvents in the MovieMaterial to trigger as it should. In fact - there was no MouseEvents being triggered at all. I spent almost a whole day fiddling around with it with no result. I searched the Google Group for answers, but all the threads that looked like they had a similar problem/bug were unanswered.

After a lot of testing and failing, I realized that there actually wasn’t any interactive layer present in the View, despite the material being set to interactive = true. My buddy Alejandro suggested that I change the blendmode for the _interactiveLayer in View3D to see what was going on and this really put me onto it. The _interactiveLayer is a transparent layer in View3D that holds the Movieclip that you use as material (the material itself uses a bitmap for display). When you’re clicking in the view, you are actually clicking on this transparent movieclip that the engine cleverly overlays and moves around so it will look as if you’re clicking the 3D object.

By changing _interactiveLayer.blendMode to BlendMode.ADD, I could see the layer and start realizing when it was active or not. Then it struck me - there is no mechanism in Away3D that notifies a material that is has been moved from one Mesh to another! I was swapping materials a lot and as soon as I did the first swap, the interactive material failed. All I had to do was to make sure that the MovieClip used in the material was removed from the _interactiveLayer and then it would be reset.

So - be careful when you swap MovieMaterials in Away3D. If you loose interactivity, change the BlendMode of the _interactiveLayer to debug and make sure that you reset the movieClip by moving it to a different location in the DisplayList. I hope this post can help someone in the same situation!

oh, and by the way - using the latest AS3DMod with Away3D 3.6 seems to have a bug as well. I couldn’t pinpoint it, but if you’re using AS3DMod and seeing performance problems, try downgrading to Away3D 3.5. It solved the problem for me.

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