Premise
Actionscript 3.0 can be a good starting point to become familiar, those unfamiliar with C programming and / or C + +, orioentata programming (OOP). In addition, this series of lessons will be useful to those coming from other rooms or from earlier versions of Flash.
Set a project
In this first lesson we will see how to set up a project Flash CS3 generic. It is good to use when the projects are expected to have to deal with at least more than one file. The use of the project was introduced - by Macromedia - already in versions prior to CS3, so it should be a subject known to developers Actionscript 2.0.
However with Actionscript 3.0 - as we shall see - it is possible to create a Actionscript (. Pbuh) to the document-root movie ours. Fla so to speak. This feature is very useful and also makes a project minimum of at least two files: the. Fla. As associated. For this reason, you will "always" from a project, so right now organizing the various files (. Fla,. As, ...) that will be part of our "package" of development.
Also, once you learn the dimesticazza with the philosophy to objects, instrinseca in this type of language, end up with many files will be normal, even for simple projects substantially.
A project is a Flash virtual container (the. Flp files are XML-formatted text with a list of files to load) that brings together, in an organized manner, all the files of our project.
1 2 3 | version = "1" > name = <flash_project "mioprogetto" "1" version => filetype = "fla" profile = "" def_file = "true" /> path = filetype = <project_file "./mioprogetto.fla" "fla" profile = = "" def_file "true" /> </ Flash_project> |
It would be perfectly possible to manage multiple files individually, but a Flash project proposes a series of characteristics that make certain tasks easier and more automated, such as compiling and saving all the files that make up the project.
Note: If you have installed a full suite, then with Dreamweaver or Adobe Version Cue projects you get through a whole series of features not otherwise available, such as direct links to sites created by Dreamweaver - with all the settings for FTP - or the versioning.
Before you actually create the project is well placed at suitable to prepare the file system or folders that contain your files. Normally you create a folder of our project and, in the simplest case (what we will see in this first lesson) that is enough!
The creation of a project takes from menu File-> New or the welcome page:

You will be prompted to save a file, for example mioprogetto.flp . Save this file in the folder you have previously prepared.

At this point we can add the movie, again from the menu File-> New:

Save this file (. Fla) with a name, for example mioprogetto.fla . At this point, again, the project is not aware of our movie file. From the Project panel, select the icon
"Add File to Project" and select our mioprogetto.fla :


A Flash project can add any number of files. As and. Fla. Some projects, in fact, consist of multiple files "movie" (. Fla), run by a loaded movie. For this reason you need to indicate which of the movie file in the project, is the default, that is what will be done in design-time selection to the item "Try FILAME".
Note: If the project is a Flash movie could only select it as the "default" automatic features ... but this has escaped, for now, Adobe developers.
We select our movie and then select from the context menu (shown) "Set as default document."

The icon of the movie will change, indicating that this is the main movie.

We open now the main movie, in finstra properties, below, we will notice the first difference from the previous versions of Flash: Class document.

The document class is not required to make our movie. As happened "long ago", you could place the code directly into the first frame of the movie itself. However, using the document class, makes our project very lighter, releasing the code from the movie itself. The document class is in fact a real file. As outside. In this way we can reuse this class for other movies without having to "copy and paste" code from frame to frame.
To add a Class suffciente document and select the menu File-> New:

