6 Replies Latest reply on Aug 1, 2006 7:06 AM by buabco

    MXML and Custom Display Classes

    buabco Level 1
      Hi!

      I've made a simple class called "pru" that extends Sprite and basically has 1 property that's call content that you can set with and embed object (Lets say an image).

      When I do this MXML code it works fine and I end up having a SWF that actually displays de image:
      <?xml version="1.0" encoding="utf-8"?>
      <fl:pru content="@Embed(source='assets/powered_by.swf')" xmlns:fl = "test.*"/>

      But if I try to include my class widthin another display class I don't get the image, more so, this swf file sends you to an URL when you click it and this actually works on the ENDING UP SWF even though I can't see the image.

      I'm using this mxml code:
      <?xml version="1.0" encoding="utf-8"?>
      <dis:MovieClip xmlns:dis= "flash.display.*">
      <fl:pru content="@Embed(source='assets/powered_by.swf')" xmlns:fl = "test.*"/>
      </dis:MovieClip>

      I've been scratching my head for a While now... so please someone tell me What I'm MISSING!!!

        • 1. Re: MXML and Custom Display Classes
          jrunrandy Adobe Employee
          I'm not sure (since your class is working in some circumstances), but you may need to extend UIComponent instead of Sprite. This page may have the information you need: http://livedocs.macromedia.com/flex/2/docs/00001705.html

          HTH
          • 2. Re: MXML and Custom Display Classes
            buabco Level 1
            Thanks for the reply, I've already read that document, my problem is that extending any UIComponent implies addding all the FLEX framework to the SWF movie and thats about 100 kb. Since what I'm trying to do is a very simple movie, I thought that this is to much.

            Thats why I desided to extend Sprite and MovieClip isntead, redusing the size to 6 kb. But it seems that mxml doesn't seem to handle well other classes that are not part of the FLEX framework. I haven't been able to find any documentation on doing movies without using FLEX framework.
            • 3. Re: MXML and Custom Display Classes
              jrunrandy Adobe Employee
              The Display Programming chapter of Programming AS 3.0 may have what you want. Also, you can get the accompanying files here.
              • 4. Re: MXML and Custom Display Classes
                buabco Level 1
                thanks, but here comes the strange part, I've watch the examples you indicated and they where all using the application object and exteding UIComponente, none of them where meant to make a light weight application that extends de Sprite or MovieClip object.

                The document you mention is quite clear on how to programatically add elements to the display list, which I've been successfull to add, but none of the explain why the MXML code I posted in the beginning doesn't work... I'm starting to think the mxml compiler can only compile elements from de FELX namespace and can't handle correctly elements from other namespaces.
                • 5. Re: MXML and Custom Display Classes
                  Level 7
                  Hi,

                  You should have gotten a compiler error when you added pru as a child of
                  MovieClip because MovieClip is not a container and doesn't take
                  components as children.

                  You can create components that are a subclass of Sprite, but you won't
                  be able to add effects and animate them in mxml.

                  winsha

                  buabco wrote:
                  > thanks, but here comes the strange part, I've watch the examples you indicated
                  > and they where all using the application object and exteding UIComponente, none
                  > of them where meant to make a light weight application that extends de Sprite
                  > or MovieClip object.
                  >
                  > The document you mention is quite clear on how to programatically add elements
                  > to the display list, which I've been successfull to add, but none of the
                  > explain why the MXML code I posted in the beginning doesn't work... I'm
                  > starting to think the mxml compiler can only compile elements from de FELX
                  > namespace and can't handle correctly elements from other namespaces.
                  >
                  • 6. Re: MXML and Custom Display Classes
                    buabco Level 1
                    Winsha,

                    Thanks for your reply, things are starting to be a lot more clear now... I didn't got a compilation error though :)

                    Just to clear this isue up, and to be sure that I actually understand it:

                    The mxml tree is NOT the same as the display tree, this means that by adding childNodes into the mxml tag I'm not adding them into the display tree of that specific Class.

                    This is only true to the classes that are subclasses of the MX Contariner component, which has the code necesary to handle de mxml tree... I think I was able to find some information on this under the COMPONENT DESCRIPTOR topic on the documentation files, even though is a bit hard to understand.