Saturday, September 17, 2022

Animation with Scripting for Adobe Flash Professional CS5 Studio Techniques – Ajar Productions

Animation with Scripting for Adobe Flash Professional CS5 Studio Techniques – Ajar Productions

Looking for:

Adobe Flash Runtimes | Documentation archives and downloads.Animation with Scripting for Adobe Flash Professional CS5 Studio Techniques -  













































     


Animation with scripting for Adobe Flash Professional CS5: studio techniques | eBay



 

To set up a scene for panning or zooming, you need to place the entire scene in a single symbol. Once this has been done, panning and zooming is achieved by applying a motion tween to the instance of the symbol containing the actual scene. For projects that will be exported to a format that allows the inclusion of ActionScript, there are components that have been created to behave like cameras in Flash.

You can move them, scale them, rotate them, and even change their color properties. When the movie is published, your camera manipulations are seen onscreen. Panning in Flash generally refers to 2D movement. A perfect example of 3D panning occurs in the opening scene of the original Star Wars movie. The ship moving through space is very convincing to the eye. When the footage is played back, the ship appears to move forward through space past the camera.

You use the same basic principle to create a panning effect in Flash. To pan across a scene, you need to follow two guidelines.

Make sure that. The entire scene is inside the symbol that will be Motion Tweened. Panning your scene is as simple as dragging an instance of your scene onto the Stage and tweening horizontally from one side to the other Figure 1. The background was intentionally drawn much wider for the purpose of creating a panning effect and converted to a symbol. The steps that follow describe how to create a pan effect on a background that has been encapsulated in a symbol.

Insert frames F5 in the Timeline and position the frame indicator aka playhead at the last frame Figure 1. Position the symbol containing the background to the opposite side of the Stage. The Motion Tween will automatically interpolate the symbol across the Stage between frame 1 and the last frame in the motion span.

There may be occasions when you realize that you want to add a pan to artwork that has already been drawn and animated on the main Timeline.

The following steps describe how to convert an existing scene to a symbol. Select all frames and layers by clicking and dragging across the Timeline highlighting them in black. Return to the main Timeline to delete the original animation. Create a new layer, drag your scene onto the Stage from the Library, and reposition it accordingly.

Now you can move the symbol containing your scene around the Stage by using a Motion Tween Figure 1. Upon playback, the illusion to the viewer is the camera being moved; when in actuality, it is the scene that is moving. To add depth to your animations, you can simulate this natural phenomenon using a technique known as parallax scrolling to move your foreground objects greater distances than your background objects over an equal amount of time i.

Parallax scrolling grew out of the multiplane camera invented at Disney in the s. The multiplane camera involved layering different pieces of artwork in front of the camera. As the camera moved, the layers of artwork moved differently based on their relative distance from the camera Figure 1. Make sure each piece of artwork in your scene has been converted to a symbol and each symbol has its own layer.

On the last keyframe of each tween, move each object Figure 1. You can easily create a motion blur on the Timeline using the MotionBlur extension found in the Extensions folder on the CD. Adjust the foreground objects more than the background objects.

Suppose, for example, you have three layers e. Sample last-frame adjustments might include moving the lowest layer horizontally by pixels, the middle layer by pixels, and the top layer by pixels Figure 1.

You can also blur the more rapidly moving objects to add extra realism to your parallax effect see Chapter 3 for a motion blur effect using ActionScript. These same parallax techniques can be applied to zoom effects as well.

Zooming Zooming is a method of decreasing the apparent view angle of an image so that the image appears closer to the viewer. Zooming effects in Flash are accomplished in a similar manner to panning except that the symbol is scaled instead of repositioned or rotated. Note how the tree has moved with respect to the relatively immobile sky in the background.

Camera effects go a long way toward pulling your audience into your animation. You should consider your production needs when processing your audio. To apply an audio clip to your Timeline: 1. Create a new dedicated layer for your audio. As a matter of best practice, audio should always be on a separate layer. Lock your audio layer to avoid accidentally adding art- work to this layer. Insert new frames F5 to extend your Timeline so that it is long enough to accommodate your audio use the waveform displayed on the Timeline as your guide.

