February 07, 2007

My first Flex app... some q's in here if anybody can answer them.

So.. I built a calculator :)

I think I like Flex but am still having trouble getting the hang of it in some ways.

One of the funny things I found is that I didn't know how to deploy what I had just built. Like if I wanted to put this crappy calculator in a page I already have, how would I do that? Checking the help docs didn't come up with much at all and I still didn't get how to deploy this thing (like Flash's "publish" option). I just copied over all the files in the bin folder. Seems to work... but really, I'd like it all compiled into one SWF that I could just stick on a page. Is that even possible?

Here's the source if you're interested. I wish I knew how to do the right click thingy and choose "view source".

Lots more studying to do.

UPDATE**
Got the view source right click thingy working, now how do I change the language of it? It's in English, the only thing in the menu that happens to be English for me. Is it possible to change that to another language?

Posted by Graeme at February 7, 2007 10:20 AM
 



Comments

Copying everything in the bin directory is easiest. You could just copy the SWF but then you wouldn't have anything that can detect Player versions to make sure folks can view. You can also simplify what's in the bin folder by looking at the compiler options in Flex Builder and take out the history manager for example, or express install, etc. It's all in your hands.

Since we add the View Source text ourselves (instead of it being built into the Player), it comes from a resource bundle I think. You'd need to create a resource bundle that translates that text to the language of your choice. You may want to view the source of mx.core.Application and track down code around the viewSourceUrl so you can see how things are used.

Good luck!

Posted by: Matt at February 7, 2007 10:41 AM

Great job! I set out to write a calculator example the other day and never finished it.

One thing I would suggest that you look into is HBox and VBox tags for your layout. Its a lot easier than the absolute positioning for everything, and if you have to find something in the source its generally easier.

But yeah, you should be able to take the swf and deploy it anywhere, especially since it is all self contained and not relying on server-side processing.

Posted by: Ryan Guill at February 7, 2007 10:00 PM

The only caveat to just using the swf is the history management (Browser back button integration) built into Flex controls like Tab Containers and Accordions will be lost.

Posted by: arpit at February 8, 2007 12:24 AM

To change the language local of the Flex application go to:
Project -> Properties -> Flex Compiler.

In the "Additional compiler arguments:" field change -locale en_US to your respective local setting.

If you are not using Flex Builder just use a different -local argument in the mxmlc compiler arguments.

Posted by: Renaun Erickson at February 8, 2007 01:14 AM

Thanks everybody for the comments. Matt, I'll look around a bit more at stuff but it seems Renaun has some great advice there on how to fix the problem. I'm using Flex Builder so I'll check the properties. The only thing I wonder though is what else changing the locale will do.. I mean, will it affect anything else?

Ryan, great advice on the h and vboxes. I used those for a mockup of something else I was messing with but wasn't really sure I needed them in the calculator app.

Posted by: Graeme Bull at February 8, 2007 02:08 AM