8 Replies Latest reply on Dec 22, 2007 6:04 PM by Shelady

    Link A Button to a .swf File

    Shelady
      Hi,
      I made a button "Movie1" and I want to start a .swf file on the same page when I click this button.
      How do I link this button to the movie file named "myMovie:".
      Thanks
        • 1. Re: Link A Button to a .swf File
          peterent Level 2
          You'll need to set aside space in your Flex app to display the movie. Use <mx:SWFLoader id="mymovie" width="..." height="..." />

          Then your button can load it:
          <mx:Button label="Show Movie" click="mymovie.load('MyMovie.swf')" />
          • 2. Re: Link A Button to a .swf File
            Shelady Level 1
            Dear Sir,

            Thanks for your reply. I did exactly as you directed but the movie is loading itself and not waiting for me to click the button. I want it to play only when I click the button.

            Any other suggestions!!!

            Thanks anyways
            • 3. Re: Link A Button to a .swf File
              Shelady Level 1
              Can you tell me how can I do it with the help of Action Script 3.

              I am trying to do something like this.

              <mx:Button height=" " weidth=" " click="onClick(event)'/>

              <mx:Script>
              <![CDATA

              private function onClick(event:MouseEvent):vovid

              { load("myMovie.swf") }

              This last line is my problem. Please advice.

              Thanks
              and then defining the onClick function in AS3. This part I am not sure how to use proper .load function
              • 4. Re: Link A Button to a .swf File
                peterent Level 2
                It isn't possible for the movie to load itself if you don't give the SWFLoader the filename until the button is clicked:

                <mx:Application ... >
                <mx:SWFLoader id="loader" width="300" height="300" />
                <mx:Button label="Load movie">
                <mx:click>
                loader.load( "MyMovie.swf" );
                </mx:click>
                </mx:Button>
                </mx:Application>
                • 5. Re: Link A Button to a .swf File
                  Shelady Level 1
                  Dear Sir,

                  Thank you so much. Because of you I could load the movie successfully. Can you please help me out in one more thing? I have 3 movies and have 3 buttons and I want to assign different buttons to the different movies. I want when I click a button it should start a different movie on the same page on the same place. How do I achieve it?

                  Again thank you so much for your help.

                  She
                  • 6. Re: Link A Button to a .swf File
                    Shelady Level 1
                    I have written this code in the application but only first movie is working with the button. Button 2 and 3 are visible but are not loading their movies.

                    <?xml version="1.0" encoding="utf-8"?>
                    <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
                    <mx:SWFLoader id="loader" width="800" height="1028" />
                    <mx:Button label="Load movie" x="850" y="100">
                    <mx:click>
                    loader.load( "myMovie.swf" );
                    </mx:click>
                    </mx:Button>
                    <mx:Button label="Load movie 2" x="850" y="200">
                    <mx:click>
                    loader.load( "myMovie2.swf" );
                    </mx:click>
                    </mx:Button>
                    <mx:Button label="Load movie 2" x="850" y="300">
                    <mx:click>
                    loader.load( "myMovie3.swf" );
                    </mx:click>
                    </mx:Button>
                    </mx:Application>
                    • 7. Re: Link A Button to a .swf File
                      peterent Level 2
                      I don't see anything wrong with your code. Have you tried loading one of the other movies before the first?
                      • 8. Re: Link A Button to a .swf File
                        Shelady Level 1
                        Thank you Sir,

                        I achieved the target because of you.

                        Thanks.