A best practice is to maintain backward compatibility in
your extension’s ActionScript public interfaces. Continue to support
the extension’s classes, methods, properties, and events in all
subsequent versions of the extension.
Device-bundled extensions have a more complex issue with regard
to backward compatibility. Sometimes, the
behavior
of an
extension is different between versions of an extension. For example,
a particular method returns a value with a new meaning in a new
version of the extension. When this behavior occurs for device-bundled
extensions, an application can stop working correctly. This problem
can occur if the application was built with a version of the extension
that behaves differently than the version of the extension installed
on the device. In this case, the application expects one behavior,
but the installed extension provides a different behavior.
In such cases, the extension installed on the device can determine
how to proceed. The extension can do the following:
-
Look up the extension version that the AIR application
was built with as well as the version installed on the device.
-
Determine whether the extension’s behavior is different in
the two versions.
-
If the AIR application was built with an older version of
the extension, revert to the older version’s behavior.
To look up the extension version number that the application
was built with, do the following:
-
Get the application installation directory using
File.applicationDirectory
.
-
Use the File class APIs to access the extension.xml file
of the extension that the application built against. The file is
at:
<application directory>/META-INF/AIR/extensions/<extensionID>/META-INF/ANE/extension.xml
-
Read the contents of the extension.xml file and find the
value of the
<versionNumber>
element.
To look up the installed extension’s version number, do the following:
-
Use the static method
ExtensionContext.getExtensionDirectory()
to
get the base directory for the extension.
-
Use the File class APIs to access the extension.xml file
of the extension installed on the device. The file is at:
<extension base directory>/META-INF/ANE/extension.xml
-
Read the contents of the extension.xml file and find the
value of the
<versionNumber>
element.