7 Replies Latest reply on Jan 29, 2009 8:37 PM by Newsgroup_User

    Casting interface from MovieClip object.

    Someonewhere
      I've an MXML based SWF file that I load into another MXML-based SWF file. My "external" SWF I load implements an interface. I cannot seem to cast any of the internal objects to this interface. Any clues?

      I've done this with a non-MXML SWF I've created so I know it's possible. Just won't work with an MXML-based SWF.
        • 1. Re: Casting interface from MovieClip object.
          Level 7

          "Someonewhere" <webforumsuser@macromedia.com> wrote in message
          news:glcs8a$m4v$1@forums.macromedia.com...
          > I've an MXML based SWF file that I load into another MXML-based SWF file.
          > My
          > "external" SWF I load implements an interface. I cannot seem to cast any
          > of
          > the internal objects to this interface. Any clues?

          If the class file of the swf itself implements the interface, then that's
          what you'd be able to cast to it. In order for you to cast the internal
          objects to that interface, their class files would also need to implement
          it.

          HTH;

          Amy


          • 2. Re: Casting interface from MovieClip object.
            Someonewhere Level 1
            Let's say you do this:

            <mx:Application ...snip... implements="ISomeInterface" ></mx:Application>

            Now I load this successfully into another SWF running. Works great, draws it's images and all that. However, it's a MovieClip object. What property of the MovieClip do I use to do this:

            var obj:ISomeInterface = MovieClip.?? as ISomeInterface

            If I write an SWF using pure flash components, meaning not using any of the MX namespace classes, I can support an interface and get at it when loading it externally. HOWEVER, this type of SWF does not come across as a MovieClip but as a "DisplayObject" when loaded externally.
            • 3. Re: Casting interface from MovieClip object.
              Someonewhere Level 1
              Also, I only use the Loader or URLLoader classes and cast it to the appropriate object when I get it. For SWFs this is a chain of several objects from MovieClip to just a DisplayObject since the SWFs we load could be written in several different development environments and we need to be able to "Restart" them at a button press.

              And as anyone who has done this can tell you, it's a pain.
              • 4. Re: Casting interface from MovieClip object.
                Level 7

                "Someonewhere" <webforumsuser@macromedia.com> wrote in message
                news:gldf3q$esb$1@forums.macromedia.com...
                > Let's say you do this:
                >
                > <mx:Application ...snip... implements="ISomeInterface" ></mx:Application>
                >
                > Now I load this successfully into another SWF running. Works great, draws
                > it's images and all that. However, it's a MovieClip object. What
                > property of
                > the MovieClip do I use to do this:
                >
                > var obj:ISomeInterface = MovieClip.?? as ISomeInterface
                >
                > If I write an SWF using pure flash components, meaning not using any of
                > the MX
                > namespace classes, I can support an interface and get at it when loading
                > it
                > externally. HOWEVER, this type of SWF does not come across as a MovieClip
                > but
                > as a "DisplayObject" when loaded externally.

                I'm up to my eyeballs in teaching myself how to write a Flash Component, but
                I'll try to make time to make an example of this for you next week. Post
                back if you get it solved and I don't have to :-)


                • 5. Re: Casting interface from MovieClip object.
                  Someonewhere Level 1
                  It's the whole MovieClip thing. At this point I've ported the SWF to not use the MX components. Honestly, a good thing, considering the SWF bloat that MX adds.

                  Also, the CPU load was cut in half by not utilizing MX componenets.

                  Honestly, I should have never used MX for this.

                  I still would like to know how to get an interface pointer from a MovieClip.
                  • 6. Re: Casting interface from MovieClip object.
                    Someonewhere Level 1
                    Oh, and the non-MX SWF casts to my interface, obviously. :P
                    • 7. Re: Casting interface from MovieClip object.
                      Level 7

                      "Amy Blankenship" <amySpamFilter@magnolia_pleaseNOspam_multimedia.com> wrote
                      in message news:gldkk4$l41$1@forums.macromedia.com...
                      >
                      > "Someonewhere" <webforumsuser@macromedia.com> wrote in message
                      > news:gldf3q$esb$1@forums.macromedia.com...
                      >> Let's say you do this:
                      >>
                      >> <mx:Application ...snip... implements="ISomeInterface"
                      >> ></mx:Application>
                      >>
                      >> Now I load this successfully into another SWF running. Works great,
                      >> draws
                      >> it's images and all that. However, it's a MovieClip object. What
                      >> property of
                      >> the MovieClip do I use to do this:
                      >>
                      >> var obj:ISomeInterface = MovieClip.?? as ISomeInterface
                      >>
                      >> If I write an SWF using pure flash components, meaning not using any of
                      >> the MX
                      >> namespace classes, I can support an interface and get at it when loading
                      >> it
                      >> externally. HOWEVER, this type of SWF does not come across as a
                      >> MovieClip but
                      >> as a "DisplayObject" when loaded externally.
                      >
                      > I'm up to my eyeballs in teaching myself how to write a Flash Component,
                      > but I'll try to make time to make an example of this for you next week.
                      > Post back if you get it solved and I don't have to :-)

                      I've posted the example:
                      http://flexdiary.blogspot.com/2009/01/example-of-casting-contets-of-swfloader.html

                      HTH;

                      Amy