5 Replies Latest reply on Oct 7, 2011 7:56 PM by Ned Murphy

    How do you add a link to a .swf file?

    annegables11

      Is there a way to add a link/URL to a .swf file, without embedding into the original .fla file?

       

      Is there any way to do that with just the .swf file alone, and without actually editing the .fla or re-creating it?

        • 1. Re: How do you add a link to a .swf file?
          Ned Murphy Adobe Community Professional & MVP

          None that I know of - you cannot change an swf file without editing it via an fla.  An alternative is to create a second swf that loads the swf and also has the link in it.

          1 person found this helpful
          • 2. Re: How do you add a link to a .swf file?
            annegables11 Level 1

            where can i find out how to create a swf that loads the swf and has 

            the button/link in it? could you point me in the right direction?

             

             

             

            Quoting Ned Murphy <forums@adobe.com>:

             

            Ned Murphy http://forums.adobe.com/people/Ned+Murphy created the discussion

             

            "Re: How do you add a link to a .swf file?"

             

            To view the discussion, visit:  

            http://forums.adobe.com/message/3959806#3959806

             

            • 3. Re: How do you add a link to a .swf file?
              Ned Murphy Adobe Community Professional & MVP

              Do you have any experience designing/coding with Flash? If so, which version of Actionscript are you familiar with?  Another factor is if the other swf uses Actionscript, and if so which version? (An AS2 file cannot load an AS3 file).

              1 person found this helpful
              • 4. Re: How do you add a link to a .swf file?
                annegables11 Level 1

                I am not that familiar with Flash/Actionscript coding anymore. 6 years 

                ago, I designed for 2 years and taught myself Flash/Actionscript using 

                the Help Section in Flash and asking questions in Forums.

                 

                I don't know the version of Actionscript for the other .SWF, and 

                neither does the person who gave it to me.

                 

                Could you show me how to do it assuming it's an AS3 file?

                 

                 

                 

                Quoting Ned Murphy <forums@adobe.com>:

                 

                Ned Murphy http://forums.adobe.com/people/Ned+Murphy created the discussion

                 

                "Re: How do you add a link to a .swf file?"

                 

                To view the discussion, visit:  

                http://forums.adobe.com/message/3960121#3960121

                 

                • 5. Re: How do you add a link to a .swf file?
                  Ned Murphy Adobe Community Professional & MVP

                  I won't be providing lessons, but here's the basics...  to load the other swf file using AS3 you will use code like the following in the main timeline...

                   

                  var my_loader:Loader = new Loader();
                  my_loader.load(new URLRequest("theOther.swf"));
                  addChild(my_loader);

                   

                  addChild(myBtn); // described next but coded here

                   

                  To add a link, you can create an invisible button and place whereever you like in the timeline, or if its a text link you can assign the link to the dynamic textfield via the properties panel.  To create an invisible button just create a button symbol and draw a shape for it only in its Hit frame, leaving all other empty... that way you can still see the button to work with it on the stage, but it will be invisible when the file plays.  You could also have the button include text or any other visual you desire if you don't need/want it to be invisible.

                   

                  If you use the button approach, then you need to assign the button an instance name (I use "myBtn" for this example)  Then you have to assign an event listener and event handler function for the button...

                   

                  myBtn.addEventListener(MouseEvent.CLICK, clickBtn);

                   

                  function clickBtn(evt:MouseEvent):void {

                       navigateToURL(new URLRequest("http://www.yourlinksurl.com/etc"));

                  }

                   

                  The reason I addChild for myBtn after I addChild the Loader is so that it will sit above the Loader.  Without that line, the Loader would have the loaded swf sitting atop the button blocking access to it.

                   

                  If you plan to use a Textfield instead of a button, then you don't need the event code but you still need the addChild() line to bring it in front.  As mentioned already you can link it via the properties panel field for a link.  To make life simple per these instructions just assign the textfield an instance name of myBtn.