Add new keyframes to your audio layer as necessary, and repeat the previous step to start an audio clip at a different location Figure 1. This is because the default behavior is Event. The next section shows you how to adjust the sound properties.

Synchronizes the sound to the occurrence of an event, such as when a user clicks a button. The same as Event except that if the sound is already playing, no new instance of the sound plays.

Synchronizes the sound with the Timeline. Flash forces animation to keep pace with stream sounds. Also, a stream sound can never play longer than the length of the frames it occupies. The other three behaviors are useful in games and when you need to play audio using ActionScript.

To update your existing audio on the Timeline so that it will sync with your artwork: 1. Switch the Sync behavior to Stream in the Properties panel Figure 1. Move the playhead around again. Chapter 1 Getting Started You can now see and hear how the Stream behavior enables you to sync your audio with your animation.

A waveform is a visual representation of the amplitude basically volume of an audio clip over time. Flash has a number of presets to quickly adjust the envelope of an audio clip, such as Fade in or Fade out, Fade to left or Fade to right, and so on. When you have a keyframe with audio selected, you can apply one of these presets via the Effect menu under the Sound heading within the Properties panel Figure 1.

To edit the audio envelope more precisely, click the Edit sound envelope button the pencil icon next to the Effect menu Figure 1. With the Edit Envelope window open, you can edit the envelope by hand Figure 1. The two waveforms represent the left and right channels for stereo audio. To create additional envelope handles up to eight total , click the envelope lines.

To remove an envelope handle, drag it out of the window. Note how adding or removing a handle applies to both channels. Effects such as fading from one channel to the other channel essentially, one speaker to the other can add realism to an action that takes place on one side of the Stage and ends on the opposite side.

Because within Flash you must manually add the sound into each scene you create. But this is a huge 24 Chapter 1 Getting Started problem if your audio is one continuous soundtrack, like music as we have discussed. If the audio is a continuous sound and you add it to the Timeline in Scene 1 and then again in Scene 2, there will most likely be a noticeable glitch in the audio during playback. Thus, if you have an audio track similar to a piece of music and there are no obvious breaks or moments of complete silence, we recommend keeping your movie as a single scene.

Try to avoid having a 30,frame Timeline during the planning of your project, before even opening Flash. In some projects, a long Timeline will be unavoidable. Remember that scenes are only a function of the Flash authoring tool. Once you export your movie, your animation becomes one long Timeline. One last topic, sound settings, needs to be addressed before we wrap up this section on incorporating audio into your animation. Dialogue and music will likely require a higher-quality compression setting than will sound effects.

In addition to adjusting global Publish Settings, you can individually adjust the quality of each sound item in the Library. Note that the Override sound settings check box in the Flash Publish Settings allows you to supersede those Library item settings if you so desire. Click the Set button to the right of the Audio Stream label to open the Sound Settings for all audio with the Stream behavior Figure 1.

Bit rate is generally the most effective setting to change. For publishing to the web, MP3 generally has the best compression-toquality ratio. Return to the Sound Settings as necessary to adjust the audio quality to your satisfaction. Narrative The sequences of events that constitute your story are considered its narrative. This will help you develop a broad understanding of where your animation is going before you begin investing your time in implementation. Here are some questions to consider when assembling a narrative:.

Is the story driven by a character or a situation? What characters are present in the story? From whose point of view is the story told? In what sequence are the story elements presented? What is the setting time and place of the story? Take Star Wars as an example again, and answer these questions regarding its narrative. Answering these questions will also make it easier for you to explain your story to others, which is especially helpful if you are seeking funding or need additional help producing your animation.

In addition, answering these questions can help you decide what type of narrative to employ. Types of Narrative There are a few basic types of narratives. You can use a single narrative type, or you can exploit multiple narrative types in a single story. There are three broad types of narrative to consider: linear, nonlinear, and branching. These narrative types can be used on their own or combined with each other in various ways.

Linear A linear narrative occurs in a straight, cause-and-effect, chronological sequence. A sample linear narrative might proceed as follows:. We, the audience, meet Boy what a nice, troubled young man.

