Jun 23 2009

Hired at Flumotion

This Monday I was hired in Flumotion, a company that is expanding and which are going to develop major projects. 

I am very excited with this new job in which I hope to learn and give everything I can.

VN:F [1.1.8_518]
Rating: 0.0/10 (0 votes cast)

May 21 2009

Compile CSS to SWF memory bottleneck

If you work with Flex and Skins you may use the option “Compile CSS to SWF”, this is a good solution but I recently found that as you add more resources to the CSS file, Eclipse may suffer a memory bottleneck while compiling it.

To solve that problem I just decided to compile the CSS directly with mxmlc, and disable “Compile CSS to SWF” option. This will recover the compiling time for the application and it shouldn’t crash again.

The only thing you need to do that is to have mxmlc on the path and write this instruction on the shell / terminal:

mxmlc [path/to/file]/file_name.css

This should generate a file_name.swf on the same folder.

The only problem of this solution is to not forgot to compile the file every time you make some change! 

VN:F [1.1.8_518]
Rating: 10.0/10 (1 vote cast)

May 18 2009

Flex swf optimization ( I )

Update: I just found this  air application for link report visualization 

If you are an experienced Flex user you’ll know many ways to reduce the size of your compiled code. Using Modules, RSL, etc… But there’s nothing else you can do?

The trick I will show you do not necessarily reduce the size of your application, but you’ll get a complete list of all the classes on your project with the size it takes.

To do so you only must use this instruction:

 –link-report=report.xml

for the compiler. This will generate an xml file with all the information of your project, with dependencies, sizes, etc… You’ll find this file inside your bin-debug folder

I hope you find this trick useful!

VN:F [1.1.8_518]
Rating: 0.0/10 (0 votes cast)

Apr 19 2009

Flex, Amazon S3 and custom headers

Update: http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html, I think the problem is related to this, I’ll try to fix it soon.

Update: Seems not be working on the web, sure it’s some crossdomain issue so I’ll try to access to a budget ( since you cannot put a crossdomain.xml policy file on your Amazon’s root folder ) and I’ll update this post then 

Static and dynamic website objects ( SWF, mp3, images, etc…) are high bandwith consumers, especially dynamic ones liek SWFs due to development issues. If our bandwidth gets collapsed people will take a long time to see our website or even do not come to see it.

One solution to this problem is to move all these items to Amazon S3 which provides a very good service at low cost.

There is a library in google code (as3awss3lib) I could not get to run, probably because they need the AIR libraries and my intention was to use the core Flex libraries only. So I decided to investigate how the Amazon S3 API works, and then tried to access this API using HttpService. If you have tried the same thing you’ve found that not HttpService do not allow custom headers (even if AIR lets you), so I tried to find other ways to put my own headers in httpService, My attempt was to create a connection with the Socket object but soon I found this library (as3httpclientlib) on google code work done and I only had to worry about the connection.

Here is an example of a simple application ( Having some Security Sandbox Issues, I’ll check the policies but totally works on local ):

This movie requires Flash Player 9

And the code (to compile this code you will need these libraries: as3httpclientlib and as3crypto):

MXML source

VN:F [1.1.8_518]
Rating: 10.0/10 (1 vote cast)

Apr 4 2009

Flex & Drupal login ( Actionscript remoteObjects )

Hello People!

It has been a long time since my last post so I’ve decided to post something found interesting. Long ago, seeking a faster way to create my websites I found CMS called Drupal, this CMS provides a lot of very important aspects of a web, such as content creation, scalability and robustness. But as you know this blog is basically based on the Flash platform technologies, not Drupal, But I was interested in joining the two sides and make a login.

To follow this tutorial is recommended that you have some knowledge of Drupal and Flex

Requirements

Have a server ( local or remote ) with Drupal

Note:

This tutorial was mad with Drupal 6.x but I think you can do it perfectly with the previous version 5.x

