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.position = 0;
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();
var newObj=clone(t);

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 package. Using this:

registerClassAlias(“de.benz.something”, Test);
var t:Test=new Test();
var newObj=clone(t);

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?




My First Steps With Flash Data Services

Today i finally got the time to install the flex data services. For me this is quite an adventure as i`m not really a server or java guy. So for me the first thing was to get tomcat. I know it would have been easier to use the integrated jrun but i think tomcat is a more common setup.

Installing Java Open Transaction Managet (JOTM)

With this decision comes the first problem. In order to use the data management features one has to install the Java Open Transaction Managet (JOTM). No big deal if you know that 😉 You can grab a version here.
Unzip the file and locate the lib folder. Now copy all of those jars into your tomcat project folder under WEB-INF/lib. Here i struggled for a moment. I thought know the CRM example that ships with FDS should work fine but it didn`t. The solution was to create a config file under TomcatInstallation/conf/Catalina/localhost/ . The file needs to be an xml file named after your webapp directory e.g. samples.xml. Assuming your webapp directory is called samples the content should look like this:
<Context docBase=”${catalina.home}/webapps/samples” privileged=”true”
antiResourceLocking=”false” antiJARLocking=”false”>
<Transaction factory=”org.objectweb.jotm.UserTransactionFactory” jotm.timeout=”60″/>

Replace ${catalina.home}/webapps/samples with your location.
With this setup i was able to run the CRM samples. Next step will be to configure everything for messaging. What would be the best messaging provider for tomcat?
As i said i`m pretty new to all this server/java stuff but i`m allready really impressed by FDS.

Anyone knows of good tutorials for starters? Any suggestions?