We meet Girl hey, she should meet this Boy we know. This may be a plain-vanilla narrative, but the truth is that many good stories utilize such a linear narrative.

As with any other art form, execution is key. Nonlinear Nonlinear structure rejects the cause-and-effect, chronological sequence. Many nonlinear narratives are meant to mimic human memory. Other narratives are designed precisely so that a chronological sequence cannot be reconstructed e. As you can imagine, there are several variations within the general category of nonlinear narrative.

Branching Interactive storytelling is especially well suited for a particular subtype of nonlinear narrative: branching. A branching narrative allows the path of the story to change as the story is being told or shown , as in the context of a game.

Shifts in the narrative can be based on user interaction, they can be based on environmental factors e. If you want to take your character description a bit further, you can write a story bible.

Story bibles are reference documents written for comics and television shows that include detailed information on character, setting, and other story elements.

Story bibles are especially helpful for maintaining consistency on projects that have multiple authors or writers. These poses help to determine how a character will be rendered from various vantage points. Model sheets serve two distinct purposes: exploration and communication. A model sheet can be rendered as rough sketches Figure 1. Usually, rough sketches are drawn to determine shot composition and timing. The process of drawing a rough version of your story is known as storyboarding.

Storyboarding A storyboard is a sequence of drawings, as in a comic book or a graphic novel, that serves as a blueprint for your story. Think of the storyboard as a visual plan for your project or as a script with sketches instead of words.

When developing a game, storyboards are useful for mapping out the overall game play, action sequences, and scene breaks. A successful animated project is the result of good preparation. A storyboard ensures that all animators are on the same page. Now that you know what a storyboard entails, you might be curious to see what one looks like. Like many other techniques in animation, storyboards were first created at Disney in the s.

Since then, the elements of storyboarding have remained essentially unchanged. Many live-action movies are also storyboarded to help plan shots. To learn more about storyboarding, see this interview with a storyboard artist at Pixar www. All storyboards contain an indication of framing. All actions take place within the frame. Usually, only frames with important actions are included in the storyboard i. Storyboards can be rough hand-drawn images because their purpose is to save time, but the drawings should be clear enough to make the action evident to someone else.

Each frame in the storyboard should include just enough detail to convey the setting, characters, and camera shots collectively known as blocking. Some of the best storyboards have even been drawn on restaurant napkins. You can download preformatted storyboard templates or create your own by drawing panels on paper or in Flash.

If you use Flash to create your storyboard and include one action per keyframe, the Stage will serve as your frame border. The tools that you use to create your storyboard may affect the particular format that you choose for your storyboard. You may prefer to use this method, or you may prefer to remain completely paperless by drawing entirely on the computer.

Drawing directly into Flash is certainly a fast and easy way to start your Flash animation project. You can print this template for a hard copy or import the PDF to Flash and work with it digitally. There are several digital alternatives to drawing in Flash: Adobe Photoshop, Adobe Illustrator, and Autodesk SketchBook Pro are our favorites, but you can use whatever you are most comfortable with.

Storyboarding on Tablet Devices With new technology comes new ways of creating content. These applications are designed so that your finger is the actual drawing tool.

Consider your output format when deciding on your Flash dimensions. See Chapter 5 for more information. Storyboard Composition One of the most important functions of the storyboard is to establish your framing i.

This is essentially how the camera and thus, the audience will 34 Chapter 1 Getting Started see your characters and the scenes they inhabit. Several elements combine to form successfully drawn storyboard images. The following subsections detail the primary elements that should be considered when drawing your storyboard frames.

Setting Setting determines where the action takes place: inside a building or outside, in a city, a jungle, or perhaps a desert. On the other hand, the setting may play an integral part of your project, provided certain areas of the background interact with the character. Plot Plot describes what happens to the character s in the story or the game.

In a game, a plot can be as simple as getting the character from point A to point B, or something more complicated such as accumulating points by collecting various types of hidden objects on different levels. Action Action determines how the story or game will play out from beginning to end. Actions are the events that drive the plot.

