We released a new 0.7 version of the Spring ActionScript framework yesterday. This release is the first official release since moving from the Prana framework to the Spring ActionScript framework and contains a bunch of fixes and enhancements to the IoC container, an experimental MVCS package and a lot of new utilities. We also removed the Reflection API and now provide that as a separate library called AS3Reflect.

For more info on Spring ActionScript 0.7, please see the official annoucement at http://www.herrodius.com/blog/160

More info on AS3Reflect can be found at http://code.google.com/p/as3reflect/

Hope you enjoy this release. Happy coding!

- Christophe Herreman, Spring ActionScript project lead


No Tags

December 15th, 2008Google API - AS3 Library

A while ago, I have build an API library in AS3 that interfaces with Google’s own javascript API. To show you how performant this API is, I included a demo-app at the bottom of this blog.

The library is a simple collection of the API’s features, there is a class per feature, like Google Web search, Images Search, etc. Each library throws it’s own event with an Array of matching datatypes, for example GoogleWebItem, so it’s easy to keep track on wich data is recieved and what this data contains.

This api contains:

  • Google Web Search
  • Google Images Search
  • Google Book Search
  • Google Video Search (Google Video & YouTube)
  • Google Blog Search
  • Google Local Search
  • Google Patent Search
  • Google News Search
  • Google Translation
  • Google Weather
  • Google Suggest

This API is Flash & Flex compatible.

Little example code

var googleWebSearch:GoogleWebSearch=new GoogleWebSearch()
googleWebSearch.search(txtInput.text,0,lang)
googleWebSearch.addEventListener(GoogleSearchEvent.WEB_SEARCH_RESULT,onWebResults)

private function onWebResults(e:GoogleSearchEvent):void{
for each (var result:GoogleWebItem in e.data as Array){
trace(result.title, result.url)
}
}

The library

You can download the library here (updated).
The demo app can be found here.

Right-click in the app to see source-code.


No Tags

So you want to replace your cube’s sides with some fresh BitmapData? At runtime?

As you probably noticed before, there isn’t much of a reference on the Internet explaining on how to change the material of a cube (or any other 3D DisplayObject) in PaperVision3D.

You probably already know that you can assign wonderful materials like ColorMaterial, BitmapMaterial, etc to a cube by using a MaterialsList in its constructor.
But what should we do if we want to change the material after the cube has already been created?

The first thing you’d tried is to reapply the cube’s materials property (cube.materials = myNewMaterialsList) but you’ll notice that won’t work.
After looking for a few days I found the solution on how to reapply a new material (it has some limitation though).

The rescuing phrase:
cube.materials.getMaterialByName("front").bitmap = image;

Where “image” is a BitmapData Object.
Before you test this, keep in mind that there are a few limitations before this actually works (I don’t think its meant to be used like this)

Keep in mind that you are changing the side of the cube to a new bitmap so in the constructor of the cube: define the material of the side you want to change as BitmapData.

The code I used (there are several possibilities to do this):

var defaultFrontMaterial:BitmapMaterial = new BitmapMaterial(new BitmapData(267, 375, false, 0xFFFFFF));
defaultFrontMaterial.smooth = true;
defaultFrontMaterial.doubleSided = false;

var defaultBackMaterial:BitmapMaterial = new BitmapMaterial(new BitmapData(267, 375, false, 0xFFFFFF));
defaultBackMaterial.smooth = true;
defaultBackMaterial.doubleSided = false;

// Materials
materials = new MaterialsList(
{
front: defaultFrontMaterial,
back: defaultBackMaterial,
right: new ColorMaterial(0xFFFFFF, 1),
left: new ColorMaterial(0xFFFFFF, 1),
top: new ColorMaterial(0xFFFFFF, 1),
bottom: new ColorMaterial(0xFFFFFF, 1)
} );

The default material you are about to create for the cube’s front side should have the same dimension of that particular side. If you try to make the new BitmapData with a height and width of 1px and a solid color, you’ll end up with a rescaled image when you try to reapply the new material. (You might think: this default BitmapData side won’t display an image so why wouldn’t I make it 1px by 1px, but that’s a wrong thought :p).

And that’s it! I hope this method works for your particular case. This technique also works perfectly if the side has multiple faces (segments).

Many thanks to my collegues for supporting me and many thanks to PaperVision developers for the great API but let’s all hope they’ll make setters for applying new materials at runtime.


Technorati Tags: , , , , , , , ,


© 2007 labs.boulevart | iKon Wordpress Theme by TextNData | Powered by Wordpress | rakCha web directory