Category 'Tutorials'
For completeness, in relation to Painting Flash CS3: effects with matrices Matrix I want to emphasize that the Matrix are not necessary for the behavior indicated in the previous post. In fact we see in the example below:
The code is slightly different from the previous one, is as follows:
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| / * Actionscript 2.0 code ** * / . MouseEvent ; import flash.events. MouseEvent ; . Matrix ; import flash.geom. Matrix ; / / Flag to detect the mousedown Boolean = false ; md var: Boolean = false; / / Create a chalkboard front Sprite = new Sprite ( ) ; var lvg1: Sprite = new Sprite (); . lineStyle ( 0 , 0xffffff ) ; lvg1. graphics. lineStyle (0, 0xffffff); . beginFill ( 0x666666 ) ; lvg1. graphics. beginFill (0x666666); . drawRect ( 0 , 0 , 199 , 199 ) ; lvg1. graphics. drawRect (0, 0, 199, 199); . endFill ( ) ; lvg1. graphics. endFill (); lvg1 ) ; addChild (lvg1); = lvg1 . y = 30 ; lvg1. x = lvg1. y = 30; / / Create the blackboard tilted Sprite = new Sprite ( ) ; var lvg2: Sprite = new Sprite (); . lineStyle ( 0 , 0xffffff ) ; lvg2. graphics. lineStyle (0, 0xffffff); . beginFill ( 0x666666 ) ; lvg2. graphics. beginFill (0x666666); . drawRect ( 0 , 0 , 199 , 199 ) ; lvg2. graphics. drawRect (0, 0, 199, 199); . endFill ( ) ; lvg2. graphics. endFill (); = 400 ; lvg2. x = 400; = lvg1 . y ; lvg2. y = lvg1. y; = 45 ; lvg2. rotation = 45; = lvg2 . scaleY = . 6 ; lvg2. scaleX = lvg2. scaleY =. 6; lvg2 ) ; addChild (lvg2); / / / / Paint event ( MouseEvent . MOUSE_DOWN , _onMouseDown ) ; lvg1. addEventListener ( MouseEvent . MOUSE_DOWN, _onMouseDown); ( MouseEvent . MOUSE_MOVE , _onMouseMove ) ; lvg1. addEventListener ( MouseEvent . MOUSE_MOVE, _onMouseMove); ( MouseEvent . MOUSE_UP , _onMouseUp ) ; lvg1. addEventListener ( MouseEvent . MOUSE_UP, _onMouseUp); / / e : MouseEvent ) : void { _onMouseDown function (e: MouseEvent ): void { "_onMouseDown" ) ; trace ("_onMouseDown"); : uint = 0xffffff ; var c: uint = 0xffffff; . graphics . lineStyle ( 10 , c , 1 ) ; and. target. graphics. lineStyle (10, c, 1); . lineStyle ( 10 , c , 1 ) ; lvg2. graphics. lineStyle (10, c, 1); . graphics . moveTo ( e . localX , e . localY ) ; and. target. graphics. moveTo (and. localX, and. localY); . moveTo ( e . localX , e . localY ) ; lvg2. graphics. moveTo (and. localX, and. localY); md = true; } / / e : MouseEvent ) : void { md = false ; } _onMouseUp function (e: MouseEvent ): void {md = false;} / / e : MouseEvent ) : void { _onMouseMove function (e: MouseEvent ): void { "_onMouseMove" ) ; trace ("_onMouseMove"); md ) { if (md) { . graphics . lineTo ( e . localX , e . localY ) ; and. target. graphics. lineTo (and. localX, and. localY); . lineTo ( e . localX , e . localY ) ; lvg2. graphics. lineTo (and. localX, and. localY); } } |
In this case the rows from 22 to 25 show that even with simple rotation and displacements the effect repeats itself.
More ...
Playing around with the powerful and versatile object Matrix (matrix), linked to the transformations, you can do weird things. These tools are used to apply particular transformations to a visual object, such as a Sprite. You can, for example, scale, rotate, or twist (skew) a Sprite. e rotation ), per l'effetto Skew bisogna ricorrere direttamente alle matrici. While the first two functions (scale and rotation) Sprite objects (and others) provide directly the properties ( scaleX / scaleY , and rotation ), the skew effect should appeal directly to the matrices. What I would like to emphasize here is that when we modify a graphic object all its internal coordinates are shifted:
More ...

Today I'm in the mood for graphics tips! We shall see, step by step, how to make a key (a keyboard) with photorealistic Photoshop.
More ...
Google has APIs - in Javascript - to put its maps into any web site . Viediamo how to accomplish the same thing with Flash!
We start from a free component, UMAP (Universal ActionScript 3.0 Mapping API - Integrated with Google Maps), developed by AFComponents , a vertically organized companies of components for Flash / Flex really interesting and affordable. On the site, where you must register to take advantage of free downloads, there are also versions of UMAP for ActionScript 2.0: MAP G Ver.2.6.1 . In this case we will analyze the version 0.4 beta of UMAP for ActionScript 3.0 (inside the package there is also a Flex component). That we're going to see is - obviously - a beta version and is missing, then, some features present in the version for Actionscript 2.0 ( G Ver.2.6.1 MAP ). However, property run impeccably to the future, it seems more interesting to focus attention on this release, I tried them both and, despite the greater completeness of the release for Actionscript 2.0, Actionscript 3.0 beta version is considerably more powerful.
More ...
Those who are lucky like me to own the new Adobe Photoshop CS3 - Extended version - it will "grogiolato" to see all the news of this new release. Among the many new features in version 10.0.1 Two in particular struck me for their extremely useful. The first is the instrument dials:

This allows, for example, of "contour" an object so simple and effective. Once selected, simply click on the image that we want to capture him and do the rest. It is possible, during this process, remove any selections that do not satisfy us, usually with the Alt key (on Windows - what used to elimnare share with the other selection tool). Furthermore, in the top toolbar, you can adjust the amplitude of the "brush" of selection, until arriving to operate pixel by pixel.
This feature is coupled perfectly with the second new feature found in Adobe Photoshop CS3 : improves board, accessible from the Select menu (Alt + Ctrl + R).

Given a selection, this tool allows you to run a series of operations really useful and interesting, with a real-time preview adjustable form by any images that you see at the bottom of the window above. Addition to being useful to enhance the edges during the operations of contour and selection, allows also to perform reworkings of simple images, like the one shown below:

From the rough and "square" image of the left, by using Refine Edge has arrived in a flash to the right figure.
View Video
More ...
Finally with ActionScript 3.0 no longer have two different management of events as they did before ActionScript 2.0 (see: Event management: similarities between Flash and Javascript ). The method addEventListener() , ubiquitous in the new architecture allows to manage new and exceptionally clean all possible events, even personal ones. The new organization in the package allows you to import the events that we serve and treat everyone equally:
More ...
Flash CS3 has so many innovations, including the "odd" to specify at compile some tips on writing code. This happens, for example, when we have to do with the 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 that's ActionScript 3.0, when completing the movie, I felt (Warning) - or recommended:
Warning: 3551: Appending text to a TextField using + = is many times slower than using the method TextField.appendText ().
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. Adds 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 quantity of content significant.
We trust? To verify security:
1 2 3 4 5 6 7 8 9
| . getTimer ; import flash.utils. 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 us try as advised by the compiler:
1 2 3 4 5 6 7 8 9
| . getTimer ; import flash.utils. 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 great ... but it's true! ). The method appendText() is faster and more powerful pre-incremental operator ( += ). Why? The most obvious reason is the following: the operator ( += ) works on any type of data. Besides, in an OO language this operator is not structured as in C but is simply "oggettato". 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 "fix" to a string and thus does not do many "questions" in it. The operator ( += ), instead, must operate for any type of data and therefore is not optimized for the strings. In C, on the contrary, the operator ( += ) is a function at a low level and will always be faster than a call to a function.
More ...
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 a response XML. First of all, the object XML does not exist anymore! In ActionScript 3.0 new classes were introduced, some of which are dedicated to "backward compatibility".
Note: The XML class (along with related classes) from ActionScript 2.0 have been renamed XMLDocument and moved to the package flash.xml. 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 resolved by exploiting 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:
More ...
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 ; private var _maxy: 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 ) ; _y + = _getRndRange (1, 5); _getRndRange ( - 50 , 50 ) ) > 0 ) ? 1 : - 1 ; _x + = ((_getRndRange (- 50, 50))> 0)? 1: - 1; 1 , 5 ) ; _rotation + = _getRndRange (1, 5); _y > _maxy ) { if (_y> _maxy) { _interval ) ; clearInterval (_interval); } ; updateAfterEvent (); } } |
The method _move() contains the intelligence of the staple, ie the function of fall, extremely simple. By varying the function random _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, ie the flakes fall with a particular slope. In particular you can send the flakes to right and left using a code of this type:
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); ), then, confers a further detail to the same staple.
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 and a randomico stairs, to have snowflakes of different sizes.
1 2 3 4 5 6 7 8 9 10 11 12
| / / Create staple creaFiocco function () { 20 , 100 ) ; var s = randRange (20, 100); = randRange ( - Math . floor ( ( Stage . width - 320 ) / 2 ) , Math . round ( ( Stage . width + 320 ) / 2 ) ) ; var x = randRange (- 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 ... Best wishes to all and Happy Holidays ... 
More ...
As disability is a TextField for input? Since the property enabled is not available you can use a simple artifice: change runtime state of the TextField. Fortunately, Flash developers have permission 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 "static" text. In reality, it will transform 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 entered some text in a TextField input when turned it into a dynamic TextField will only get the impression of not being able to insert characters! That I disabled 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. type = v? "input": "dynamic"; }; |
More ...
Latest Comments
Mark : Thank you very much, I've lit
I solved it by setting [cc_objc] / / OptionViewController.m - ...
Giovambattista Fazioli : @ Mark: I suggest you think a more correct approach. If you run the subclass of the tab ...
Mark : Excuse the spam .. I noticed that there is an error .. here is the correction [cc_objc] / PrimaClasse.h ** ** / # import ...
Marco : forgotten .. in [cci] OptionViewController [/ cci] for [cci] @ syntetize [/ cci] I put the delegate
louis : very clear and simple I have to admit that writing a pa hardly use delegates created by ...