My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
GettingStartedInShinyColor  
Getting Started in More Details and Shiny Color.
Featured
Updated May 16, 2011 by zwetan

Here a small tutorial from start to finnish
to get you started writing code for redtamarin in

  • Flex Builder 3.0
  • Flash Builder 4.0
  • Flash Builder 4.5

Introduction

You still need to do the default Getting Started tasks



Define a workspace

Because redtamarin is not your default Flex Builder project,
I would advise you to create an Eclipse workspace dedicated to redtamarin development.

Each Eclipse workspace have a .metadata folder containing various settings,
here with one of the tools we have built, we gonna inject a bunch of external tools into this folder.

Here what we have by default

run EclipseExternalTools

$ ./EclipseExternalTools /work/Demos/redtamarin

if you go into the folder .metadata/.plugins/org.eclipse.debug.core/.launches/
you will see that list of scripts we just added

Now, close Flex Builder and restart it.



Edit our tools first

Let's open the external tools

On the top left, you should see our list of tools

Now, open the external tools favorite
and add all the tools (eg. click "Organize favorites...")

Select the order that you prefer with "move up", "move down", etc.

And now, let's see our tools

Here a summary of those tools

tool description alternative to
ASC_compile compile an *.as file with ASC Flex Builder MXMLC compiler
redshell_debug run an *.abc file with redshell_d Debug button
redshell_run run an *.abc file with redshell Run button
make_projector take an *.abc or *.swf file and create an executable n/a
dump_api take an *.abc or *.swf file and dump the API n/a
dump_infos take an *.abc or *.swf file and dump the infos n/a
extract_abc take a *.swf file and dump all the *.abc files n/a



Our first project

Create an ActionScript project

and name it "test"

edit the Library path and remove any default SWC reference

by default you will get this error

that's normal, under redtamarin there is no Sprite class (well.. not yet, another tutorial for that).

So, to deactivate this error, and a bunch of other errors, you need to edit your project properties

in the Builders section on the left, deselect "Flex", and confirm by clicking "OK"

As it is, you disabled some Flex Builder options and settings, but nothing can work yet.

You need to create two directories in your project

You should obtain this directory structure

Edit again your project properties

And in Library path add the lib-swc folder

In details that gives

Now, clean up the default code that Flex Builder created in test.as to start from fresh

I know, it sucks to do all those settings by hand, I'll try to come up with a way to automate that.

Voila, you're ready to write your first redtamarin program :).



Our first program

Because our tools run on the command line, it is also a good idea to display the console window

Let's write some code!

yes, you're not dreaming

there is full syntax completion support
like a normal Flash/Flex project

Now, let's compile the program!
be sure to have test.as selected
then click on the ASC_compile tool

and here the result

the console tell us that we create a 116 bytes file,
and you can see also on the left panel a new file: test.abc.

Now, let's run the code!
be sure to select test.abc on the left panel

then click on the redshell_run tool

and see the console output in all its glory

the username result should off course reflect the username defined on your system =).

That is very basic and I hope simple, but that's how you work with redtamarin:

  • you compile one or more *.as file(s) to an *.abc file
  • you run one or more *.abc file(s) with the redshell

More stuff you should know

Let's edit our code in a way that it will generate a runtime error

Run the abc file with redshell_run

here the result

Error #1500 as it is not very helpful ...

Let's run the abc file with redshell_debug

here the result

Error: Error #1500: Error occurred opening file hello.txt
        at avmplus:;FileSystem$/read()
        at global$init()

much more useful, and that's why there is also a debug release of redshell as redshell_d
that's the only version that give you error details.

Now, let's be crazy and write a class.

And let's make an obvious syntax error and see what happen

yes, the compiler will tell you something is wrong and in red so you really can not miss it.

So we spent few minutes writing a class, let's see a big screenshot

the same stuff as writing code for Flash

  • you get the layout of the class on the left panel
  • you get syntax colorisation
  • you get syntax completion

the different stuff

  • you can declare more than one definition per file
    if you wanted you could declare 3/4 classes or more in the same file
  • your file name does not have to be same name as the class
  • your main class will not automatically run by itself, you have to explicitly run it
    see under //main entry point
  • trace() will output wether you use the release or debug version of redshell

Now for a special thing related to Eclipse and command line,
Eclipse console seems to not support an interactive mode,
so if you use a blocking function the console will get stuck.

For those case, you will have to run your program in a "real" console or terminal

But, depending on your coding style or what you program, putting it all in one file may not work for you,
so let's see another way, we keep the main entry point in test.as but externalise the class Robot to its own Robot.as file

Like good old AS1 you use includes, and usually include everything from your main file.

But let's see what happen when we compile

Yes, including a file does not necessary import it, you have to use import

Now, let's turn this simple program in an executable,
select the abc file and click make_projector

here the result

It created a test2 executable, yes it should be named test,
but because we already have a directory named test
the program createprojector altered the name to test2.

And voila, a standalone executable containing both redshell and test.abc is generated


Sign in to add a comment
Powered by Google Project Hosting