PaperVision3D one to one pixel representation

February 24th, 2009 admin 3 comments

It was hard for me to find the correct camera settings in papervision to achieve a one to one pixel representation of my objects at z = 0, so here they are:

camera.focus = 10;
camera.zoom = 100;

Voilá! Now move your DisplayObject3D to x, y and z = 0 and you should see it at its actual pixel size.

Categories: programming Tags:

Microphone activityLevel in Flash

January 14th, 2009 admin 8 comments

I wanted to analyse the frequencies of the microphone input in Flash, but guess what? You can’t!

With streaming sound it’s no problem, as this tutorial shows. But surprise: the microphone input is not accessible so you can’t respond to specific frequencies in you live sound input. Crap.

Anyway, after discovering this I set out to simply use the volume of the input, which is represented in the activityLevel property of the Microphone class. When activity is registered (you can set a threshold volume above which it does so), the ActivityEvent.ACTIVITY is dispatched, so you can respond to that.

Get ready for my next surprise: I only see the event being dispatched when my security settings panel is open, and then only when the microphone tab is active! Wtf is going on here?!

After battling with this, and trying out different possible solutions, it turns out that to make it work, you need to have set the loopback setting to true (microphone.setLoopBack(true)). This means that the microphone input will be played back over your speakers.

Needless to say you won’t always want this to happen. In fact, you probably néver want this to happen (think of the feedback!), but apparently you have to in order to be able to read the input volume at all.

Luckily the solution is fairly straightforward: set the soundTransform property of the microphone to a SoundTransform instance with volume zero and presto: no mic sound playing back through your speakers, but an ActivityEvent.ACTIVITY event triggering nonetheless.

Categories: programming Tags:

setTimeOut crashes Flash player

December 2nd, 2008 admin No comments

I just spent the best part of the morning fixing a bug in a website that made my browser crash when I was trying to play a video in Flash using the FLVPlayback component.

What turned out to be the problem? Well, it was the fact that we used the built-in setTimeOut method to keep checking the buffering progress of the video. It would crash Flash player without exception. I removed the call to this method and replaced it by an enter frame listener, and now it works like a charm. No more crashing.

I haven’t tested it thoroughly yet, but it seemed to appear after I had upgraded to Flash CS4, making Flash Player 10 a suspicious candidate. So my suggestion is: avoid this utility method where possible!

Categories: programming Tags:

Extremely safe singleton classes

November 10th, 2008 admin 1 comment

I’ve found a solution to creating singleton classes that make it absolutely impossible for any class outside it to instantiate it directly.

The idea is that you create an inline class (in this case called ‘SingletonEnforcer’) and require an instance of that inline class as a parameter in the constructor of the singleton class. No class outside of it can instantiate SingletonEnforcer, and therefore no class outside of it can directly instantiate the singleton class itself!

Here’s the example code:

package
{

public class SingletonClass
{
private static var instance : SingletonClass;

public static function getInstance() : SingletonClass
{
if (!instance)
{
instance = new SingletonClass(new SingletonEnforcer());
}
return instance;
}

public function SingletonClass(enforcer : SingletonEnforcer)
{
if (!enforcer)
{
throw new Error(”SingletonClass must be instantiated through SingletonClass.getInstance()”);
}
}

}
}

class SingletonEnforcer {}

I’ve found this example on PixelBreaker’s blog. Check it out.

Categories: programming Tags:

Executing HTML links in Flex

October 27th, 2008 admin 1 comment

In the project I’m currently working on, I found that HTML links in textfields weren’t properly executing, although the text seemed to be rendered properly. My mouse cursor even changed to a hand cursor on rollover of the link within the text, but I could only actually ópen the link through the context menu that popped up after a control-click (or right click for the PC user).
After some searching, I found the simple answer to my problem on the Flex Examples blog: in order for the HTML link to be properly executed, the ’selectable’ property of the containing TextField must be set to ‘true’! If the text is not selectable, your HTML link won’t automatically be opened on click. Way to go Adobe!

Categories: Flex, programming Tags:

Removing ugly yellow focusRect in Flex

October 10th, 2008 admin 3 comments

Right now I’m working on a project in which Flex integrates Flash components in its application and we encountered the infamous yellow focus borders when hitting the tab key from inside the application.

It wasn’t as easy as I thought it would be to Google the solution to prevent the ugly yellow rectangles from being displayed. I’ve found the solution in the Flex help though, so I’ll try to improve the search results on Google by providing the solution here.

When you look at the focusRect property description of flash.display.InteractiveObject, it says: “Specifies whether this object displays a focus rectangle. A value of null indicates that this object obeys the stageFocusRect property set on the Stage.”
And there’s your solution! In your Flex application, create a method that is called on creationComplete and in this method add the following code:

stage.stageFocusRect = null;

Now all focus rectangles are globally disabled in your application. It’s as simple as that.

Categories: Flex, programming Tags:

IFIP ECS 2008

September 9th, 2008 admin No comments

I’ve just presented my graduation work on the physical induction of emotions and an implementation for entertainment on the IFIP Entertainment Computing Symposium.

The presentation can be downloaded at http://www.rockabit.com/downloads/IFIP_ECS_2008.ppt.

The paper can be downloaded in PDF format here:

full version (16 pages)

short version (8 pages)

Categories: science Tags:

Particle experiments

September 9th, 2008 admin 3 comments

Here’s some small experiments I did in ActionScript 3 with particles in combination with perlin noise determining how they move.

In all cases it’s a bunch of particles placed in a circle, each one having its position linked to a randomly chosen pixel in a scrolling perlin noise filled bitmap. The third example has only a few particles and interconnects them with a curve, creating a moving type of amorphous blob.

pulsating iris

pulsating fountain

globule

Edit: I’ve added a small motion blur effect to the globule to make it a little bit more interesting, visually.

Categories: programming Tags:

Updated for iPhone

August 19th, 2008 admin No comments

I’ve just upgraded my blog with the newest version of the software, so that I can add posts from my iPhone.
It is now WordPress version 2.6.1 and if you can read this, then blogging from my mobile works!
Let’s see if this works to increase my blogging frequency ;)

Categories: Various Tags:

Updated design travel blog

June 20th, 2008 admin No comments

I recently ‘beautified’ the design of my travel blog and it’s now online at www.reisabit.com (beware: it’s in Dutch).

Before, it looked too much like an application, very rigid and unpersonal. The color scheme was also too dark, using black and dark red.
Hopefully this new design gives the website a more open feel.

Categories: Uncategorized Tags: