Category 'Flash CS3'
For completeness, in relation to Painting Flash CS3: Matrix effects with matrices I want to emphasize that the Matrix is not necessary for the behavior indicated in 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 ; flash.geom imports. Matrix ; / / Flag to detect the mousedown Boolean = false ; md var: Boolean = false; / / Create a blackboard 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. lvg1 x =. y = 30; / / Create the board 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, lines 22 through 25 show that even with simple rotation and displacement effect is repeated.
Continued ...
Playing around with the powerful and versatile object Matrix (matrix), linked to the changes, you can do bizarre things. These tools are used to apply special 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 (not just) make available directly to 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 moved:
Continued ...
Some, quite rightly, argue about the Adobe AIR, Adobe Integrated Runtime (formerly Apollo) offered by Adobe. What are we talking about? After all AIR is still a beta ( the latest release is 12/12/2007 - Beta 3 ) and its success, we'll see whether including or not depends on many factors.
Continued ...
I state it now: you do not win anything! Apart from pride - if anything - to have solved the problem.
QUEST - APPLICATION
How to create a tool to erase, delete, clear, a "portion" of the graphics API designed with Actionscript 3.0?
, espongono la proprietà graphics , un puntatore ad un altro oggetto che “serve” tutte le funzioni grafiche di disegno runtime. With Actionscript 3.0 Some visual objects, such as MovieClip or Shape , exhibit the property graphics , a pointer to another object that "serves" all graphic design runtime functions. For example, you can develop a simple drawing application. , in modo semplice e rapido. This object graphics can draw whatever you want, for example, an object of Shape , easily and quickly. The problem is that once something is drawn can clean out all but a single part.
Draw a line is easy:
1 2 3 4 5 6
| Shape = new Shape ( ) ; var myShape: Shape = new Shape (); myShape ) ; addChild (myShape); / / . lineStyle ( 2 , 0xff0000 , 1 ) ; myShape. graphics. lineStyle (2, 0xFF0000, 1); . moveTo ( 0 , 0 ) ; myShape. graphics. moveTo (0, 0); . lineTo ( 100 , 100 ) ; myShape. graphics. lineTo (100, 100); |
Drawn something you can clean everything with the simple call to clear() :
1
| . clear ( ) ; myShape. graphics. clear (); |
But if I want to "delete" only one point? Or coordinates from 50.50 to 100.100?
Searching the Internet I found several examples of "design applications" and, in fact, offers no support or tool "delete".
Do you have any solution?
Continued ...
. Again in the "uniform", as happened with the events (see the new event handling of Flash CS3 and Flash CS3: The new event management ), one of the many new features in ActionScript 3.0 is the disappearance of all those ad hoc methods dedicated to the creation of special items, such as: createEmptyMovieClip() or the famous attachMovie() . With Actionscript 3.0 the operator new is sufficient to perform all the operations building. A new MovieClip, for example, is created (runtime) with the following code:
But let's go! If I want a symbol in the library and add it as a runtime happens if attachMovie() is gone? The solution is not very dissimilar from what happened in Actionscript 2.0. First you need to go into the library, select the symbol and open the Properties window. At this point, check the Export for ActionScript box chaining - as they did in Flash 8. A symbol library as a base class has always flash.display.MovieClip , but this does not interest us much. The interesting thing, however, is the parameter class that is set by default (when you check Export for ActionScript) with the symbol name. What is important to emphasize is that this is a new mode of Flash CS3 (and ActionScript 3.0). The symbol to be exported must have a Class reference. The curiosity is that we are not necessarily forced to create our own class (extended from flash.display.MovieClip ), even if we could do it.
Continued ...
I had already spoken in Flash CS3: The new event handling . I'll be back on the issue sublists for the difference of this new approach compared to previous versions of ActionScript. Schematically we have a general situation of this type:

Any object that supports events, ultimately exposing itself the addEventListener (). In the documentation, among other things, we read:
What's new for event listeners in ActionScript 3.0
[...] To add event listeners in ActionScript 2.0 is sometimes uses addListener () and sometimes addEventListener (), whereas in ActionScript 3.0 using addEventListener () in all situations.
[..]
Event management, then, is standardized at the level of real listeners. All the "features" of listening, in fact, have the following structure:
1 2 3
| eventObject : EventType ) : void { eventResponse function (eventObject: EventType): void { / / The actions in response to the events are defined here. } |
o una sua sottoclasse. EvenType is always an object of class Event or a subclass. . This allows for more informations specific to the particular event in addition to handling standard properties such as target or currentTarget .
An important difference with previous versions of ActionScript, with respect to the listener, is that:
In ActionScript 2.0, event listeners can be either functions, methods or objects, whereas in ActionScript 3.0, event listeners can be only functions or methods.
In short, having used for some 'time to event structure from earlier versions of Flash, I must say that this new approach is really nice. It's a bit 'that development with Actionscript 3.0 and, after a small initial loss (just to regain what was taken for granted) now I can not understand how could I bear the "old" method of the events of the previous versions.
Continued ...
Google has APIs - Javascript - to put its maps in any web site . vied 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 need to 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 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 lacks, therefore, some features in version for Actionscript 2.0 ( G Ver.2.6.1 MAP ). However, watchman at the future, it seems more interesting to focus attention on this release, I tried both and, despite the release of more complete for Actionscript 2.0, Actionscript 3.0 beta version is considerably more powerful.
Continued ...
Santa Dear Adobe,
although it has already received two patches for Flash CS3 (version 9.0.2), some troubles in its use have appeared as all the software in the world, especially in this release that has undergone very many changes.
- The 'ActionScript editor, for example, is slow and jerky! Consider, dear Father Adobe, my car has 8Gbyte of RAM and an Intel quad core duo!
- During the automatic formatting, lines of code like this one below, are "misunderstood" and reformatted evil:
1
| ( MouseEvent . CLICK , function ( e ) { myfunc ( ) ; } ) ; mybtn. addEventListener ( MouseEvent . CLICK, function (e) {myfunc ();}); |
Adding braces where it should be:
1 2
| ( MouseEvent . CLICK , function ( e ) { myfunc ( ) ; } ) ; mybtn. addEventListener ( MouseEvent . CLICK, function (e) {myfunc ();}); // < -- chi te l'ha detto?! } / / <- Who told you?! |
So better use the syntax:
- The windows docket, at least in the implementation of Windows Vista, every now and then disappear under other panels ... The Help window, the guidance in short, creates a problem when you try a project. The latter, in fact, disappears behind the other panels ... mystery! However, this defect, like others, is not always reproducible.
- The components have strange behavior: sometimes are shown, in design-time, as white rectangles ... while continuing to operate at runtime!

- The 'anterprima scale9Grid, as indicated in the new documentation and be able to show the objects correctly resized at design-time, continues to be plagued by the same problems as the previous version! Too bad!

However, Christmas is all better ... so dear Santa Adobe, we look forward to future updates.
Continued ...
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:
Continued ...
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 ...
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, ...