When it comes to interactive narratives, the user contributes to those actions which are generally controlled with ActionScript. Typically, Flash animated shorts and games do not have as many different camera shots as a traditionally animated cartoon, but a new camera angle here and there can be refreshing and can help convey emotions within a scene. In a storyboard, these roughly translate to how much space a character consumes in a particular frame.

Wide shot or long shot. This is a shot that shows your entire scene or stage. It can also be called an establishing shot. Medium shot. If the subject is a character, the medium shot would be from about the waist up. The medium shot can also serve as a transition from a wide shot to a close-up. Close-up shot.

This shot is very close to the subject and tends to show your character from the shoulders up. Extreme close-up shot. Use the extreme close-up sparingly, especially in any animation.

This is a shot in which the frame encompasses a view of two people Figure 1. Over-the-shoulder shot. This is a great shot to use when two or more characters are interacting with each other. It gives the viewer a solid visual understanding of who Chapter 1 Getting Started is where in the scene. The over-the-shoulder shot is an effective way to transition from one shot to the next Figure 1.

Perspective angle Figure 1. The simplest way to imply a camera angle is to add angle lines in the background.

Different angles can alter the interpretation of a given shot or serve to reinforce a mood that is being conveyed with other elements e. The angle you choose can convey a certain relationship between two characters or between the character and the audience. One angle can make your character look powerful; yet another can make your character appear meek and helpless Figure 1. This game started as a simple way to showcase the peer-topeer capabilities of Flash Player What started off as a very simple example quickly grew into a fully interactive Flash game that includes various characters, animation, and a scoring system.

Sausage Kong is the result of several fun ideas tossed back and forth by Thibault and Chris via email. At the time, Thibault was living in Paris, France, and Chris lives in Boston, Massachusetts, so it was helpful to construct a storyboard to ensure that both parties were on the same page when it came to determining how the game would work and what assets were necessary to create and program the game. This is a situation in which a rough storyboard came in handy.

The Concept Within Sausage Kong, the user presses the arrow keys on the keyboard to control the direction of a character left and right. To start the game, the user presses the spacebar, and a boy jumps in the air. Once caught, the boy must run toward a grinder machine, and the user presses the spacebar to make the boy throw the pig into the grinder.

The grinder cranks out sausages made from the pig. The more sausages made within a predetermined amount of time, the more points earned. Working from this concept, Chris began creating storyboards. Since the pigs are parachuting from a high elevation, the background environment is an exterior shot with grass, trees, and sky.

The preloader includes a percentage load bar as well as a fun animation of sausages dancing in a circle Figure 1. The second frame of the storyboard roughly shows how the introductory splash page will look. The preloader disappears, and the game logo drops down from outside the viewable area, as indicated by the red arrow.

When creating a storyboard in Flash, it can be useful to dedicate an additional layer just for drawing arrows and notes to specify how various elements will move Figure 1. If the user selects New Game with the arrow keys , the logo will disappear and the game begins. Chris Georgenes , Justin Putney. This Studio Techniques book is designed for intermediate or advanced users who understand the basics of Flash and want to create a more immersive interactive experience.

The book includes coverage of storyboarding, 2D character design and rigging, character animation, visual FX with code, workflow automation, and publishing your animation on the web and to mobile devices. The moment of triggering an event for broadcast is known as dispatching an event. When an event is dispatched, the event also carries information about the occurrence of the event. T h e information carried by the event varies depending on the type of event that was dispatched.

For instance, a KeyboardEvent carries information about the key that was pressed. You'll put events to good use in the examples that follow. Creating Reusable Classes For Animation So far, you've written a class that takes advantage of the extends keyword to reuse the methods and properties found in the MovieClip class and applied that class to a Library symbol.

There are also several other ways that classes can be reused. When extending a class, the class being extended is referred to as the base class or superclass. Any class that extends another class is referred to as a subclass of its superclass. After extending a class, you can rewrite certain methods from the superclass to fit the needs of the subclass. The ability to use a single method name for a method that behaves differently in different subclasses is known as polymorphism poly for many, morph for shape.

