Who has started to develop code with scripting languages such as JavaScript or ActionScript the same, may not know all the concept of data type. With some high-level languages, in fact, it used to - at best - to declare variables without giving a specific data type, not counting those languages that do not require any statement (such as PHP - not in the strict version 5 ).
Articles Tagged 'Const'
Actionscript 3.0 for beginners: lesson # 5
Actionscript 3.0 for beginners: lesson # 4
Recall the example of our code of TicTacToe (found in full on Google Code ) and begin to analyze it in detail.
Import definitions
With Actionscript 3.0 has done a great job of cleaning and accommodation nell'alberatura classes (contained in the packages, package ) used during development. In other programming languages, like C for example, when you want to use a feature must explicitly "import" in the code. This operation of "import" is necessary to allow the compiler to have all the codes and definitions related to the features we want to use. ; Actionscript 3.0 mette a disposizione l'istruzione include che è identica all' #include del C/C++. In ActionScript 3.0, however, education import should not be confused with the equivalent C / C + + #include , Actionscript 3.0 provides education include that is identical to ' #include in C / C + +. The latter, in fact, "include" the actual code that, if used or not, the final executable is compiled. The statement import is the highest level and is more "intelligent" at compile time. It is used primarily for access classes without specifying their full name. In alre words instead of using forms such as:
1 |
Constants and variables: what is the real difference?
It seems obvious, but some escape the subtle difference between constants and variables in a programming language. The constants, from the name, do not change their value during the cycle of a program, while variables can do it! Often, however, happen to use variables instead of constants without realizing it, also because this does not impact the logic of an application. Despite this, the difference between constants and variables, and there emerges all at compile time, where the constant plays a role certainly more powerful.
Coming from C or Assembly programming knows the difference between constants and variables, especially because, in both assembly and C, constants play a role by MACRO. For MACRO meant in a "piece of code" that is labeled and replaced in the code at compile time. The compiler, in short, performs a kind of find .. replace (and is sostituitsci) in the code each time it encounters a constant.
Imagine you write in C, the following simple piece of code:
1 2 3 4 | 5 ; int a = 5; 3 ; int b = 3; int c; b ; c = a + b; |
sono indicate come variabili in questo caso. Whether a which b are shown as variables in this case. In C, in fact, the constants are defined with the keyword #define . sono state definite come int . We note immediately that a which b has been defined as int . Already here you can make a first optimization. If we know that our variable a never exceed a certain value, you should declare it properly and do not use data types at random. Some developers do not bother to declare the correct types, thinking that this does not affect the performace! Wrong! Alternatively, it is acceptable that the first draft of the code does not involve this level of detail. However, it is a good rule, during the development process, review the code and check the data types.
However, in an assembly of the Motorola family, for example, like the mythical 68000, would seize our code compiled (without optimizations) into a kind of:
1 2 3 4 | , d0 ; int a move. the # 5, d0; int , d1 ; int b move. the # 3, d1, int b d2 ; int c - foo move. the d1, d2, int c - foo l d0 , d2 ; risultato in d2 ovvero c add. the d0, d2, d2, or result in c |
or:
1 2 3 | , d0 ; int a move. the # 5, d0; int , d1 ; int b move. the # 3, d1, int b d1 ; risultato in d1... move. l d0, d1, d1 result ... |
The compiler, however clever, effort in optimizations, then write the code with the right keyword can only help to improve the compiled output. In our case, if the value 5 is a constant is not convenient to use an integer variable, because the compiler, and rightly so, considering the variable variable, in fact, an entire predisponde easy to contain the value 5, which in binary is 101, ie occupies three single bits (if anything, int is a 32bit or 53bit worst a double-precision floating point!). If we had written the code like this:
1 2 3 4 5 | 5 # define MIA_COSTANTE 3 ; int b = 3; int c; b ; c = b + MIA_COSTANTE; |
The compiler would know from the outset that MIA_COSTANTE , being constant, the value will not change so I can reserve less space to treat it. In practice the Assembly code diverebbe:
1 2 3 | d0 ; la "q" indica una istruzione "quick", cioè che tratta valori compresi tra -128 e +127 moveq # 3, d0; the "q" indicates a statement "quick", that is values between -128 and +127 , A statement "quick" takes less CPU time (4 clock cycles in this case) d0 ; anche qui uso una istruzione "quick" addq # 5, d0; here an instruction manual "quick" |
This code is very fast and takes up less bytes. What we must keep in mind is that when you declare a variable environment prepares to treat it as such, even if today's compilers can do miracles, performing a series of steps in the code before compiling (some compilers, even perform a kind of simulation program to optimize the compilation into machine code).
A good rule, therefore, is to declare the right kind for our variables, though these are. Alternatively use the constants, especially if the programming language we are using the expected (as in the case of the new Flash CS3).
10 reasons to upgrade to Adobe Flash CS3
For some developers just need to know that there is a new version of their preferred development package to run and buy the upgrade. Others, quite rightly, more calm and maintain a "pretend" to know the actual improvement in the new version before you change your habits. In the case of Adobe Flash CS3 is not much to wait, given the many changes that the package has undergone since Macromedia was acquired by Adobe.
Here, then, 10 simple, but important, reasons which, in my personal opinion, enough to convince you to upgrade to Adobe Flash CS3 . I will focus, of course, only on the things that struck me personally, this is not intended as an exhaustive list of all the many innovations introduced by the CS3 suite, only a fly to anticipate some features of CS3.
1. Installation
The installation is nice and fast, compared to previous versions. It includes, among other things, with all Adobe products (Dreamweaver CS3, Photoshop CS3 Extended, etc ...) which makes the installation / removal, and update a real pleasure.
2. Backward Compatibility
One issue often overlooked, but always taken into account in the history of Flash: The ability to manage previous versions of the product. In Flash CS3 has all the tools to manipulate it is to migrate the previous versions of our movies. We find this possibility in debugging (debugging a separate Actionscript 2.0 and Actionscript 3.0) is in the process of completing the movie. Write now Actionscript 3.0 Flash applications could be counterproductive in certain contexts. If your target site has a high traffic you may find that many users have not yet installed the latest versions of Flash Player for your browser and then would not see the movie. However, as noted above, Flash CS3 allows you to develop Flash applications mantendedo backward compatibility and therefore I do not see this as a big ostocalo nell'upgrade product.
3. GUI and IDE

The IDE Flash CS3 (like Dreamweaver CS3) has been revised to better. The panels (see picture left), often uncomfortable in previous versions, have been completely redesigned and now their use is much less invasive.
In addition, the ability to minimize panels (see figure at right) is found that makes a real attractive and functional interface. When a panel is in icon mode takes up much less space and with a simple click you can open the first main panel always visible.
All the IDE, in short, has been revised including the central area with the window for editing and graphic code. Do not you point out all the changes or you'll ruin the surprise ...







Latest Comments
Simon : It annoys disturbed again and use that space for these things ... however it does not work ...
Giovambattista Fazioli : @ Simon: what could be due to the syntax I used, specifically for PHP 5 +,...
Simon : I tried last night putting everything into functions.php, okay, jquery forms, and tabs jQueryUI them ...
Giovambattista Fazioli : @ Simon: I recommend cleaning to enter a code like that in ...
Simon : @ Giovambattista Fazioli: Thank you for your patience, it's all clear ... now I feel now, ...