Kinesis SoftwareKineticFusion

[Show Table of Contents]

8 Working With RVML Documents

[Hide Table of Contents]

8.3 Creating RVML From Existing SWF Movies

The simplest and perhaps most common way of creating RVML documents is by converting an existing SWF movie to RVML.

8.3.1 The RVML File

RVML documents are produced by decompiling SWF movies and KineticFusion will automatically store RVML documents as files on your computer. When decompiling from the GUI, the output file can be determined automatically be selected the 'Decompile SWF' option, or the output folder and/or file name can be explicitly specified by selecting the 'Decompile SWF To...' and 'Decompile SWF To Folder..' menu options.

When decompiling from the command line, an output file or folder can be specified using the '-o' option.

RVML documents are always in UTF-8 format.

There are several configuration options that determine what goes into the output RVML document and the format of the file. Document-Oriented Configuration Options

Should KineticFusion write a UTF-8 Byte-Order Mark (BOM) to the start of each RVML document?
Should KineticFusion write a UTF-8 single character comment after the XML declaration in output RVML documents?
Should Unicode characters in text or attribute values be stored as unicode entities or as their natural representation?
Should an XML DOCTYPE declarion with a reference to the DTD be added after the XML declaration?
Specifies the SYSTEM ID location of the DTD that is used in the DOCTYPE declaration
Should Unicode constants be used to represent non-ASCII character strings inside ActionScript blocks RVML-Oriented Configuration Options

Should embedded fonts be output as RVML
Specifies the format in which all colors should be output
Specifies whether component symbols should be resolved and removed from the output RVML
Specified whether ActionScript should be interpreted as ActionScript 2.0 where possible.

8.3.2 Storing Resources Default Resource Repository

KineticFusion will always use the File Repository type when decompiling existing SWF movies. KineticFusion first determines the location of the base repository folder. This is the folder under which the repositories for all decompiled SWF movies are located. It will then create a resource repository with the name of the output RVML file being decompiled and a suffix of Resources e.g. the resource for an SWF movie decompiled to an RVML document called myMovie.rvml will be stored in a repository folder called myMovieResources under the repository base directory.

The mechanism for locating the base directory takes into account several factors that can be modified by the developer:

To illustrate, with an SWF movie called being output to an RVML file called /rvml/myMovie.rvml:



The repository is created in /data/myMovieResources



The repository is created in /rvml/repository/myMovieResources



The repository is created in /rvml/myMovieResources

The KineticFusion Server Edition also permits developers to define their own storage handlers for reading and writing resources. See the documentation on the Server Component for more information.

We have no recommendation on the type of base repository location you use. The advantages of keeping all the resources for all your movies under the same directory include ease of versioning and management of resources. However, it often makes more sense to keep resources close to the movie with which they are associated, especially if there are multiple movies with the same name which would otherwise get mapped to the same repository when using a global repository location.

When selecting a repository type to use within an RVML document you should keep in mind the overheads of managing the resources and the RVML that is used to locate them. Using absolute files or URLs are useful when resources are known to reside in a single location and moving them to a relative location would result in unnecessary duplication. Additionally, it is easy for multiple RVML documents to refer to the same resource. However, it also becomes difficult to determine which RVML documents need to be modified when a resource is changed or removed.

8.3.3 Decompiling ActionScript

KineticFusion can convert existing SWF movies to RVML. Part of this process involves reassembling the compiled scripts within the SWF to recreate the high-level ActionScript that formed the origin source code. This is a complex process and is based on code generation patterns from all the major ActionScript compilers available. Where code has been manually optimized or deliberately obfuscated then the decompilation process will not succeed. Decompile as ActionScript 1.0

Significant changes were introduced in development paradigms with ActionScript? 2.0 (AS2.0) however the ActionScript support in the SWF format was not significantly changed to support these enhancements. Instead, ActionScript compilers use AS2.0 features for compile-time semantic checking but the compilers compile the classes as AS1.0. In fact, there are currently only three new features in Flash 7 Player that do not have a direct correspondence in AS1.0 and these are decompiled as KineticFusion synthetic functions ( See the section on Synthetic functions for more information).

Consequently, regardless whether the original SWF was created using AS1.0 or AS2.0 syntax, all ActionScript can be represented in KineticFusion as AS1.0. AS1.0 representation can be selected from the GUI? using the 'Run-> Decompile SWF as ActionScript 1.0' menu option or by setting the global configuration property:


When decompiling as AS1.0, the user will see the exact implementation of all classes and code blocks without any interpretation by KineticFusion. This is the most basic representation of ActionScript within an SWF and good place to start look for problems. All AS1.0 code is inlined inside action elements within the RVML document and this can make the RVML document appear quite large.

KineticFusion will recompile an RVML document containing either AS1.0 or AS2.0 without any change in the functionality of the original SWF. Extracting ActionScript 2.0 Classes

The default behavior for KineticFusion is to check all input SWF movies to see if they contain ActionScript 2.0 classes. As all AS2.0 classes can be represented as ActionScript 1.0, this process make assumption about what the representation and symbol names of the classes, following the implementation representation of Macromedia Flash.

All identified classes with an SWF are firstly converted to AS1.0 action blocks. The class structure is extracted and the representation is optimized to induce the existence of fields, getter/setter methods and to simplify references. When this process has been applied to all classes the classes are stores to a classes folder in the local resource repository, the classes and associated symbols are removed from the movie and the location of the classes in stored in the output RVML document. Excluding Known Classes

While KineticFusion can decompile classes to an external format, there is still certain information in the original classes that will not be retained such as comments, metadata and type information. Where the user already has the source code for these classes available on the KineticFusion ActionScript class paths, KineticFusion can discard the SWF classes. This features is controlled by two configuration options:

When either of these options is set to 'false' (they are both set to 'false' by default) then any decompiled classes with the same qualified name that exist on the corresponding class path are discarded. When the RVML is recompiled, the classes on the class path will be used automatically.

8.3.4 Decompiling SWC components

When the kinesis.components.resolve property is enabled, all SWFs are scanned for components on decompilation. The current component path is used to define all available components.

When a valid component is found within an SWF, all the symbols and classes associated with that component are removed from the SWF and discarded. In their place, a new Component element is added to the output RVML with the name of the discovered component.

Frequently SWC components contain other components - for example, the Flash V2 Menu component has the Flash V2 Button component embedded within it. In this case, while both the Menu component and the Button component will be identified as being in the SWF, only the Menu component will be identified in the output as the Button component is included implicitly.