Insert the following code / template:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | package { / ** * Document for Class myproject * * * @ Class MyProject * @ Author Giovambattista Fazioli * @ @ Email g.fazioli undolog.com * @ Web http://www.undolog.com * @ Version 1.0 * * / .*; import flash.display .*; .*; import flash.events .*; / / MioProgetto extends MovieClip { public class MyProject extends MovieClip { / ** * Class constructor * / MioProgetto ( ) : void { public function MyProject (): void { / / Todo } } } |
Save as "MioProgetto.as" and add this file to the project:

In the text field "Document Class" properties movie we've seen before insert "MyProject"

Click on the icon
If everything is correct in the editor will open our document class.
Document class
We can see our project on the button "Test Project" panel projects:

Insert in the constructor of the class document, the following code:
1 2 3 4 5 6 | / ** * Class constructor * / MioProgetto ( ) : void { public function MyProject (): void { 'Avvio progetto' ) ; trace ('Start Project'); } |
This will be the code on the start of our movie, the - well - that "time" was inserted in the first frame! This means that any instance of the MovieClip TextFiled or component included in the movie, will be visible to this class. In the next lesson will achieve the classic game of Tic Tac Toe (also quoted in honor WarGames ) in detail so as to see more features of the Document Class.











[...] Actionscript 3.0 for beginners: lesson # 1, we see the necessary steps for creating a project in Flash CS3. So I came up [...]
[...] As promised here is the second lesson in ActionScript 3.0! Today we start the analysis of a simple project that reproduces the play or the Tic Tac Toe Tic Tac Toe. I tried to include some special features in this example, ActionScript 3.0, trying to give space to the understanding and not on style. It follows that if I had to write the "game" really, I probably would have structured very differently, but in this case I tried to mediate between a classical program with a compact, hermetic more understandable for newbies. I created a single document class, the procedure is not necessary but useful to keep in line with the previous lesson. [...]
Hello Giovambattista, it seems a very interesting tutorial, but you have not even begun the last phase of project start-up where I insert it again in mioprogetto.as? adding to what was written above? I'd like to understand how to make a website in as3 with buttons and pages and nothing else I hope you can help me thanks a lot
@ Oibaf: I do not understand the first part of your comment.
Hello. Congratulations for the nice tutorial. However I had a question, but the second script of the first lesson should be placed exactly where ?!?!?!? thank
@ Dosa85:
The second script is a portion of the first, as an example. Corresponds to the constructor.
The "error: 1013: The private attribute may be used only on class property definitions.
@ Dosa85:
This error can be caused by various factors. Are you sure you followed everything correctly? If the ZIP send me by email of what you did, so we see why it does not work.
Thanks so much for this tutorial!
This page does not seem to be very popular, judging from the date of the last comment, in any case I hope someone can help me abbbia triggered the notification e-mail ...
first of all thanks for the tutorial, it is very clear + many more ... I'm missing only the meaning of this phrase at the end:
= new Sound ( ) ; in questo caso è un istanza della classe
Sound, e il suo nome èmySound, giusto? If I understand it is an instance like this:var mySound : Sound = new Sound ( ) ;in this case is an instance of theSound, and his name ismySound, right?Another thing: I have movieclip movies, that is the "symbol" with the code and an internal timeline, right? (I have CS4 in English, unfortunately) ... then oh well, will be the text field text box, but ... Component? What would be a component?
last thing: what you mean by "will be visible to this class"?
@ Ricvail: Hello, I answer for points.
1) originally did not support Flash files (external). As. All of the code - or pseudo code - was inserted as a "script" within the frame. The first version of Actionscript (scripting actions), then, were very far from a real programming language. The instructions are limited essentially to control the forward and backward frames. As it has evolved to reach the current state where, however, still remained the possibility of using Flash to the "old way".
INTED What, then, was that the use of the document class, such as I have presented in this tutorial, solves what once was done within the frame.
The evolution of Flash allowed to use it as a real development environment for advanced applications. Who is developing complex applications, but also those who appreciate the features, uses in fact the technique I described, and no longer writes the code inside the "frame".
2) Yes! In object-oriented programming (OO) class is denoted by the "declaration" of an object. An object, however, as long as there is not created or, as they say, instantiated. , si dice che l'oggetto esiste ed è ti tipo
Sound. When you create an object, using the operatornew, and ask in a variable, asmySound, it is said that the object exists and you typeSound., etc… questi fanno parte dello strato più basso di tutto il sistema. 3) Flash provides visual primitive objects such as those you mentioned:
MovieClip,TextField, etc. ... these are part of the lowest layer of the whole system. Components are objects, not necessarily visual, higher level, often formed by the sum of more primitive objects. For example you could create a component with the appearance of a form inviomail, then made a series of label (name, surname, etc ...), a series of TextField and a "Send" button.In principle, a component is similar to a
MovieClip, even if it needs to be written and compiled in a certain way (and exported) as a component. The advantage of the component (as for MovieClip) is to easily reuse them several times.4) With "will be visible to this class," I mean that a method within the class
MioProgettocan direct a visual object (such as a MovieClip or TextField) located in the main movie. For example, if you create a MovieClip and ask him in the movie, giving it an instance name "foo", within the classMioProgettoyou - for example - manipulate "foo", moving, enlarging, associate events, etc. ... as if I had created by code.If we can be of further help I suggest you:
I hope I was clear enough. If in doubt do not hesitate to rewrite.