Wednesday, May 9, 2007

Do you count months from 0 to 11 ???

Just to let you know that for some strange reason Flex dates are a bit 'unusual' (at least to .NET developers like me). When checking the 'month' property of a date it's 1 less than the actual month. Why? Flex assigns 0 to January, 1 to February, 2 to March, ... Easy to get around but rather 'silly', no?

Another unusual thingie is the fact that you need to use the 'date' (!) property in order to get the number of the day in the month (and in this case it is NOT 0-based...).

I assume it's to trick people when doing the brand new Flex2 certification exam :)

Monday, May 7, 2007

Dragging and dropping but what about the Z-INDEX ?

I don't know whether you know but dragging components around the screen is sooo easy in Flex. The code below works within an MXML component. If you want it to work in an MXML application then you should replace 'this' by the actual component name.

mouseDown="this.startDrag(); " mouseUp=" this.stopDrag();"

Question is: how to make the component being dragged the top component (make it appear above all other components) ? After some searching I found the following solution:

mouseDown="this.parent.setChildIndex(this,this.parent.numChildren-1); this.startDrag(); " mouseUp=" this.stopDrag();"

Sunday, March 18, 2007

Namespaces - aarrghhhh

Am I overlooking something or is it just impossible to use an HttpService with resultFormat="e4x" in combination with databinding IF the incoming XML contains a (default) namespace???

Preventing the namespace from being sent to the HttpService seems to solve the problem but isn't really a nice solution...

Suggestions are more than appreciated!

Thursday, March 15, 2007

Interested in server-side session state ?

I've been trying to make my Flex based client to end up in the same server-side session upon each HttpService request.

Each request to a session-enabled ASP.NET page returns a cookie with the session id. By sending this ASP.NET_SessionId cookie back upon each request you can benefit from the session support built in ASP.NET.

There's one problem however: there doesn't seem to be a way to get the cookie information after an HttpService request... This is not going to stop us of course :)

The solution is easy:

- Create an ASP.NET page that returns the session id (in the 'normal' page output)
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
Response.Write(Session.SessionID);
Response.End();
}
}

- Store the session id in your Flex application for re-use
...
var sessionCookie: String;
private function loginRequestHandler(event:ResultEvent):void
{ sessionCookie = event.result.toString(); }
...

- Re-use the cookie information with each new request:
...
userRequest.headers = "Cookie: ASP.NET_SessionId=" + sessionCookie;
userRequest.send();
...

Too enthousiastic Flex caching

I've been trying to call a dynamic ASP.NET webpage multiple times (each time the page returns different information).

It seems that Flex is, by default, caching the response. The 'ugly' way is to append some unique id at the end of the url to force a new request (http://somewebsite/stockquotes.aspx?ID=1, http://somewebsite/stockquotes.aspx?ID=2, ...).

There is however also a 'nice' way to solve the problem (at least if you have access to the ASP.NET source code). Just add the following code to your ASP.NET page (for example in the Page_Load method): Response.Cache.SetCacheability(HttpCacheability.NoCache);

Welcome, I'm Ria Flex

Hi! I'm Ria, Ria Flex (aka Tom Van den Eynde) and I would like to share with you my passion and experiences with Adobe Flex.

For those who don't know Adobe Flex yet: it is the ultimate solution to build modern, easy to use, web applications. You can find some examples of applications built using Adobe Flex online: