Articles Tagged 'Actionscript 3.0'
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:
Continued ...
We continue the analysis of the example of the game Tic Tac Toe, presented in Actionscript 3.0 for beginners: lesson # 2 . We arrived at the function that creates the game grid:
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
| / ** * Graphic design grid (3x3) on screen * * @ Param void * @ Return void * @ Private * / createGrid ( ) : void { private function createGrid (): void { / / Temporary pointer to a MovieClip / / Note: here you could also use a Sprite / / But in this case I need to extend the object / / Adding some personal proproetà. The Sprite / / Is a closed class and therefore not extensible runtime, while / / The MovieClip class is a dynamic class and then makes / / Possible to add run-time properties MovieClip , i : uint = 0 ; var tm: MovieClip , i: uint = 0; / / Add the MovieClip in a 3x3 pattern ; i < 9 ; i ++ ) { for (; i <9; i + +) { ( ) ; tm = new MovieClip (); tm ) ; addChild (tm); = OFFSETX + ( ( i % 3 ) * ( PLAYER_WIDTH + PLAYER_OFFSET ) ) tm. offsetX = x + ((i% 3) * (PLAYER_WIDTH PLAYER_OFFSET +)) = OFFSETY + Math . floor ( i / 3 ) * ( PLAYER_HEIGHT + PLAYER_OFFSET ) tm. OFFSETY + y = Math . floor (i / 3) * (+ PLAYER_HEIGHT PLAYER_OFFSET) tm. _index = i; 0 ) ; drawPlayer (tm, 0); } / / Draw the 2 lines and 2 horizontal ranges addressable this . graphics ) { with (this. graphics) { 6 , 0x666666 ) ; lineStyle (6, 0x666666); OFFSETX , OFFSETY + ( PLAYER_HEIGHT + 15 ) ) ; moveTo (offsetX, OFFSETY + (PLAYER_HEIGHT + 15)); OFFSETX + ( ( PLAYER_WIDTH + 20 ) * 3 ) , OFFSETY + ( PLAYER_HEIGHT + 15 ) ) ; lineTo (offsetX + ((PLAYER_WIDTH + 20) * 3), OFFSETY + (PLAYER_HEIGHT + 15)); OFFSETX , OFFSETY + ( PLAYER_HEIGHT + 20 ) * 2 ) ; moveTo (offsetX, OFFSETY + (PLAYER_HEIGHT + 20) * 2); OFFSETX + ( ( PLAYER_WIDTH + 20 ) * 3 ) , OFFSETY + ( PLAYER_HEIGHT + 20 ) * 2 ) ; lineTo (offsetX + ((PLAYER_WIDTH + 20) * 3), OFFSETY + (PLAYER_HEIGHT + 20) * 2); OFFSETX + ( PLAYER_WIDTH + 15 ) , OFFSETY ) ; moveTo (offsetX + (PLAYER_WIDTH + 15), OFFSETY); OFFSETX + ( PLAYER_WIDTH + 15 ) , OFFSETY + ( ( PLAYER_HEIGHT + 20 ) * 3 ) ) ; lineTo (offsetX + (PLAYER_WIDTH + 15), OFFSETY + ((PLAYER_HEIGHT + 20) * 3)); OFFSETX + ( PLAYER_WIDTH + 20 ) * 2 , OFFSETY ) ; moveTo (offsetX + (PLAYER_WIDTH + 20) * 2 OFFSETY); OFFSETX + ( PLAYER_WIDTH + 20 ) * 2 , OFFSETY + ( ( PLAYER_HEIGHT + 20 ) * 3 ) ) ; lineTo (offsetX + (PLAYER_WIDTH + 20) * 2 OFFSETY + ((PLAYER_HEIGHT + 20) * 3)); } } |
Continued ...
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.
Continued ...
The Text Replacement technique that I present today is in some respects, very interesting. Unlike the classical image using CSS to replace operation , this technique uses a Flash movie to overwrite the titles of our site. Despite being a little more complex, requiring the creation of a Flash movie and the use of JavaScript, produces a number of considerable advantages:
- Keeps the 'accessibility to the site using a True-Unobtrusive Javascript- so that crawlers and spiders continue to see the page as simple and correct HTML
- It does not require the creation of n by n image titles. Only one movie to replace all the titles of our site, with a considerable saving in terms of the Download
- Also allows you to create simple titles but not normally used fonts on the Web
- Text can be rendered in HTML, thanks to the features of Flash
- The text is selectable
- As you can insert a Flash movie and interactive animations of any kind
You will note, also, that in this procedure are practically no CSS considered!
Continued ...
It may seem a predictable and already exhausted, but with Flash CS3 and the new management of document classes (package) permitted in Actionscript 3.0, is not fully functional immediately create a preloader. The latest release of Flash, in fact, manages to load the movie in a different way from previous versions. On the net you can find different proposals and solutions to create a preloader "old school". However, several examples I found did not satisfy me fully as they require to alter the movie so that it works like a classic preloaders. In practice, when you develop must always remember "this thing I have to do so otherwise the preload does not work"! And for movies already filled in, then?
Loader
The solution I have adopted, at least for now, was to make a movie outside (my loader - see example ) able to load any movie outside, including a picture! This solution, although it requires basically two movies (the loader and the FILAME true), it becomes economical only if you can create a loader that can be used over and over again, that is able to upload any movie, any resolution and any frame rate.
Continued ...
In the post Flash CS3: Create a reflex effect on any MovieClip we saw how you can write a class that extends MovieClip, to connect it to DesignTime to any MovieClip in the library. I discovered, however, that may be more useful and economical path to the contrary. I created a class Reflex ( Reflex.as ), with the intention of using it exclusively by code. I created this class thinking of moving the pointer in the constructor to a MovieClip. , ma leggermente modificato in modo da poter funzionare espressamente da codice: The new class Reflex contains essentially the same code inserted in the first ReflexMe , but slightly modified so as to work specifically by code:
1 2 3 4
| / / sfx .*; undolibrary imports. .* sfx; / / Reflex = new Reflex ( movieClipInstance ) ; var rx: = new Reflex Reflex (movieClipInstance); |
Continued ...
I introduce today a vast and interesting subject that has its "core" use class DisplacementMapFilter . , etc…). This class allows you to apply a displacement map filter to a visual object Flash ( Bitmap , Sprite , etc ...). Filters, Flash CS3, and it has several all belong to the same family. However, the DisplacementMapFilter has very special characteristics, such as vedreno, making it unique in the generation of spectacular effects.
DisplacementMapFilter - click to open the Flash movie
Download the source
Continued ...
With AS3 have introduced new "instructions" to define properties and methods (public or private). si comportava in AS2 come ora si comporta protected , in AS3 private è davvero “privata” !) proprio a causa dell'introduzione di una sintassi più OO rispetto alle precedenti versioni. Some, such as private - already present in AS2 - changed behavior ( private behaved in AS2 behaves like now protected in AS3 private is really "private"!) just because of the introduction of an OO syntax than previous versions . Better outline, then, from the "public" at most "private":
- public
everyone can access it - protected
you can access the parent class and subclasses - Private
only the class that defines - Internal
only within the same package
Continued ...
Taking advantage of a remarkable feature of Actionscript 3.0 (see ActionScript 3.0, all with the new operator ) I created a class ReflexMe able to generate an effect "reflection" on any MovieClip present in the library.
The source is part of the package undolibrary - GoogleCode of this - but if you want you can download the single file ReflexMe.as .
Continued ...
The class BitmapData allows you to easily apply effects useful for various purposes. We have already seen how to create a "fog TV" with a few lines of code ( Flash CS3 to create fog effect TV in 1 second ). Now we will deal with another effect "spectacular" which, as we shall see later, allows the creation of interesting visual effects, as in the example shown below: the parameters varied to observe the different effects, clicking the mouse on the image generated This can be moved.
On this occasion I also added a new simple component (Check) in Undolibrary ! So update your SVN repository. The source is available here: MapEffect.zip
Continued ...
Latest Comments
Robert : I rispsoto your questions with pleasure. The idea is really great. I am looking for a solution ...
Sting : @ Darius - you can see an example here: http://www.fight4fun.it/ clicking on: MAPS I hope ...
vik : Giustappunto I'm working on a project and the client asked me to show all the news (which are CPT) in ...
Giovambattista Fazioli : @ paso: absolutely. Simply identifying the field [cci] input [/ cci] you want to ...
paso : Hello I would like to request a service, you can use the datepicker with cform7 I spiegp best I can implement ...