8 Replies Latest reply on Jun 24, 2009 10:33 AM by Paul Reilly

    Custom Metadata

    si-robertson Level 1

      Hi guys,


      I have noticed custom class metadata is now preserved in Flash Builder 4 and I was wondering which tech update introduced that - Flash Player 10 or the Flex 4 SDK?




      PS: Flash Builder 4 is fantastic. Great work Adoblings.

        • 1. Re: Custom Metadata
          CoreyRLucier Adobe Employee

          It would most certainly be the SDK but all custom metadata should still eventually be stripped when link your resulting SWF (unless you explicitly utilize the -keep-as3-metadata flag).




          Corey Lucier

          1 person found this helpful
          • 2. Re: Custom Metadata
            si-robertson Level 1

            Thanks for the reply Corey,


            The thing is I'm not sure if the -keep-as3-metadata parameter is actually required when using the Flex 4 SDK. To test things out I created a Flex Library project, dropped a class into it and added a custom metadata tag to the class. I then created a Flex Project (AIR) and copied the test Flex Library SWC file into the Flex Project libs directory, and just to ensure the Flex Project wasn't referencing the Flex Library project in any way I closed the Flex Library project. I then imported the test class from the SWC into the Flex Project, ran the describeType() function on the class, and then traced the XML data - the custom metadata tag was described in the XML data.


            So, unless I've missed something, it seems the -keep-as3-metadata parameter is no longer needed. I would like one of the Flex devs to confirm this though if possible, I don't want to start taking advantage of custom metadata tags when using the Flex 4 SDK if things are likely to change before the SDK is officially released.

            • 3. Re: Custom Metadata
              CoreyRLucier Adobe Employee

              I verified your findings...to the best of my knowledge it should actually not work this way be default, but still unsure of the recent change that may have enabled this.  We do make use of custom metadata in Flex 4 and kinda rely on the fact that the metadata is compiled out.


              Interestingly enough when I do a full release build of my SWF, the metadata is in fact compiled out.


              I will consult with the compiler folks shortly and clarify why the metadata is being persisted in debug SWFs.  But I am confident you can't rely on it persisting unless you use -keep-as3-metadata.



              • 4. Re: Custom Metadata
                si-robertson Level 1

                Ah, I didn't test a release build, only a debug build. Good catch.


                I will assume this is just a temporary beta glitch and continue to the use -keep-as3-metadata option.

                • 5. Re: Custom Metadata
                  si-robertson Level 1

                  Sorry to bother you again, a question has just popped into my head related to custom metadata:


                  Is it possible to modify the Flex SDK (a personal modification) in order to handle custom metadata tags? In other words, if I wanted to use the following metadata tags to embed files would it be possible for me to modify the SDK to get this working?



                      // embeds the file as a BitmapData class

                      [CustomTag( file="/assets/image.png" )]


                      // embeds the file as a Sound class

                      [CustomTag( file="/assets/sound.mp3" )]


                      // embeds the file as a Sound class, uses LAME for the MP3 encoding

                      [CustomTag( file="/assets/sound.wav", encodingOptions="..." )]



                  If this is possible where should I start researching?


                  FYI: This would be for projects that did not use MXML or Flex components etc.

                  • 6. Re: Custom Metadata
                    Paul Reilly Level 1

                    This sounds alot like [Embed], which should work in .as files and which shouldn't require any Flex components.  Just curious, how is your CustomTag different?

                    • 7. Re: Custom Metadata
                      si-robertson Level 1

                      It would indeed be similar to the Embed metadata tag, the difference would be the base classes the generated classes extended and, in some cases, the way certain file types were dealt with [encoded]. I don't really use MXML or the Flex components so I would like to be able to embed assets without relying on the mx asset classes [I tend to strip everything out of the SDK library path except for the airglobal and playerglobal libraries] although that isn't the main reason I would like to know if this is possible.


                      Being able to deal with custom metadata tags at compile-time would certainly open the doors for a lot of cool development tricks. I'm pretty sure this is possible seeing as the SDK is open source, I'm just not sure which source files I should be looking at.

                      • 8. Re: Custom Metadata
                        Paul Reilly Level 1

                        The method, getAssociatedClass(), in
                        flex2.compiler.media.AbstractTranscoder handles mapping each
                        DefineTag to a particular base class.  You could locally modify
                        this method to map to different base classes.


                        There is a new compiler extension mechanism in trunk, but I think
                        it would be very difficult to use it to implement something like
                        [Embed], because flex2.compiler.as3.EmbedExtension not only
                        handles the transcoding, it modifies the syntax tree to assign
                        the generated class to the variable with [Embed] metadata.  The
                        new compiler extension mechanism is geared more towards
                        preprocessing and postprocessing.  We would need to expose adding
                        custom flex2.compiler.as3.Extension implementations to the
                        various subcompilers.  Feel free to log a compiler enhancement
                        request for that.