To complete this tutorial you will need some modules that do not come with the core ( amfphp and services ) as well as the amfphp server. To install the modules simply unzip them inside drupal_folder/modules but i recommend creating a folder drupal_folder/sites/all/modules and copy them inside. Then it¡s imperative you download the amfphp server and copy the the folder inside the amfphp. ( You should have something like this drupal_folder/modules/amfphp/amfphp, the first amfphp is the module logic and the second is the server.

Now we must activate some options of the modules we just install

- In Services activate Services ( it’s the only option, you can fail here xD )
- In Services - servers activate AMFPHP
- In Services - services activate System Service and User Service

You can go to the Drupal Services option and click on the AMFPHP server, you would see a default message from the server, if you can’t see it you may missed something.

One more thing before view the Actionscript code, in the Drupal Services menu, inside the Settings Tab, disable the “Use Keys” option which is used to provide security when we connect from external applications, and althought this tutorial might be used to create an external login too, we won’t use keys to simplify the tutorial ( maybe in a next post ) however we will leave the “Use sessid” active. 

Once you have activate that options ( remember to save once you’ve activated ) we need to give permissions for anyone to access the services, if not an anonymous user couldn’t login because it couldn’t access them. Now we can begin to create our AS3

Before giving the Actionscript code I would like to discuss some aspects of the code:

While creating remoteObjects is easier in mxml I always prefer to avoid it using Actionscript but this meant more time until I found the way to communicate Flex with Drupal because I couldn’t how I could pass parameters to Drupal, if you’ve encountered the same problem, I hope this tutorial help.

Note:
Before communicating with any other service you must have your sessid, you’ll do that connecting with the system.connect service, which will return you an object containing the sessid. If you do not know if your services are working correctly because of your code or because of Drupal, you can execute them directly from the Drupal Services menu, there you can find all the parameters you need to execute any service.

Using MXML remoteObject is implemented like this ( using user.get as example ) :

<mx:RemoteObject
id=”test”
endpoint=”http://localhost/drupal/services/amfphp”
destination=”amfphp”
source=”user”
result=”handler_drupalResult( event )”
fault=”handler_drupalFault( event )”>
<mx:method name=”get” >
<mx:arguments>
<sessid>sessid</sessid>
<uid>1</uid>
</mx:arguments>
</mx:method>
</mx:RemoteObject>

This service is used to get the information about the user with a certain uid ( user id ). In order to do that you must be logged in.

In Actionscript should be something like this:

drupal.source = “user”
var params:Object = new Object();
params.sessid = sessid;
params.uid = 1
Operation(drupal.getOperation( “get” )).argumentNames = ["sessid","uid"]
drupal.getOperation( “get” ).arguments = params;
drupal.getOperation( “get” ).send();

The lined marked in bold is the one I was searching during hours, this is automatically implemented in the mxml component, if you don’t put it Drupal will always return “Missing Arguments”

Finally, the code:

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application
layout=”absolute”
xmlns:mx=”http://www.adobe.com/2006/mxml”
applicationComplete=”init()”
>

<mx:Script>
<![CDATA[
import mx.rpc.remoting.mxml.Operation;
import mx.messaging.channels.StreamingAMFChannel;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.remoting.mxml.RemoteObject;

private var drupal:RemoteObject;
private var sessid:String = "";

private function init():void
{
drupal = new RemoteObject();
drupal.endpoint = "http://localhost/drupal/services/amfphp"

drupal.destination = "amfphp";

drupal.addEventListener( ResultEvent.RESULT, handler_drupalResult );
drupal.addEventListener( FaultEvent.FAULT, handler_drupalFault );

}

private function handler_drupalResult( event:ResultEvent ):void
{
log( event.toString() )
log( event.result.toString() )
try
{
sessid = event.result.sessid
LBL_sessid.text = event.result.sessid
}
catch ( error:Error )
{

}

}

private function handler_drupalFault( event:FaultEvent ):void
{
log( event.toString() )
}

private function handler_systemConnect( event:Event ):void
{
drupal.source = "system"
drupal.getOperation( "connect" ).send();
}

private function handler_login( event:Event ):void
{
drupal.source = "user"
var params:Object = new Object();
params.sessid = sessid;
params.username = TI_user.text;
params.password = TI_password.text
Operation(drupal.getOperation( "login" )).argumentNames = ["sessid","username","password"]
drupal.getOperation( “login” ).arguments = params
drupal.getOperation( “login” ).send();
}

private function handler_logout( event:Event ):void
{
drupal.source = “user”
drupal.getOperation( “logout” ).send( { sessid:sessid } );
}

private function handler_get( event:Event ):void
{
drupal.source = “user”

var params:Object = new Object();
params.sessid = sessid;
params.uid = 1
Operation(drupal.getOperation( “get” )).argumentNames = ["sessid","uid"]
drupal.getOperation( “get” ).arguments = params;
drupal.getOperation( “get” ).send();

}

private function log( message:String ):void
{
var d:Date = new Date();
TA_results.text += “[" + d.toLocaleTimeString() + "]\n” + message + “\n\n”;
}

]]>
</mx:Script>
<mx:TextArea x=”356″ y=”38″ width=”467″ height=”558″ id=”TA_results”/>
<mx:Panel x=”63″ y=”38″ width=”285″ height=”75″ layout=”absolute” title=”System”>
<mx:Button x=”15″ y=”10″ label=”connect” width=”235″ click=”handler_systemConnect( event )”/>
</mx:Panel>
<mx:Panel x=”831″ y=”38″ width=”285″ height=”558″ layout=”absolute” title=”Data”>
<mx:Label x=”10″ y=”10″ text=”sessid:”/>
<mx:Label x=”10″ y=”27″ width=”245″ fontWeight=”bold” id=”LBL_sessid”/>
</mx:Panel>
<mx:Panel x=”63″ y=”121″ width=”285″ height=”251″ layout=”absolute” title=”User”>
<mx:Button x=”15″ y=”88″ label=”logout” width=”235″ click=”handler_logout( event )”/>
<mx:Button x=”15″ y=”63″ label=”login” width=”235″ click=”handler_login( event )”/>
<mx:Button x=”15″ y=”145″ label=”get” width=”235″ click=”handler_get( event )”/>
<mx:Label x=”15″ y=”10″ text=”user:”/>
<mx:Label x=”15″ y=”121″ text=”user ID:”/>
<mx:Label x=”15″ y=”33″ text=”password:”/>
<mx:TextInput x=”86″ y=”8″ width=”164″ id=”TI_user” text=”"/>
<mx:TextInput x=”86″ y=”119″ width=”164″ id=”TI_uid” text=”1″/>
<mx:TextInput x=”86″ y=”31″ width=”164″ id=”TI_password” text=”"/>
</mx:Panel>

</mx:Application>

Espero que te haya servido de ayuda!!

I hope you find this usefull!!

VN:F [1.1.8_518]
Rating: 0.0/10 (0 votes cast)