Suppose you need to write a Gat class and a Dog class in your project. Following good object-oriented etiquette, you begin by writing a more abstract superclass called Animal. Because vocalization is a behavior common to most animals, you endow your Animal class with a speak method. Depending on your needs, you may decide to include a Mammal class to extend your Animal class, or you may write your Gat and Dog classes as direct subclasses to the Animal class.

At this point, the behavior in your classes begins to diverge. In the Dog class, you redefine the speak method to act as a bark. In the Gat class, the speak method elicits a meow. Any object that can interact with the Dog class can use the same methods to interact with the Gat class, although when asked to speak, the Gat will meow instead of bark.

In addition to altering methods to suit the needs of your subclasses, you can override methods from a superclass entirely. Even though altering the functionality inherited from your superclass can seem like rewriting, this is generally still preferable to rewriting a base class that has been tested and may have other classes depending on it.

Now that you're aware of polymorphism, you can plan your base classes accordingly. The examples that follow use polymorphism to generate various visual effects. Class Examples: Visual Effects Before you start on effects, let's lay the groundwork for testing your effects. Let's first establish a classpath for the rest of the classes you will write in this chapter and then create some artwork to show off your effects classes.

Create a new folder called c o m inside your examples folder. Create a subfolder within anim named fx. The fx folder will store your effects classes. Create a new ActionScript 3. In the EffectsBase.

T h e more complex your artwork, the more it will demonstrate the performance of the effects you are about to create. T h e figures in this section use a depiction of a rocket, but you can use any piece of artwork that you'd like Figure 3.

To see the full power of your effect, create a background as well. Make sure your background is on a separate layer. T h e examples in this section use a night sky as a background Figure 3.

Move your symbol instance to the bottom-left corner of the Stage. When your tween is created, the playhead automatically moves to the last frame. Move your symbol to the top-right corner of the Stage.

Hover over the middle of the tween path with the Selection tool. You should see a curved line appear next to your cursor. Click and drag the middle of the path toward the upper-left corner of the Stage to make a curved tween path Figure 3. Now that your path is a curve, click on the path to select it. This causes your instance to rotate as the path curves. Add a frame F5 to the end of your background layer so it's visible for the entire length of the tween.

Now it's time to create your first effect. The symbol you create for this section can also contain nested animation. Try using the Deco tool to add a particle, smoke, or fire effect within your symbol. TheMotionBrush class You'll start your effects classes by tackling a common animation task: hand-written text. Grafting the illusion of text being hand-written in real time onscreen can be time-consuming.

You'll create an easier-to-apply, reusable class that accomplishes a write-on effect. Not only that, but any graphic content can be employed as the "brush," and the application of the class will not be limited to write-on effects. Your MotionBrush class will also serve as a base class for effects that you will create later in this section.

To render your MotionBrush class, you'll need to employ the powerful Bitmap class. Nearly all visual effects in Flash exploit the Bitmap class.

For instance, when you add a blur filter to a symbol instance on Stage using the Properties panel, Flash renders the instance as a bitmap to generate the blur effect. Most artwork generated using the Flash drawing tools is composed of vectors. Vectors are made up of lines and curves. Bitmaps are generally less complex to render for effects because they are simply composed of pixels rather than complicated vector data. Since you're rendering the bitmaps using artwork from the Flash file, your effect will not increase the file size.

The MotionBrush class will use a Bitmap object as a canvas and draw copies of a symbol instance onto the canvas. For programming simplicity and rendering performance, these symbol copies will simply be superficial pixel-based snapshots. Every so often, you'll take a snapshot of the "brush" symbol at its current position and display state. For other complex effects, you may even want to use your canvas as a mask, so let's be sure to build that into your MotionBrush class.

This inventory will become the basis for the methods of the MotionBrush class. Additionally, you need to think about which parts of your class will be open to the outside world i. As a matter of practice, you should make no more than necessary available outside of the class. T h e practice of restricting the internal workings of a class is known as encapsulation. You will encapsulate parts of your class, both to protect parts of the class and to make it simpler for the outside world to interact with the class.

Since you will extend your class, and other classes will depend on this class working properly, you'll want to make sure that your class is relatively tamper-proof. Also, your class should do its j o b with as little outside instruction as possible.

