11 Replies Latest reply on May 30, 2008 2:50 AM by slaingod

    MovieClip ignores commands

    smokinjoefission
      Hi All,

      I'm having the most bloody frustrating time with what seems (according to the documentation) a simple task:

      I'm embedding a flash swf file created in Flash CS3. I'm trying with a simple two-frame timeline, and have tried various ways (setting the source of an image object to the embedded swf file's content, creating a new movie clip from the content, etc) and can't even get a simple .gotoAndStop(1) command to work. The movie clip ignores everything and keeps looping.

      Here's the current failing code:

      In my mxml:
      [Embed(source='/assets/twoFrameTest.swf')]
      [Bindable]
      public var test:Class;

      in my actionscript:

      public var mc:MovieClip;
      mc = new test();
      var ui:UIComponent = new UIComponent();
      ui.addChild(mc);
      this.addChild(ui);

      this works fine, it then displays the movieclip in its continuous loop.

      mc.stop(); /* fails */
      mc.gotoAndStop(1); /* fails */

      I have tried both flash 8 and flash 9 formats. I've tried all sorts of settings with 'export for actionscript' for the symbols in the flash source file.
      The embedded movie clip honors AS3 code in the source file (ex: stop(); on frame 1 stops it from looping in the flex application).

      I've tried loading the swf file with SWFLoader - same results.

      I'm ripping my hair out over this one, and I can't afford any more hair loss!

      Any advice would be greatly appreciated,

      Thanks
        • 1. Re: MovieClip ignores commands
          slaingod Level 1
          You may have indicated this in your post above, but just to be specific, you must export your SWF as AS3 specifically in the Export dialog, to get that stuff to work in Flex.

          Many times you can just set your swf to an Image source="" then use my_image.content.gotoAndPlay(2) etc.

          It may also make a difference which object in your swf you are in... Ie. mc.gotoAndPlay() would stop the stage layer, but might not stop a nested timeline.
          • 2. Re: MovieClip ignores commands
            smokinjoefission Level 1
            Thanks for the tips, Slaingod, but it's still not working.

            I've selected every symbol in library and ensured that 'export for actionscript' is checked.

            I've tried the File->Export->Export Movie option (there's no mention of an actionscript setting in the dialogue box that appears)

            My latest attempt was using the 'Class method' of importing a SWF file:

            [Embed(source='/assets/Two_Frame_Test.swf')]
            [Bindable]
            public var test:Class;

            myTest = new test();
            var ui:UIComponent = new UIComponent();
            ui.addChild(myTest );
            this.addChild(ui);
            myTest .gotoAndStop(1);

            with the same results: the swf is placed in the application and just keeps looping infinitely.

            The images on each frame are movieclips (I've read that only movieclips and buttons can be used), but have no time line, they're just composites of other movieclips.

            Getting properties of the newly created SWF file shows nothing. IE: myTest.scenes.name is null, and frames shows up as 0 (even though it's a 2 frame swf)

            Any other ideas?

            Thanks in advance...
            • 3. Re: MovieClip ignores commands
              smokinjoefission Level 1
              Further testing:

              I created another two frame swf file without any library items. One with a simple red square, one with a blue square, with the same results.
              • 4. Re: MovieClip ignores commands
                smokinjoefission Level 1
                Has this got everyone else stumped too? Can anyone else duplicate this problem?
                • 5. MovieClip ignores commands
                  VarioPegged Level 2
                  See if this approach works for you. As was mentioned previously, make sure you're publishing to a Flash 9 file (AS3) in the publish settings of the FLA file.

                  TS
                  • 6. Re: MovieClip ignores commands
                    smokinjoefission Level 1
                    Yes!

                    Once I adjusted the source to have a leading . (source="./assets ...) it worked. Without the leading period, I'd get a broken image icon.

                    However, the stop/start commands don't work if I embed the SWF file in the Flex application. Is this a bug or am I still not getting it?

                    I'd rather not have to load all the assets from a remote source if I can get away with it.

                    Thanks
                    • 7. Re: MovieClip ignores commands
                      VarioPegged Level 2
                      I haven't tried an embedded SWF yet. I'll let you know what I find.

                      Note that my quick 'n dirty example really should have some form of complete/error handler for the SWFLoader if you decide to go that route.

                      TS
                      • 8. Re: MovieClip ignores commands
                        VarioPegged Level 2
                        I get exactly what you're getting: no control with the embedded SWF. Here's why trying to control the embedded SWF from the embedding app doesn't work ... from the docs:

                        "Note: You cannot access the properties or methods of embedded SWF files directly. You can, however, use LocalConnection to allow them to communicate."

                        I know I've read this for Flash 8 SWFs, but apparently this is true for EMBEDDED Flash 9 SWFs as well.

                        Never had a need to use LocalConnection, but the docs seem pretty thorough on that. Seems like it's a lot of trouble to control your embedded SWF though.

                        TS
                        • 9. Re: MovieClip ignores commands
                          smokinjoefission Level 1
                          Thank you for all your help VarioPegged; I've seen that mentioned for Flash 8 as well, and loathe to go down that road ...

                          For this 'limitation' with Flash 9 SWFs: should I file that under 'bug' or 'undocumented feature'? ;-)
                          • 10. Re: MovieClip ignores commands
                            VarioPegged Level 2
                            There is a viable workaround for this. See slaingod's solution in this post.

                            I do wish that Adobe would update the docs to reflect that an octet-stream embedded SWF can indeed be controlled by the embedding Flex app.

                            TS
                            • 11. Re: MovieClip ignores commands
                              slaingod Level 1
                              Yea, sorry I didn't publish that here originally. :)