Tuesday, March 16, 2010

Static Methods and Properties in Flex

Static Methods and Properties:

•Static methods, also called class methods, are methods that are declared with the static keyword.
•Static methods, which are attached to a class rather than to an instance of a class.
•Static methods, are useful for encapsulating functionality that affects something other than the state of an individual instance.
•Static methods can be accessed only through a class and not through an instance of the class.
•We cannot use the keywords this or super within the body of a static method.
•[reason : Both the this reference and the super reference have meaning only within the context of an instance method.]
•Static properties are not inherited by subclasses. This means that static properties cannot be accessed through an instance of a subclass. A static property can be accessed only through the class object on which it is defined.
•Although static properties are not inherited, they are within the scope chain of the class that defines them and any subclass of that class.

Monday, March 15, 2010

Resolve Flex’s error: “Type was not found or was not a compile-time constant”

I just faced the terrible nightmare of “Type was not found or was not a compile-time constant” error (Flex Builder) and I lost several time to figure out what the problem was. I realized that I was using the same name for MXML Application file which was already used by a class inside one of my packages. So, by renaming the file I solved the problem, but I was not completely satisfied and I looked for a way to avoid the error mantaining the same file/class name. Initially I tried to use namespaces, but as the reference says: “Applying a namespace means placing a definition into a namespace. Definitions that can be placed into namespaces include functions, variables, and constants (you cannot place a class into a custom namespace)”. I finally solved by renaming class references inside my package with the full qualified name (from MyClass to com.mysite.foo.MyClass). I also clean up the project under menu Project -> Clean...

Friday, March 12, 2010

Logging in Log4j

Locate the log4j.cfg file ...


log4j.rootLogger=INFO, stdout, F
... etc ...
log4j.logger.org.apache.commons=info
log4j.logger.org.apache.axis2=info
log4j.logger.org.apache.axiom=info
#log4j.logger.org.apache.commons.httpclient=debug
#log4j.logger.httpclient.wire=debug
#log4j.logger.httpclient.wire.header=debug


So when you want to see the logging you can remove the "#" as required.

Some relevant links are here ...
"http://hc.apache.org/httpclient-3.x/logging.html"
"http://logging.apache.org/log4j/1.2/manual.html"

Ressources Monitor (Windows 7)

Tuesday, March 2, 2010

Automatize your task with ANT (copy folders and subfolder on a click)

Using the same build tool for all your projects simplifies your life and keeps things easier to manage. Many developers (especially Java developers) are already using Ant.

See the example below to copy a bunch of files on the fly.

< target name="_copy-file-local-server" >
< echo message="Copying compiled files -> server folder"/ >
< copy todir="destinationFolder" overwrite="true" >
< fileset dir="sourceFolder" >
< include name="**"/ >
< /fileset >
< /copy >
< /target >

See http://ant.apache.org/ for details