Articles Tagged 'Development'
Flash CS3 has very many innovations, including the "curious" to indicate at the time of compiling some tips on writing code. This happens, for example, when we are dealing with objects TextField . I've had to add a string to the end of a field TextField with the classical notation:
1
| + = "Stringa aggiunta" ; mioTextField_txt. text + = "string adding"; |
But here is that ActionScript 3.0, when completing the movie, I felt (Warning) - or recommended:
Warning: 3551: Adding text to a TextField using + = is many times slower than using the TextField.appendText () method.
Cool! Let's see the fact of the method SYNOPSIS appendText() actually says:
) applicata a una proprietà text (ad esempio <strong>someTextField.text += moreText</strong> ), in particolare nel caso di un campo di testo con una quantità di contenuto significativa. Appends the string specified by newText at the end of the text field. This method is more efficient than an addition assignment ( += ) properties applied to a text (eg <strong>someTextField.text += moreText</strong> ), in particular in the case of a text field with a significant amount of content.
We trust? To verify security:
1 2 3 4 5 6 7 8 9
| . getTimer ; flash.utils imports. getTimer; uint = 0 ; var i: uint = 0; int = getTimer ( ) ; var s: int = getTimer (); i ; i < 10000 ; i ++ ) { for (i, i <10000; i + +) { + = "Ciao" ; text_txt. + text = "Hello"; } int = getTimer ( ) ; var f: int = getTimer (); f - s ) ; trace (f - s); |
Time: 9360 - on my machine in debug mode. Let's try as advised by the compiler:
1 2 3 4 5 6 7 8 9
| . getTimer ; flash.utils imports. getTimer; uint = 0 ; var i: uint = 0; int = getTimer ( ) ; var s: int = getTimer (); i ; i < 10000 ; i ++ ) { for (i, i <10000; i + +) { ( "Ciao" ) ; text_txt. appendText ("Hello"); } int = getTimer ( ) ; var f: int = getTimer (); f - s ) ; trace (f - s); |
Time: 8415 
Nothing fancy ... but it's true! ). The method appendText() is faster and more powerful pre-incremental operator ( += ). Why? The most obvious reason is as follows: the operator ( += ) works on any type of data. Moreover, in an OO language this operator is not structured as in C but is simply an "object". In C + +, for example, you can overwrite (override) the operator as part of the structure of the object language itself. Ultimately appendText() is faster because its goal is to "hang" a string and thus does not do many "questions" in it. The operator ( += ), however, should work for any type of data and therefore is not optimized for strings. In C, on the contrary, the operator ( += ) is a function of low-level and will always be faster than a call to a function.
Continued ...
ActionScript 3.0 introduces a number of formidable tools of communication, some totally new, some revised and improved from previous versions of ActionScript. We begin to see how it changes the way you interact with a Web Server in the case of a simple communication between Flash and a PHP page with the XML response. First of all, the object XML does not exist anymore! ActionScript 3.0 introduced new classes have been, some of which are dedicated to the "backward compatibility".
Note: The XML class (along with related classes) from ActionScript 2.0 have been renamed XMLDocument and moved to the flash.xml package. It is included in ActionScript 3.0 to ensure compatibility with previous versions.
usando il metodo sendAndLoad() dell'oggetto LoadVars (vedi: Flash: LoadVars e XML per inviare dati in POST ). In ActionScript 2.0 communication with a Web Server was often solved by using the combination of objects LoadVars and XML, using the method sendAndLoad() object LoadVars (see: Flash: LoadVars and XML to send data in POST ). Now things are changing, but you just get used to new names and objects. As indicated in the manual, in fact:
Continued ...
Because of its ability to communicate with the server, the XMLHttpRequest object (XHR), used in the technology Ajax (an acronym for Asynchronous JavaScript and XML, which should be pronounced "egiacs" although we prefer Italian "aiacs"), has a security lock that prevents you from running applications outside the domain in which it operates. This protection is necessary to prevent JavaScript Injection (techniques of "injection" extremely dangerous code in order to break the system) of various kinds, with the ultimate objective of "break" in the system.
This limit is now taken seriously and you're thinking, somehow, to solve it - directly into the XmlHttpRequest - without compromising security (see also: Third Proposal for cross-site extensions to XMLHttpRequest ).
Whatever the situation today is as follows:
Continued ...
The site Adobe.it is renewed, it is of erasing the hybrid Adobe-Macromedia made immediately after the acquisition of software company of Flash! Pagination original file (the stop on the left), use of DHTML and Flash, of course.
All sections have been redesigned with an original use of the background. From rinavigare absolutely !
Continued ...
Some readers have asked me how it was created the snowflake, so realistic, the Widget Christmas . Those who have downloaded the source you probably already know ... but it was really simple. First, I selected the Brush Tool in Flash and I drew a point.
I turned this into a symbol and I applied two effects in the right sequence: bevel and blur:
The result was: 
At this MovieClip (symbol) associated with a simple class I CNeve , which actually creates the intelligence of the staple itself:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| MovieClip { Cneve class extends MovieClip { _interval ; private var _interval; _maxy : Number ; _maxy private var: Number ; / / Cneve function () { this , "_move" , 25 ) ; _interval = setInterval (this, "_move", 25); round ( ( Stage . height + 256 ) / 2 ) + _getRndRange ( - 20 , - 7 ) ; _maxy = Math . round (( Stage . height + 256) / 2) + _getRndRange (- 20, - 7); } / / _getRndRange ( min : Number , max : Number ) : Number { private function _getRndRange (min: Number , max: Number ): Number { Number = Math . floor ( Math . random ( ) * ( max - min + 1 ) ) + min ; var randomNum: Number = Math . floor ( Math . random () * (max - min + 1)) + min; randomNum return; } / / _move ( ) { _move private function () { 1 , 5 ) ; _getRndRange _y + = (1, 5); _getRndRange ( - 50 , 50 ) ) > 0 ) ? 1 : - 1 ; _x + = ((_getRndRange (- 50, 50))> 0)? 1: - 1; 1 , 5 ) ; _getRndRange _rotation + = (1, 5); _y > _maxy ) { if (_y> _maxy) { _interval ) ; clearInterval (_interval); } ; updateAfterEvent (); } } |
The method _move() contains the intelligence of the staple, which is the function of a fall, extremely simple. By varying the random function _x += ((_getRndRange(-50, 50))>0) ? 1 : -1;, si può aggiungere un effetto effetto vento, cioè i fiocchi cadono con una pendenza particolare. _x += ((_getRndRange(-50, 50))>0) ? 1 : -1;, for example by inserting a _getRndRange(-550, 50), you can add an effect wind effect, that the flakes fall with a particular slope. In particular, the flakes can be sent to the right and left using a code like this:
1
| _getRndRange ( _getRndRange ( - 350 , - 50 ) , _getRndRange ( 50 , 350 ) ) ) > 0 ) ? 1 : - 1 ; _x + = ((_getRndRange (_getRndRange (- 350, - 50), _getRndRange (50, 350)))> 0)? 1: - 1; |
The rotation ( _rotation += _getRndRange(1, 5); ), this gives a further detail to the bow itself.
e uno scale randomico, per avere fiocchi di neve di diverse dimensioni. When I create a bow (see function creaFiocco() below) I also added an alpha=90 stairs and a random, to have snowflakes of different sizes.
1 2 3 4 5 6 7 8 9 10 11 12
| / / Create staple creaFiocco function () { 20 , 100 ) ; randRange var s = (20, 100); = randRange ( - Math . floor ( ( Stage . width - 320 ) / 2 ) , Math . round ( ( Stage . width + 320 ) / 2 ) ) ; randRange var x = (- Math . floor (( Stage . width - 320) / 2), Math . round (( Stage . width + 320) / 2)); = - Math . floor ( ( ( Stage . height - 256 ) / 2 ) ) - 10 ; var = y - Math . floor ((( Stage . height - 256) / 2)) - 10; "neve" , "neve_" + index , index , { _x : x , _y : y , _xscale : s , _yscale : s , _alpha : 90 } ) ; c_mc. attachMovie ("snow", "neve_" + index, index, {_x: x, _y: y, _xscale: s, _yscale: s, _alpha: 90}); index + +; index > 1000 ) { if (index> 1000) { ; index = 1; , 2 ) ; c_mc = createEmptyMovieClip ("c_mc", 2); } } |
And that's all ...
I forgot ... Happy holidays and best wishes to all ... 
Continued ...
Today I propose an interesting variant of the "classic" analog clock in Flash. This version contains a transition tween start of the movie. I was inspired to Gadgets in Windows Vista that does, in fact, this beautiful effect at startup.
The code is written in Actionscript 2.0 and has been compiled with the new Adobe Flash CS3. This demonstrates that the new CS3 suite is fully compatible with previous versions of Flash, an extremely important point for those who have decided to consider the product update.
For the source click here .
Continued ...
Thanks to "spurred" by TV Revolution I made a small Christmas Widgets (see if we can improve it with your comments).
To use simply insert the following code on your site:
The parameter h determines the height in pixels of the movie. By default, this is shown in absolute position and width to 100%. To change this setting used abs=0 to place the snow inside the page, not above. Instead, use w=800 to set a personal dimension. For example:
Create snow 50 pixels, 640 pixels wide, and relative position, as shown below:
Continued ...
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).
Continued ...
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 ...

Continued ...
How can a disabled TextField input mode? Since the property enabled is not available you can use a simple artifice: change runtime state of the TextField. Fortunately, Flash developers are allowed to change the status of a TextField also run through the property type . It follows that if a TextField is added to the Stage as input (and hence type="input" ), by code, we can turn it into a text "static". In reality, the transform them into dynamic text ( type="dynamic" ) but the visual result is the same. The artifice works because both the TextField TextField input the dynamic properties share the same text . So if I put a text in a TextField input when it transformed into a dynamic TextField will have only the impression of not being able to insert characters! That I have disabled the TextField input!
The TextField object may also be extended as a MovieClip, then we may use the following code useful:
1 2 3
| prototype . Enabled = function ( v : Boolean ) { TextField . prototype. Enabled = function (v: Boolean ) { type = v ? "input" : "dynamic" ; this. v type =? "input": "dynamic"; }; |
Continued ...
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, ...