Documentation

  Conversion modes: Plain and Nesting

Conversion mode is the program used by GAF Converter to process an SWF animation. Before GAF Converter v.4.0 was released there had been one conversion mode - Plain. Starting from 4.0 version we’ve added one more conversion mode that is called Nesting. In this article we will present an overview of the new conversion mode Nesting and describe key differences between Plain and Nesting modes.

 

Conversion mode Plain

Conversion mode Plain was designed to process an SWF animation in a way that the converted animation looks exactly like the one you see in Flash Player. It allows designers and animators to work in Flash Pro the same way they always do and create rich and bright animations using familiar tools without limitations.

When is the Plain conversion mode useful?

The Plain conversion mode is useful when you just need to play back the animation and disregard the internal structure of the animation. The Plain mode is strongly recommended when you have Action Script 3 code that manages animation playback, and you want to get in GAF what you see in Flash Player.

How does the conversion work?

When converting an animation, GAF Converter plays an SWF file in Flash Player. It collects information about all Display Objects in the Display List when playing the animation frame by frame. As the result, you will get exactly the same animation that you see in Flash Player. Only animation parts, which are visible during playback in Flash Player, are included in a texture atlas.

Action Script 3

All Action Script 3 inside an SWF is executed during the conversion process and affects the result. You can apply Action Script 3 to control the animation playback starting from simple actions like stop(), gotoAndPlay(), etc. and up to complex code that fully creates and manages the whole animation. When using Action Script 3 be sure to avoid endless animations.

Starting from the version 4.3 GAF Converter saves the following set of Action Script 3 code into the GAF config file for further execution in runtime:

How does GAF Converter define animation’s end in mode Plain?

GAF Converter chooses a “Monitored Timeline” as a reference point for detecting the end of the animation. If the Main Timeline’s length is more than one frame, than the Main Timeline becomes the “Monitored Timeline”. If the Main Timeline is one frame long, GAF Converter analyzes the Display List of the first frame and finds the MovieClip with the longest Timeline. This MovieClip becomes the “Monitored Timeline”. GAF Converter stops conversion after the “Monitored Timeline” reaches the last frame.

It’s important to know that the length of a converted animation doesn’t always equal the length of the  “Monitored Timeline”. When analyzing the animation, GAF Converter plays it back via Flash Player. If there is an ActionScript 3 code managing the “Monitored Timeline” playback (stop() gotoAndStop() gotoAndPlay() or any other code written in ActionScript 3) this code will run too.

If the animation on the “Monitored timeline” does not reach the last frame in the maximum possible number of frames in the animation, GAF converter stops the conversion and shows warning "animation can't reach end". Maximum possible number of frames is 10000.

Structure of the converted animation compared to original SWF

During conversion in the conversion mode Plain animations are optimized and merged into a single Timeline. Visually you get the same animation, but internal structure is different from the original SWF file. It was done for playback optimization and because of technical reasons. This is important to know if you are going to have access to the animation parts for some reason.

Texture atlas

When creating a texture atlas, GAF Converter finds unique parts in an animation and bakes only them. It allows you to create the texture atlas with the smallest possible size.

Color effects and filters also can be baked into texture atlas if they are applied to static parts of the animation (Movie Clips without animations inside). This is the part of the optimization that allows decreasing the number of draw calls at playback.

The following rules are used in the process of baking graphics into texture atlas:

Note: the biggest scale is calculated taking into account the scales applied to all parent Movie Clips up to root.

 

Conversion mode Nesting

Conversion mode Nesting was designed to process an SWF animation in a way so that the converted animation has an internal structure similar to the original SWF animation. It allows developers and designers to use Flash Pro to create User Interfaces or create technically complex animations that can be managed by the game code more flexible than Plain animations.

When is the Nesting conversion mode useful?

The Nesting conversion mode is useful when you need to save internal nesting structure in the converted animation and to control nested timelines independently from each other. In this mode developer can use some limited set of Action Script 3 code, that will be saved during conversion in an animation config and will be executed during playback in runtime (see "Action Script 3" section for more info).

How does the conversion work?

In this mode GAF Converter collects information about all Display Objects in the Display List frame by frame in each Timeline separately. It doesn't play animations like in Plain mode. All Action Script 3 code is removed before conversion and doesn't impact on the conversion process. As the result you will get exactly the same internal nesting structure after conversion as you have in Flash Pro. All animation parts from all timelines are included into a texture atlas.

Action Script 3

All Action Script 3 code is removed before the conversion and doesn't impact on the conversion process. Only following set of Action Script 3 code is saved into GAF config file for further execution in runtime:

Note: the scope can be only "this". Otherwise the code will be ignored by GAF Converter. This means that you can not use syntax like this:

We will support scopes different from "this" in the next versions of GAF Converter.

Structure of the converted animation compared to the original SWF

During conversion in the conversion mode Nesting, internal structure, and nesting are saved. In the output GAF animation the internal structure will be the same as it is in Flash Pro.

There might be only one structural difference between the original SWF and GAF. During conversion in the Nesting mode, GAF Converter still tries to optimize the animation. And when GAF Converter finds the following conditions, it bakes Movie Clip into a texture atlas as a single region and doesn't save its internal structure:

Texture atlas

When creating a texture atlas in the Nesting conversion mode, GAF converter applies the same rules as for the Plain conversion mode. There is only one difference between those modes: in Nesting the biggest scale is calculated taking into account only the scale applied to the display object, scales applied to all parent Movie Clips are ignored. This is the technical limitation we will attempt to remove it in future versions.

Other features

You can create Dynamic Text Field in Flash Pro, give it Instance Name, convert SWF file in the Nesting conversion mode and have access to it as to Text Field. You can change the text in this Text Field or any other property provided by a framework in runtime.

 

Conclusion

GAF Converter was started as a solution for converting animations, created in Flash Pro, into an open GAF-format that is played in some popular frameworks. And we did the best solution possible making it fast, flexible, and easy to use. But we do understand that animations are just a part of the game visual components. There are plenty graphic elements in a User Interface as well. Developers need a complete solution to cover all game visual components.

That's why we’ve created the Nesting conversion mode. With this conversion mode, developers can use Flash Pro to create complete User Interfaces for games. It also enables creating technically complex animations that can be managed by the game code more flexible than Plain animations. Those two conversion modes in combination with other conversion settings allows developers to use Flash Pro + GAF as a complete toolset for creating an exhaustive set of visual components for the game.