Archive for category Flash

Away3DLite uses an inverted y-axis

I switched over from Away3D to Away3DLite, hoping that my performance issues would be solved. And indeed, Away3DLite is much faster than it’s big brother. However, I suddenly noticed that the y-axis seemed to be inverted (negative values above the root and positive values under the root). I first thought I made some errors with the camera and that I was seeing everyting upside down.

This post seems to explain the reason: The y-axis is inverted.

Strange thing is, however, if you place a cone on the scene, it is pointing upwards as you would expect when using a normal (not-inverted) y-axis. Makes it all a bit confusing, but now you know…

No Comments

Refer to an embedded image by a string variable

I’m making a small banner like application. All images have to be embedded into the application, but I want to be able to dynamically create these images. The position on the stage is configured using an external XML file. So, somehow, I have to be able to make references to the embedded images in my XML-file.

Example of an embedded image:

[Embed(source="assets/image.jpg")]
[Bindable]
private var myImage:Class;

An easy way to do this is of course:

var imgClass:Class;
switch (imageName) {
    case 'myImage':
        imgClass = myImage;
        break;
   case 'otherImage':
        imgClass = otherImage;
        break;
}

But there is an easier solution. Say that the image is embedded in MyView.mxml, then you can use this statement in MyView.mxml;

var imgClass:Class = getDefinitionByName(getQualifiedClassName(this)+'_'+imageName) as Class;

If you use the debugger, you’ll see that imgClass looks like: MyView_myImage. Or more specifically, if MyView.mxml is located in package, e.g. ‘views’, then imgClass = views.MyView_myImage;

No Comments

Searching XML on attribute results in runtime error: Variable @ is not defined.

See this.

No Comments

MouseEvent.ROLL_OVER has strange behaviour when used on an object with drop shadow

If you set a drop shadow on a movieclip and use roll over and roll out to grow or shrink the movieclip (roll over = grow, roll out = shrink), you get alternating roll over and roll out events, even if you don’t change the mouse position. This happens when you put the mouse at the edges of the object. Apparently, the filter causes this strange behaviour. I solved this by placing a transparent hitArea object over the movieclip, to ‘divert’ the mouse events to the hitArea. Of course, you must not define a drop shadow for the hitArea.

No Comments

hitArea only works if the referred sprite has the same parent

You can assign another object to be the hitArea of a sprite. See:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Sprite.html#hitArea

Unfortunately, it seems that both the hitArea object and the sprite must have the same parent.

No Comments