Microsoft MAX like Flex Image View (with source)

Yesterday i installed Microsoft MAX. It`s the first app from Microsoft that uses WPF. I really like it but the first thing i thought was: “This can all be done in Flex too!” I especially liked the way the images reorder when you scale them. So back from work i tried it in Flex. I took the hybrid store example from adobe as a starting point.

You can view the result here.
And grab the source here.

Try scaling the images with the slider on the right and use the Devider and see what happens with the images. Also try to rescale your browser window. It is really easy to do such things with flex. It took about 20 minutes to do this (can you do this in ajax in this time?). It`s really just a rough sketch and if anyone improves it please leave a comment.
What i really like about Wpf is that it will become easier to sell Flex/Flash based apps because soon (when does Vista arrives?) normal desktop apps will look like Flex/Flash apps 😉

Clone Instances and keep Class reference

While checking out the Socket class i found a cool little trick. I´m sure everyone knows of the possibility to clone an Object with the help of the ByteArray Class. This method was introduced (at least to me ;-)) by senocular here.
The function looks like this:
function clone(source:Object):* {
var copier:ByteArray = new ByteArray();
copier.writeObject(source);
copier.position = 0;
return(copier.readObject());
}
The problem was that all the class information was lost. With class information i mean type info and thinks like methods were unavailable after cloning the object. When you try this:

var t:Test=new Test();
t.test=”hallo”;
var newObj=clone(t);
out.text=newObj.test;
out.text=newObj.sayHello();

I get the following error:

TypeError: Error #1006: sayHello ist keine Funktion.
at test/::show()
at test/___Button2_click()
But there is this nice Method registerClassAlias from the flash.net package. Using this:

registerClassAlias(“de.benz.something”, Test);
var t:Test=new Test();
t.test=”hallo”;
var newObj=clone(t);
out.text=newObj.test;
out.text=newObj.sayHello();

will keep the class information intact and the call to the method will be succesfull.
Man this is sooo cool. I´m loocking forward using this in two years when my company switches to flash 9 :-)
Anyone looking for a flex developer?

cheers

Benz

I

Actionscript 3 Resources

Here are some useful links to get started with AS 3:

From www.helpqlodhelp.com:

Tutorials from by Betaruce:

  • Basic tutorials for AS3 with focus on the Flash 9 alpha preview

Flashguru posts:

  • Loading external Resources (Bitmaps) with AS3 here.

Senocular:

  • Using AS3 with the free Flex SDK here.

GoToAndPlay() Tutorials:

assertTrue:

to be continued…