Imagine sitting down at a restaurant to order French fries. You don't have to tell the cook how to wash and cut the potatoes, what temperature to heat the oil to, how to store the salt, and so on because it is the cook's j o b to perform these duties. In fact, the cook's kitchen is so encapsulated that you probably will never even see the cook.

You will be interacting with members of the wait staff, because that is part of their duties. If the instruction necessary for ordering French fries was too complicated, you'd be much more likely to stay home and cook for yourself.

The instructions that you give to the MotionBrush class should be as simple as or simpler than ordering French fries. This helper class will operate in a manner similar to a cook's kitchen: The code that interacts with MotionBrush will not have access to this helper class.

The technique of utilizing a class within another class, instead of subclassing, is known as composition. To protect access to your class, you will use access keywords.

There are four keywords that determine the availability of a method or property within a class: public, private, internal, and protected. See Table 3. TABLE 3. T h e protected keyword allows classes that extend the MotionBrush class to rewrite methods and properties but shields the methods from other ActionScript classes, even within your com.

To reshape the MotionBrush class in subclasses, you'll use the overrule keyword to rewrite functions inherited from the MotionBrush class. Save a copy of EffectsBase.

Create a new class named MotionBrush. Save the file as MotionBrush. This will place the class into the com. Update the first line in the script to reflect the proper package: package com. You will attach MotionBrush to the Library symbol you created earlier. The onAddedToStage method starts your effect in motion once the symbol using the class is added to the Stage.

If the symbol is added to the Stage by dragging it from the Library rather than instantiating it with ActionScript, the onAddedToStage will fire as soon as the frame with the symbol is played. Since an event listener calls your onAddedToStage method, it must accept a single parameter of type Event, which will be stored as a variable named e. T h e onRemovedFromStage method will handle any cleanup necessary.

This method will also be called from an event listener and therefore must accept a single parameter of type Event.

These first three methods utilize the protected access keyword because you'll want to permit any classes that extend MotionBrush to rewrite these mediods to allow for new behaviors. None of these three methods return any values hence the void keyword following each method. These methods are present to launch other actions into motion. The fourth mediod, however, is present precisely to return an object die bitmap canvas.

Once executed, getCanvas will return the bitmap canvas that the MotionBrush has drawn on. This functionality allows even more visual effects to be created with the MotionBrush class and subclasses , such as using the canvas as a mask for other artwork.

Make sure all the import statements are listed above the class declaration: import import import import flash. MovieClip; flash. Bitmap; flash. Event; com. SymbolCanvas; You'll need to add com. SymbolCanvas by hand, but the code editor will likely have added the other import statements for you, since the classes have already been referenced in the code you've written. Add the following property declarations above the constructor method i.

You'll create that class in a moment. The next two properties, hideSymbol and clearCanvasOnUpdate, allow you to adjust how the symbolCanvas renders in future subclasses of MotionBrush. Both properties will be simple toggle settings so they are typed to Boolean true or false. The reason for this will become apparent when you write the first subclass for MotionBrush. Having an initialization method instead of putting code into your constructor method is always good practice.

An initialization method allows you to reset properties within your class without needing to generate a new instance of the class. The first setting notifies the symbolCanvas that it won't need to display your original symbol, just the bitmap representation. The second setting notifies the symbolCanvas not to clear the canvas before rendering. This setting is central to achieving the write-on effect described at the beginning of this section.

The init method also calls another method to initialize the listeners that will call the onAddedToStage and onRemovedFromStage methods. The initStageListeners method is primarily for organizational purposes. As a general rule, each method should perform one distinct task.

Separating the listener initialization into a single method also makes the init method simpler to overwrite and the code simpler to read. Note that the init method is assigned protected access as well. Normally, an initialization method should be private, but in this case you want to allow for different assignments to the hideSymbol and clearCanvasOnUpdate properties in future subclasses, as Chapter5 Introduction to ActionScript Classes well as allow for the possibility of starting and stopping the bitmap rendering at points other than when the symbol is added to or removed from the Stage.

