May
08
2009
0

Air project doesn’t run. No error.

Didn’t quite know what to use as a title, because the problem sounds a bit too generic. Anyway, on to the problem/solution.

The problem was that i was trying to convert an already built/in progress Flex project to Air and it was giving me some grief, since it simply didnt run. No error, nothing. The only message i got was if i tried to debug it, where i would get:

Process terminated without establishing connection to debugger.

Command:

C:\win2kapp\FlexBuilder3\sdks\3.3.0\bin\adl.exe D:\AppServ\www\workspace\tg_preimpressao_air_2009.05.08\bin-debug\main_preimpressao-app.xml D:\AppServ\www\workspace\tg_preimpressao_air_2009.05.08\bin-debug

Output from command:

invocation forwarded to primary instance

From some googling around, i found the error to be because the Air version on my Flex project was wrong to the one of the new Air project.

I had to go to the <project name>-app.mxml file in the src dir and change the second line from:

<application xmlns=”http://ns.adobe.com/air/application/1.0“>

to

<application xmlns=”http://ns.adobe.com/air/application/1.5“>

Notice the version diference.

Stir. Compile. Run. Smile.

NOTE: Alternatively, you can create a new Air project and open its <project name>-app.mxml to see the version number of your Air.

This solution was found somewhere on the net, cant really recall where, and was documented on a bug track in adobe.

EDIT: This problem happened again today and this time it was nothing of the above. It seems it can happen when, by some misfortune (i dont know why), adl.exe is still running when we try to run our Air project. I solved it by going to task manager and terminating the process. Everything compiled and ran normally from then on.

Written by 42 in: Flex, Flex Air | Tags: , , ,
Feb
23
2009
2

Format/convert decimal to hexadecimal (or other numeral system)

My problem was to convert some calculations from decimal to hexadecimal to be used in a canvas background color. Specifically, convert from CMYK, from a pantone list, to RGB and apply the result to a canvas.

In a different post i will describe the convertion, might be useful for someone.

Flex has a way of converting to several numeral systems. For example, from the manual:

var myuint:uint = 9;
trace(myuint.toString(2)); // output: 1001 - binary system
trace(myuint.toString(8)); // output: 11 - octal system

And to create hexadecimal values, to be used in uint format:

var r:uint = 250;
var g:uint = 128;
var b:uint = 114;
var rgb:String = "0x" + r.toString(16) + g.toString(16) + b.toString(16);
trace(rgb); // 0xfa8072

All seems well, except when the result in hexadecimal is just one caracter long, so be sure to check and pad it with a zero.
A simple example:

var r:uint = 8
var rs:String = (r.toString(16).length == 1) ? "0"+r.toString(16) : r.toString(16);

Breaking it down:

r.toString(16) –> converts the var r to hexadecimal, which equals “8″.

I then check the length of the result and, in case it equals 1, add a “0″ to the beginning of the string to pad it.

UPDATE/FIX: As pointed out by Joe (comment below), r.toString(16) converts the decimal number to string representation of a hexadecimal number.

Written by 42 in: Flex | Tags: , , ,
Feb
18
2009
0

Automatic scroll to the bottom of a TextArea

On my current project, i have a debug TextArea that continuously lists some var values and traces. This way i can keep track of whats going on without stopping execution to debug in Flex.

As the list fills, the Text starts going off the screen, downwards. I needed to keep the scroll on the TextArea always on the last piece of text. I googled and i found a solution by Joan Lafferty, from the blog “flex butterflies and bugs”, so all credit goes to where its due. I leave a link to the original post at the end of this one.

Anyway, the solution is as follows:

<mx:TextArea
valueCommit=”txtl.verticalScrollPosition=txtl.maxVerticalScrollPosition”
id=”txtl”
x=”202″
y=”10″
height=”206″
width=”122″
text=”{log}”
editable=”false”
enabled=”true”
wordWrap=”true”
textAlign=”right”/>

Save for the usual dimension/position properties, what you should look at is the valueCommit method, which will simply keep the scroll at the last bit of content in the TextArea.

Joan’s post is far better explained than this, and has an example. I am just posting this here as a reminder to myself and to other forgetful geeks out there.

Heres the link to Joan’s blog post about this subject:

http://butterfliesandbugs.wordpress.com/2007/08/20/scrolling-to-the-bottom-of-a-container-or-textarea-automatically/

Written by 42 in: Flex | Tags: , ,

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes