Monday, November 30, 2009

Hello World in ActionScript

If you are an old-school programmer (which doesn't necessarily mean better --that will always depend on the subject), when learning a language you always look for the simplest program that print "hello world" and that you can create with "vi".
Well, if you want to start some development in ActionScript then you might be troubled trying to find a "hello world" source code program to start familiarizing with the language (most examples and tutorials assume that you are using a IDE).
In this case do the following:
1.- Download and install FlexSDK.
2.- Modify PATHs in order to be able to execute the programs coming in flexsdk (e.g. the compiler mxmlc).
3.- Open a text file named "hello.as", paste and save the following:

package {
import flash.display.*;
import flash.text.*;

public class hello extends Sprite{
public function hello (){
var t:TextField = new TextField();
t.text = "Hello World";
t.width = 100;
t.height = 100;
t.x = 50;
t.y = 50;
addChild(t);
}
}
}

3.- Compile it: mxmlc hello.as (this will create hello.swf)
4.- Create an HTML file in your webserver with:

<html>
<body>
<object width="100" height="100">
<param name="movie" value="hello.swf">
<embed src="hello.swf" width="100" height="100">
</embed>
</object>
</body>
</html>
5.- VoilĂ ! your are seeing your first ActionScript program.

TEXT var type in MySQL

When you designed your database you may have selected TEXT because of its flexibility of size instead of a, say, a VARCHAR data type. If you ever thought you would store a text bigger than 65Kb on your TEXT columns and you started to having your strings cut, then you have reached the limit of TEXT var type in MySQL, and ACHTUNG! it will not complaint about this but silently truncate your data!
In bytes this limit is 65535 (2^16 - 1), which is, BTW, a Mersenne Number.
In this case consider using MEDIUMTEXT or LONGTEXT.

LARGE FILE SUPPORT (>2GB)

CFLAGS :
-D_FILE_OFFSET_BITS=64

or

#define _FILE_OFFSET_BITS 64

under 64bit OS you don't need it!!!