After completing all the initialization code, you need to make sure that the constructor calls the init method. In the onAddedToStage method, you generate the SymbolCanvas instance using the new keyword and pass a reference to your symbol, and then the two properties that you assigned in the init method. T h e onRemovedFromStage and getCanvas methods also now contain the code to operate as previously described.

To provide the bitmap canvas for outside use T h e completed code for the MotionBrush class should read as follows: package com. Bitmap; import flash. Event; import com. Return to your MotionBrushExample. Open the Library item properties, select the Export for ActionScript check box, assign com. MotionBrush as the symbol's Glass, and click OK. Wait to test your movie, because you need to put the SymbolCanvas class into place first.

The SymbolCanvas class T h e SymbolCanvas class primarily utilizes the private access keyword rather than protected, since SymbolCanvas is less likely to be extended. Because other classes utilize SymbolCanvas via composition rather than subclassing, it will therefore be safer to add new methods to SymbolCanvas as you progress, as long as the old methods continue to function as expected.

When you want to make a method or property available to another class, you will use the public keyword. Create a new class named SymbolCanvas. Save the file as SymbolCanvas. Let's first add the three methods that were established from writing the MotionBrush class.

Add the following properties above the constructor method: private private private private private private var var var var var var offset:Point; bmd:BitmapData; bmp:Bitmap; src:DisplayObject; clearOnUpdate:Boolean; hideOriginal:Boolean; T h e first property, offset, will ensure that your effect always renders in the proper place on Stage no matter how many symbols are nested above your symbol.

T h e next two properties store the BitmapData and Bitmap objects that you'll use to render any and all effects. T h e last three properties store the information that you passed from the new SymbolCanvas instantiation in the MotionBrush class. These parameters must match the arguments used in the MotionBrush class.

The symbol parameter is typed to DisplayObject for forward compatibility. T h e DisplayObject class is a distant superclass of the MovieClip class. Your MotionBrush class is of type MotionBrush, but it extends MovieClip, and by extension, all the classes listed in the inheritance chain.

By typing the symbol parameter to DisplayObject, your SymbolCanvas class will also allow arguments for the symbol parameters that are Sprites, InteractiveObjects, and so on. This will be of use if you ever decide to pass the SymbolCanvas class a source object that's been instantiated using code rather than from the Library.

As a general rule, typing a parameter to the lowest class in the chain makes your code more flexible for future features. The line inside the constructor, the initSymbolCanvas method call, passes the arguments to an initialization function. You may have noticed that in addition to being strictly typed, the second two parameters defined for the SymbolCanvas constructor method also have values assigned.

In addition to setting default values for these parameters, these assignments cause the hideOriginalSymbol and clearCanvasOnUpdate parameters to be optional. If these parameters are not passed when a new SymbolCanvas instance is created, the compiler will not generate an error and the parameters will be set to false and true, respectively, by default.

You'll then use the arguments from the three parameters to assign values to your src, clearOnUpdate, and hideOriginal properties. Your code will then call another initialization method to generate your bitmap. If it happens that hideOriginal resolves to a value of true, your code will render the source object invisible. Now for some slightly more complex code one reason you're encapsulating it in the SymbolCanvas class.

The i f statement is one of the most basic pieces of programming logic. The i f statement only executes the code inside its code block if the conditions inside its parentheses are found to be true. No curly braces are necessary to enclose an i f statement if the code block is only a single line see the SymbolCanvas class for an example of a single-line i f statement.

The counterpart to the i f statement is the e l s e statement. An e l s e statement must immediately follow an i f statement. The code contained in an e l s e block will execute if the conditions for the i f statement are found to be false. Similarly, there is also an e l s e - i f statement that you can use to test for additional conditions see the BoundedMover class later in this chapter for an example of the e l s e - i f statement. You first create a local variable named targ to store the parent of your source object.

The parent is the object inside which your source object is nested this will likely be the root of the Flash document. Your code then uses the as keyword to tell the compiler to type this existing object as a MovieClip. This is necessary to access methods within the MovieClip class without generating errors. At the moment, targ is a local variable, meaning it is assigned using the var keyword within the initBitmap method and will cease to exist once the Animation with Scripting for Adobe Flash Professional CS5 Studio Techniques method has completed execution.

