views:

138

answers:

3

I recently found a method (ByteArray.clear()) that FlexBuilder complains is possibly undefined; however, the method is in fact documented in the Flex LiveDocs. It must have been added in a later version of the SDK than I have installed. I'm not asking about this particular method, but I'm giving it as an example of the documentation issue that I'm trying to resolve. My questions are:

  1. How can I determine what version of the SDK or Flash player that a method or property was added in?
  2. How can I tell which versions of the SDK are supported on which Flash player versions?

I want to be able to determine from the documentation, instead of compiler or runtime errors, what SDK and Flash player versions are needed to support newly added methods.

With Java I look for the @since javadoc tag when I need to know this, but I can't find an equivalent feature in the Flex docs.

A: 

ByteArray is a Flash Player class, not a Flex class. The Flash Player APIs are implemented in the runtime so they are tied to specific releases of Flash Player. Usually the ASDoc specifies when an API was added. But in this case it seems that it doesn't. So here are a few things to try:

  1. Get around the compiler error (might result in a runtime error if you are using a version of FP that doesn't have the clear method): byteArray['clear']()
  2. Change the version of FP used in Flex to 10 to see if maybe this was added in FP 10 and for some reason that wasn't specified in the ASDoc.
  3. Flex uses a playerglobal.swc file as stubs for the FP APIs. It's possible that SWC doesn't include something it should. In which case you should file a bug.
James Ward
Thanks for the helpful workaround information for ByteArray. I've edited my question to make clearer that my focus is on finding the right documentation. Also, thanks for pointing out that I need to know both Flash Player and SDK version information, which I've also added to the question.
Kevin Condon
Cool. I don't know of a good way to discover this stuff other than looking through the open source Flex SDK's SVN. Maybe this is a good feature request to file?
James Ward
+1  A: 

Often, the documentation will say that a given property is available as of Flashplayer version x.y.z Unfortunately, even though you may be looking at the documentation, and the documentation may CLAIM that a function exists (and in the case of the ByteArray most certainly does exist), sometimes the compiler is just buggy and throws a hissy-fit.

Your best bet is to make sure that you have the most recent version of the Flex dev. kit and make sure you are publishing for the most recent major release ( Flash >= 10 ). That being done, rely on the documentation here: http://livedocs.adobe.com/flex/3/langref/index.html.

After that it is the "cross your fingers and pray" method. Sorry.

Christopher W. Allen-Poole
The problem is that the documentation *doesn't* say it's available as of a particular version. And publishing for the latest version of Flash isn't an option when you're required to support older versions (9 in this case).
Herms
I'm having a difficult time finding an example, but I know that I've seen some properties which existed in 10.2 which were not there in 10.1.My general statement still holds, you're really going to have to use the "I hope" method. But, if you want it, the Flash player 9 documentation is here: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/ A manual comparisson won't necessarily make your task easy, but it might at least make things a bit less annoying.
Christopher W. Allen-Poole
Hadn't thought to look at the Flash 9 docs. Looking at ByteArray from the Flash 9 docs it does *not* have the clear() method.
Herms
Thanks for the link to the old docs. That does confirm that the ByteArray.clear() method isn't supported with Flash Player 9. More significantly it also seems to indicate that there isn't any convention in the documentation to outright tell you when a something was added to a class or what version is required for its use.
Kevin Condon
A: 

Based on what James suggested you could use this code:

        try
        {
            // Use the clear method if the flash player supports it (10+)
            this.swf['clear']();
        }
        catch (e:Error)
        {
            // Must be flash player 9 or lower so free the variable
            this.swf = new ByteArray();
        }

There may be a better way to clear/free a ByteArray's memory in older player versions, so let me know if there are.

robmcm
The question isn't about the clear() method, it's a general documentation question: "I want to be able to determine from the documentation, instead of compiler or runtime errors, what SDK and Flash player versions are needed to support newly added methods."
Kevin Condon