Archive for June, 2009
Tanki Online
Posted by cornel | Filed under Uncategorized
One of my friends told me about some online game called Tanki Online…I’m not a big fan of online multiplayer games but this game is really cool. It’s implemented in Flash with some impressive 3D effects. They released the game for open test and it seems that a lot of people are using it (sometimes you cannot play because the server is overloaded).

Using AMF and Web Services
Posted by cornel | Filed under Flex, Java, Uncategorized
You can pack and send your data using AMF even if you don’t use the remoting services. In this post I will show several ways to do that using HTTP services. Why would you want to do that ? There are organizations or departments that expose only REST and SOAP services and it can be hard to persuade them to add the remoting services. In this case, when using web services, you have two solutions: you can create XML from your object graph (and for that you’ll have to write extra code) and apply a compression algorithm on it, or you can apply AMF serialization on the object graph, add the resulting byte code in the service body, and deserialize the AMF format on the client side.
Below is a sample how to do that. First, the Java code on the server:
public void service(ServletRequest arg0, ServletResponse response) throws ServletException, IOException { Product product = new Product("name","description"); SerializationContext context = new SerializationContext(); context.instantiateTypes = true; ByteArrayOutputStream baos = new ByteArrayOutputStream(64*1024); Amf3Output amf3Output = new Amf3Output(context); amf3Output.setOutputStream(baos); amf3Output.writeObject(product); amf3Output.flush(); response.getOutputStream().write(baos.toByteArray()); }
On the client you have two options. The easier one is to use an URLLoader.
private function loaderCompleteHandler(event:Event):void { //rebuild the object var product:Product = loader.data.readObject(); } function sendData(event:Event){ var request:URLRequest = new URLRequest("/test/loaddata/"); loader = new URLLoader(); loader.dataFormat = URLLoaderDataFormat.BINARY; loader.load(request); loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler); loader.addEventListener(Event.COMPLETE, loaderCompleteHandler); }
If you want to use an HTTPService you have a problem, because by default it does not handle binary data. However it’s easy to extend the class and to add binary support.
public class HTTPServiceExt extends HTTPService{ protected static var binaryChannel:Channel; protected static var binaryChannelSet:ChannelSet; public var binaryData:Boolean; public function HTTPServiceExt(){ } override public function send(parameters:Object = null):AsyncToken{ if (( useProxy == false ) && (binaryData)){ if ( binaryChannelSet == null ){ var dcs:ChannelSet = new ChannelSet(); binaryChannel = new DirectHTTPBinaryChannel("directhttpbinarychannel"); dcs.addChannel(binaryChannel); channelSet = dcs; binaryChannelSet = dcs; } else if ( channelSet != binaryChannelSet ){ channelSet = binaryChannelSet; } } return super.send(parameters); } }
The class DirectHTTPBinaryChannel is taken from Anirudh Sasikumar’s blog. It extends DirectHTTPChannel and it configures the internal URLoader to work with binary data.
Now you have an HTTPService class that knows how to receive binary data also. In order to use it you have to add the binaryData parameter:
function resultCall(event:ResultEvent):void{ var product:Product = event.result.readObject(); } <local:HTTPServiceExt binaryData="true" id="srv" url="/test/loaddata/" result="resultCall(event)" fault="faultCall(event)"/>
That’s all. You can refine the code; for example you may want to create only one URL for all the resources and to pass parameters, or you can use SOAP services and add the AMF binary format as an attachment.
I also uploaded a Flex/WTP project here containing all the source code.
Android and Adobe Flash
Posted by cornel | Filed under Events
HTC Hero will be the first Android phone to ship with Adobe Flash Player. The announcement was made today by HTC and Adobe Systems at a press conference in London. Also HTC will join as a participant in the Open Screen Project. Great news for Flash, HTC is a very large company in the mobile phone industry.
The HTC Hero will support Flash Player 9 and ActionScript 2. Flash Player 10 is expected to be available in the near future.
More information can be found on Mark Doherty blog. Mark is an Adobe evangelist focused on mobile devices.
Adobe LiveCycle Data Services 3 beta is out
Posted by cornel | Filed under Events, LCDS/Blaze DS
The archive can be downloaded from Adobe Labs. You can also find samples, videos and documentation about the new modeling tools and about the new messaging features.
New update to Acrobat.com – Tables
Posted by cornel | Filed under Events
Yes, now you can create collaborative spreadsheets – see the movie here. It started with Buzzword, two weeks ago we launched Presentations and now Tables. Also, starting today one can buy Premium subscription, and if you register by16 July you’ll receive a discount – see this announcement.
Invoking LiveCycle ES services from an AIR applications
Posted by cornel | Filed under LiveCycle ES
There are two ways to invoke a LiveCycle ES service from an AIR application: using webservices or using remoting. I’m a big fan of remoting over any kind of SOAP or REST services so I will write only about that, taking the Assembler service as an example. The Assembler service allows you to create PDF files from a variety of input documents – you can even merge pages between several documents, add watermarks, headers and much more.
The first step is to configure create your Flex project and add the required libraries. In order to use LiveCycle remoting you will need to add the library adobe-remoting-provider.swc located in LiveCycle8\LiveCycle_ES_SDK\misc\DataServices\Client-Libraries. Note that this path depends on your LiveCycle ES installation folder.
The second step is to call the AssemblerService but you’ll need to know the required parameters and how to pass them. For that one should go to the API reference, look for the AssemblerService interface and take a look at the invoke method
public AssemblerResult invoke(
Document ddx, Map inputs, AssemblerOptionSpec environment)
The first parameter is the DDX (Document Description XML) file describing the structure of the output document. The second one is a map with values referencing com.adobe.idp.Document objects and keys are the logical names from the DDX file.
In order to invoke this method from AIR all the input parameters should be wrapped in an ActionScript object that will act as HashMap – the key is the name of the parameter and the value is the actual value of it. If a parameter is missing from the map it will be considered null. In our case we will set only the first two parameters – the DDX file and the inputs map.
The code used to declare the remote object can be seen below
<mx:RemoteObject id="AssemblerDocument" destination="AssemblerService" showBusyCursor="true" fault="assemblerFaultHandler(event)" result="assemblerResultHandler(event);"/>
Next we should build the value for the input parameters: the DDX and the inputs map. The DDX specifies that the output PDF will be created by mixing two input PDF’s (the files are locally referenced, they are located on the same server as the LiveCycle ES server. In a real case you would probably use URL locations for them).
var ddx:XML= <DDX xmlns="http://ns.adobe.com/DDX/1.0/"> <PDF result="PDFFinal.pdf"> <PDF source="Dictionary Of Weightlifting.pdf" pages="1-35"/> <PDF source="Health.pdf" pages="1-7"/> <PDF source="Dictionary Of Weightlifting.pdf" pages="36"/> <PDF source="Health.pdf" pages="8-33"/> </PDF> </DDX> var inDDXDoc:DocumentReference = new DocumentReference(); inDDXDoc.referenceType = DocumentReference.REF_TYPE_INLINE; inDDXDoc.text = ddx.toXMLString(); var inputs:Object = new Object(); var documentRef:DocumentReference = new DocumentReference(); documentRef.referenceType = DocumentReference.REF_TYPE_FILE; documentRef.fileRef = "C:\\tmp\\Dictionary Of Weightlifting.pdf"; inputs["Dictionary Of Weightlifting.pdf"] = documentRef; documentRef = new DocumentReference(); documentRef.referenceType = DocumentReference.REF_TYPE_FILE; documentRef.fileRef = "C:\\tmp\\Health.pdf"; inputs["Health.pdf"] = documentRef;
The final step is creating the input parameter map, setting the assembler credentials, and performing the asynchronous call
var parametersMap:Object = new Object(); parametersMap.inDDXDoc = inDDXDoc; parametersMap.inputs = inputs; AssemblerDocument.setCredentials(user, password); var token:AsyncToken = AssemblerDocument.invokeDDX(parametersMap); token.documentName = "Result.pdf";
That’s all – As you can see it’s trivial to call the Assembler service from an AIR application. The most difficult part is figuring out the description of the input parameters and all the options related to the DDX format.
SocialGeek Bucharest – first edition
Posted by cornel | Filed under Events
I will speak at the SocialGeek conference in 19 June. The event sounds interesting – some of the presenters will talk about technical things, others about the Romanian market. You can register here - hope to meet you there.
Flex Camp Cluj Napoca
Posted by cornel | Filed under Events
Together with Adobe Romania Transylvania Flex Group organized the first Flex Camp from Cluj Napoca. I presented Flash Builder and Flash Catalyst and the organizers talked about the AIR platform and some fancy game developed in house. There were about 50 attendees, and taking into account their reaction I think we will do another Flex Camp this year.
I received a nice T-shirt from the Adobe Groups – thanks guys. You can see the red bat, which reminds about an old legend:
I’ve uploaded my slides and examples here.
Oracle and JavaFX
Posted by cornel | Filed under Events
At JavaOne Larry Ellison talked about Java and about Oracle’s commitment to this language (the video can be seen here). This is very interesting because he talked also about JavaFx and about the pain of building applications using HTML and Ajax (I agree with him, at least for building RIAs). While it’s premature to talk about full Oracle support for JavaFx (which means they would compete with Flash & Silverlight), I think it will be interesting to see what will happen, taking into account that they also invested a lot in ADF (JSF based framework).
Blueprint – really cool plugin for Flex Builder
Posted by cornel | Filed under Uncategorized
Blueprint is a plugin for Flex Builder that allows the developer to search for code samples directly from the IDE. No need for switching between IDE and the web browser. Unfortunately works for the moment only for Mac
.