Use local variables when possible to increase the speed at which your code executes. Next, your code assigns the bmd property to a new BitmapData object. Every object onscreen has a reference to the Stage stored in the stage property. You then use that reference to set your new BitmapData object's width and height properties to match those of the Stage within the first two arguments passed to the BitmapData constructor. With the third argument, you're assigning the transparent property of the BitmapData to true, which is essential for your effect to render properly.

With the last argument you set the fill color to a hex value representing white since the BitmapData instances use transparency, you will not see the white.

In the next line, you then assign your bmp property to a new Bitmap object and pass your BitmapData object to the Bitmap object's constructor. The line following that turns on the cacheAsBitmap property for the Bitmap object. It may sound redundant to cache a bitmap as a bitmap, but it will be necessary if the bitmap canvas will be used for any advanced masking in the future.

The next three lines ensure that the bitmap starts at the top-left corner of the Stage, even if your source symbol's parent does not.

A Point is a very basic object: just an x coordinate and a y coordinate. The new Point starts out with both x and y at 0 the top-left corner of the Stage , and uses the globalToLocal method of the targ object to offset the coordinates based on the targ object's position on Stage. After the coordinate space of the Point object has been adjusted, the x and y values are assigned to the Bitmap object Figure 3. The local position of the purple square is x, y The local position of the blue square is also x, y The position of the purple square relative to the Stage is therefore x, y Chapter5 Introduction to ActionScript Classes T h e last line within the initBitmap method adds your bitmap to the targ object's display list so that it will be visible onscreen.

Your code uses the addChildAt method to ensure that bitmap is rendered just underneath your source symbol. By using the getChildlndex method to then assign your bitmap to the stacking position held by the source object, the source object is pushed up a level in the display list right on top of the bitmap.

T h e second line stores the current matrix from the src object which includes its position, scale, and rotation. The third line uses the translate method of the Matrix class, along with the offset point stored earlier, to determine where the src object should be rendered on the canvas no matter how deep the source symbol is nested.

Both the x and y coordinates have a minus sign - to compensate for the translation of the canvas in the Animation with Scripting for Adobe Flash Professional CS5 Studio Techniques i nit Bitmap method. The fourth line renders an image of your source symbol onto the bitmap data using the transformation matrix that you translated, the color transform from the source symbol, and the blending mode from the source symbol, so it will appear as it does on Stage.

T h e final line in the update method assigns the updated bitmap data to the bitmap object so it will render onscreen. The dispose method is your housecleaning function. The first line removes the data stored within the BitmapData object using the dispose method built into the BitmapData class to free up memory.

T h e second line removes the bitmap from the parent object's display list so it will no longer be rendered onscreen. Confirm that the following import statements are all included at the top of your script. Add any that are missing: import import import import import import flash. DisplayObject; flash. BitmapData; flash. I primarily use greensock for most of my tweening. I am glad you have covered it in the book as well.

I would check the very beginning or possibly the very end. You should be able to download the files from that link. Turns out the link to the exercise files — which is listed at the end of the ebook!!!! Good to know that the link is at the end of the book, Monir. I hope you find the exercise files to be useful. Your email address will not be published. Notify me of new posts by email. Smart Mouth Extension The automatic lip syncing extension mentioned in Chapter 2 is now available!

Georgenes Sponsored Sponsored Sponsored. Adobe Premiere Pro 1. EUR 9. EUR 5. Picture Information. Shop with confidence. Get the item you ordered or get your money back. Learn more - eBay Money Back Guarantee - opens in a new window or tab. Seller information. Contact seller.

Visit store. See other items. Item Information Condition:. Good Good. Approximately EUR 4. Add to cart. Add to Watchlist Unwatch. Watch list is full. An error occurred, please try again. Last item Available. Does not ship to Finland See details for shipping.

   


No comments:

Post a Comment

- Windows Server ISO Free Download [Datacenter & Standard]

- Windows Server ISO Free Download [Datacenter & Standard] Looking for: Windows 2016 server datacenter desktop experience free. Wind...