This I propose is an article I wrote in August 2003 (original title: Written magic in Flash MX). Despite being "dated" (now I'd use a different ActionScript), I think it is a nice tool to truly enchanting effect. Propose later, or do you, the updated version with the use of classes ...
Dynamic MovieClip
The element that plays a key role nell'architetura Flash MovieClip object. The ability to create objects of this type of code gives a remarkable potential to Flash, making it a decent development environment really fun. With the ability to add run-time objects of type MovieClip, we'll see how easy it is to achieve the effect shown in Figure 1.
Figure 1 - Example of text effect
The class MagicText_class
Since we're using the latest version of Flash MX, we do things right and create a class MagicText_class be reused at will. What we're doing is defining a new class MagicText_class , which inherits all the characteristics of a class MovieClip. In this way we would have a real object, then create the basis for a Flash component real! If we wish. For now let us dwell only on our class and see how to build it.
Open Flash and set the Stage size to 300 x 100 pixels at 25 frames per second, with a white background. I remember that you can directly download the source if you wish.

Create a new MovieClip symbol and name MagicText_class , as shown in Figure 2. Also set the Linkage properties, with exactly the same name for the symbol. For those with Flash MX panel will be in Italian with different labels, then refer to Figure 2.
Linkage will allow you to add this symbol to-morrow from ActionScript. In practice, we are making available this class Flash development environment, the only way to do among other things.
Now is the time to insert the code needed to make this symbol a real object, with properties and methods defined by us. To do this (similar process to the creation of Flash MX components) should be informed that you are writing ActionScript code for a class, not for a normal frame Flash. Select the first frame of the symbol MagicText_class you created and enter the following code:
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 | # Initclip MagicText function () { "MagicText::constructor" ) ; trace ("MagicText:: constructor"); sx = 0 ; this. sx = 0; index = 0 ; this. index = 0; } / / / / Inherits the MovieClip class = new MovieClip ( ) ; MagicText. Prototype = new MovieClip (); / / . ShowText = function ( myStr_str ) { MagicText. Prototype. SHOWTEXT = function (myStr_str) { sx = 0 ; this. sx = 0; index = 0 ; this. index = 0; onEnterFrame = function ( ) { this. onEnterFrame = function () { attachMovie ( "letteraanim_mc" , "l" + this . index , this . index ) ; this. attachMovie ("letteraanim_mc", "p" + this. index, this.) index; "this.l" + this . index ) ; var obj = eval ("this.l" + this.) index; lettera_txt . autoSize = true ; obj. lettera_mc. lettera_txt. AutoSize = true; lettera_txt . text = myStr_str . substr ( this . index , 1 ) ; obj. lettera_mc. lettera_txt. text = myStr_str. substr (this. index, 1); . sx ; obj. _x = this. sx; sx + = ( obj . lettera_mc . lettera_txt . textWidth ) ; this. sx + = (obj. lettera_mc. lettera_txt. textWidth); index ++; this. index + +; this . index > myStr_str . length ) { if (this. index> myStr_str. length) { onEnterFrame = "" ; this. onEnterFrame = ""; } }; }; / / / / (LinkageID, className) registerClass ( "MagicText_class" , MagicText ) ; Object . registerClass ("MagicText_class" MagicText); # Endinitclip / / / / Block the execution ; stop (); |
The class MagicText_class not the heart of the system. In fact we could do without it. So, however, I took Occasion to show how easy it is to create objects with Flash MX. In addition, we will see how much more convenient to use these items instead of the MovieClip Drag & Drop ...
The heart of the system
Let the creation of the last two symbols MovieClip, the true heart of the whole system. These actually produce the desired effect or video effects. As can be seen from the code, the class MagicText_class does nothing but handle these particular MovieClip. Create now a new MovieClip symbol and name lettera_mc . Enter inside, the coordinates (0.0) a dynamic text, which we call lettera_txt .
This can be any size and any font. Enter an "A", so you have an idea of what will be the final result.
To make this work properly, include all the characters in filamto Flash dall'apposito panel in the properties of dynamic text. This is the only limit, which unfortunately increases the file size. Swf. If you do not proceed with the incorporation of character, the play will not work as it should. The symbol lettera_mc should not be exported to ActionScript. It provides a container to the symbol lettera_txt , which could not be used directly.
With this symbol, then, we have created a container for our character. Now is the time to create the symbol that will produce the desired special effect.
Create a new MovieClip symbol and name letteraanim_mc . This, as was the case for the class MagicText_class , it should be exported for use by ActionScript. Linkage Properties panel again selected as the name by entering the same identifier used for the symbol: letteraanim_mc (do not touch anything if Flash automatically sets the name identifier of the exported symbol with the name of the symbol).
Animation and Effects
, come mostrato nella figura qui a sinistra. Inside the symbol letteraanim_mc included in the first instance of the symbol frame lettera_mc , as shown in the figure on the left. . Appoint the instance of lettera_mc with the same name: lettera_mc .
Now position yourself a few frames later, for example, on 25, and from the Insert menu (Insert for the Italian version) selected keyframe (keyframe). On the last frame inserted into an ActionScript stop ();.
Now you can have fun and do the effects you want, create a fade (using Tween) using the _alpha parameter, expand the written words can really do whatever you want.
In the source file that you can download a fade is used together with a partial rotation with magnification.

Figure 5 - Here's what the MovieClip letteraanim_mc . Also try to leave a single frame with no animation ...
Last effort
If you've come this far we've really done everything, or at least relatively more complex. So we can prove our hard work. Get back on the scene, select the first frame and enter this code:
1 2 3 4 5 6 7 8 9 10 11 12 | ; stop (); / / , "mt" , 1 ) ; attachMovie ("MagicText_class", "m", 1); ; mt. _x = 84; ; mt. _y = 35; "Hello World!" ) ; mt. SHOWTEXT ("Hello World!"); / / Repeat function () { "Hello World!" ) ; mt. SHOWTEXT ("Hello World!"); } / / repeat , 3000 ) ; I_repeat = setInterval (repeat, 3000); |
tramite l'struzione attachMovie() . The code on the first frame of our movie creates the object mt as an instance of MagicText_class through the construction attachMovie() . Subsequent lines reposition the MovieClip (at your leisure), and invoke the method ShowText() , with the text we want to show. Last note: the function repeat() the animation repeats every 3 seconds.
Download
| Operating System | |
| Environment | |
| Source |










There are no comments for this post
Leave a comment