1 Reply Latest reply on May 1, 2008 12:16 PM by ScramblingMan

    Creating a Link

    1485
      I have created a full page Flash presentation which I now want to link to a Web page. The Flash page is a front end to the website proper, in other words the Flash presentation is a separate page to the main web pages. What I want to do is use the animated logo on the Flash page as a link to my main home page. I am aware that I might have to convert the Logo to a button symbol and then write action script for that symbol so that a user can click the logo and be directed to the home page, but how do I go about it. Can anyone help please.

      Many Thanks in anticipation
        • 1. Re: Creating a Link
          ScramblingMan
          Actually, it's simpler than having to mess with your logo.

          Draw a shape on a layer ON TOP of the logo/layer. Fill and stroke make no difference, we'll get rid of them in a minute.

          It the Properties dialog box, this shape should show up as a drawing object. Select it on the Stage, select MODIFY > CONVERT TO SYMBOL... and convert it to a MovieClip symbol, with a name like "mc_hotSpot" or something; that's what you're making, what will be a transparent hot spot, sitting on top of the logo. Now, delete the shape on stage, and drag the new symbol from the Library onto the Stage, over your logo. In the Properties box, name this MovieClip instance something like "webLink_mc".

          So, in the sample code that follows:

          - the MovieClip symbol is called "mc_hotSpot"
          - the soon-to-be-transparent hotspot instance that is the actual link "button" is called "webLink_mc"
          - the function that gets called to do the transfer from Flash to the browser is called "sitePortal"


          The code is simple:

          //Import code references needed:
          import flash.events.EventDispatcher;
          import flash.display.MovieClip;
          import flash.net.navigateToURL;
          import flash.events.*;

          //Declare variable for name of your website URL:
          var linkSP:URLRequest = new URLRequest(" http://www.YOUR_SITE_ADDRESS.com");

          //Make cursor change to finger when over hotspot:
          webLink_mc.buttonMode = true;

          //Add event listener for mouse click on hotspot:
          webLink_mc.addEventListener(MouseEvent.CLICK, sitePortal);


          function sitePortal(event:MouseEvent): void {
          navigateToURL(linkSP, "_blank");
          }

          //As I have it, the navigateToURL() command has two arguments:
          //
          //the first is the link name; the second -- "_blank" -- instructs the browser
          //to open a new window. If you don't want that, then make the command
          //simply navigateToURL(linkSP);

          Now all you have to do is select the hotspot on Stage, and use the ALPHA control in the Properties box to make it transparent.

          Done!

          Hope this helps.