Previous | Next | |
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.
8.3.1.1 Document-Oriented Configuration Options
- kinesis.xml.outputBOM
- Should KineticFusion write a UTF-8 Byte-Order Mark (BOM) to the start of each RVML document?
- kinesis.xml.outputUTFComment
- Should KineticFusion write a UTF-8 single character comment after the XML declaration in output RVML documents?
- kinesis.xml.unicodeEntities
- Should Unicode characters in text or attribute values be stored as unicode entities or as their natural representation?
- kinesis.xml.outputValidatingXML
- Should an XML DOCTYPE declarion with a reference to the DTD be added after the XML declaration?
- kinesis.xml.dtdLocation
- Specifies the SYSTEM ID location of the DTD that is used in the DOCTYPE declaration
- kinesis.actionscipt.unicodeConstants
- Should Unicode constants be used to represent non-ASCII character strings inside ActionScript blocks
8.3.1.2 RVML-Oriented Configuration Options
- kinesis.xml.outputFontDefinitions
- Should embedded fonts be output as RVML
- kinesis.xml.colorFormat
- Specifies the format in which all colors should be output
- kinesis.components.resolve
- Specifies whether component symbols should be resolved and removed from the output RVML
- kinesis.actionscript.resolveSWFClasses
- Specified whether ActionScript should be interpreted as ActionScript 2.0 where possible.
8.3.2 Storing Resources
8.3.2.1 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:
- KineticFusion will determine the base repository directory by first checking the kinesis.repository.isRelative property.
- If this property is not set to true all repositories will be created under the directory identified by the property kinesis.repository.directory. On installation, this location is defined as the installation projects folder. If this property is not defined, the base repository is set to the home directory of the user.
- If the property kinesis.repository.isRelative is true, the repository is located relative to the output RVML file. If there are many decompiled RVML files documents in this folder then a developer may not wish to have all repository folders created at the same directory level. For relative repositories, KineticFusion will check the property kinesis.repository.relativePrefix that, if defined, specifies an additional subdirectory under the current directory to be used as the repository base directory.
To illustrate, with an SWF movie called being output to an RVML file called /rvml/myMovie.rvml:
When:
kinesis.repository.isRelative=false
kinesis.repository.directory=/data
kinesis/repository.relativePrefix=repository
The repository is created in /data/myMovieResources
When:
kinesis.repository.isRelative=true
kinesis.repository.directory=/data
kinesis/repository.relativePrefix=repository
The repository is created in /rvml/repository/myMovieResources
When:
Kinesis.repository.isRelative=true
Kinesis.repository.directory=/data
Kinesis/repository.relativePrefix=
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.
8.3.3.1 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:
kinesis.actionscript.resolveSWFClasses=false
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.
8.3.3.2 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.
8.3.3.2.1 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:
- kinesis.actionscript.storeDuplicateUserClasses - store decompiled classes that already exist on the user class path
- kinesis.actionscript.storeDuplicateSystemClasses - store decompiled classes that already exist on the system class path
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.
Previous | Next |
Copyright 2003-2005 Kinesis Software. All rights reserved.