7 Replies Latest reply on Jun 14, 2006 6:56 AM by JeffreyGong

    can't get embedded swf to work

    teh_pako
      I'm trying to get this swf file embedded in flex to work, but it doens't... the swf is a video clip with the control bar, but all i can see the is the control bar and nothing ever happens... i've tried to use the mx:Image and mx:SWFLoader tags, but i always have the same results. Here's the code I'm using:

      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Script>
      <![CDATA[
      [Embed(source="assets/ezsmVid.swf")]
      [Bindable]
      public var imgCls:Class;
      ]]>
      </mx:Script>
      <mx:SWFLoader id="myLoader" width="390" height="240"
      source="{imgCls}"/>
      </mx:Application>
        • 1. Re: can't get embedded swf to work
          ur_dtrain Level 1
          A few things. One, I'm not sure if you can have the [Bindable] meta tag in between the [Embed] and the class statements (I'd put it before). Two, if the swf is generated by Flash, then the video component will not be compatible (AS 2 code underlying these components will not run under AS3 engine). And lastly, when embeding an object in this way, you need to create an instance of it.

          Add a creationComplete="initApp()" to your application tag

          public var mySwf:imgCls;
          public function initApp():void{
          mySwf = new imgCls();
          }
          • 2. Re: can't get embedded swf to work
            teh_pako Level 1
            i see... even though i didn't use the video component from flash, i believe it deons't make any difference since it's still AS 2.0... but, would it work if i make it in AS3.0?... i guess the only problem with that is that i wouldn't be able to test it in flash or something...

            I got a little confused with the last part of the code... could you explain a little more detailed?... thanks.
            • 3. Re: can't get embedded swf to work
              ur_dtrain Level 1
              The Embed code just makes the class available, You actually have to create an instance of the class to utilize it.
              • 4. Re: can't get embedded swf to work
                teh_pako Level 1
                ah ok... well for some reason it's giving me this error:
                "Metadata requires an associated definition"
                I'm really not sure what that means, since it's not indicating an error on the code
                • 5. Re: can't get embedded swf to work
                  ntsiii Level 3
                  You should be able to use the SWFLoader tag in place of the AS code Darin showed.

                  Tracy
                  • 6. Re: can't get embedded swf to work
                    teh_pako Level 1
                    Well the thing is that, when i use the SWFLoader i can see that my swf file is there, but it doens't do anything. I can click on the buttons of the control bar and it deosn't play, the same thing happened with my initial code from my first post... the only thing i can think of is that my AS is obsolete in Flex... so, i really don't know how to make this work... I haven't seen any examples or tutorials on this, and the help from Flex is really vague and their code deosn't work either, since it's the code from my initial post.
                    • 7. Re: can't get embedded swf to work
                      JeffreyGong Level 1
                      Hi teh_pako,

                      You may take advantage of Flex2 component <mx:VideoDisplay /> without using any Flash video clip.

                      Jeffrey