Linking buttons to URL. Something is wrong. Please help!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tiruak
    New Member
    • Jun 2007
    • 9

    Linking buttons to URL. Something is wrong. Please help!

    Ok, from the title you can probably tell im a beginner to Flash.
    I'm using CS3, and am trying to create a "menu" to this one webpage.

    I did 4 animated buttons, but now im having problems making them link to my pages. I will describe with details what I did:

    First, I thought about select the button, and go to the Action panel and enter the script over there. For my surprise, when I try to type it in the action script 3, it comes up with the message "Current selections cannot have actions applied to it".

    Then, second thing I did, was to go to my main project, add labels to all my buttons (b_1, b_2, b_3 and b_4), add a Layer, and on the first frame of this new layer, I go to the action panel and tryied the following sintaxe for my script:

    Code:
    function onCompanyClick(evt:MouseEvent):void {
    getURL("company.html");
    }
    b_1.addEventListener(MouseEvent.CLICK,onCompanyClick);
    So you understand, the b_1 is the instance name of my first button (which is called Company), and I did repeat that for all other buttons.

    At first I was positive it was going to work, but then when i try to publish, it says the there is something wrong with the "getURL("compan y.html") part of the code. It's probably becuase thats not the correct syntax to call a webpage using Action Script 3.0 (I dont have any AC experience, my programming skills are from other languages, and I'm just experimenting on flash).

    So, if anyone can help me, what would be the right syntaxe to call my webpage on that function? And also, why cant I just add it to the button?

    Thanks for any help
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    Take a look at this page. It has information on the changes that were implemented in Flash 9 as far as getURL is concerned.

    Comment

    • Tiruak
      New Member
      • Jun 2007
      • 9

      #3
      Originally posted by Motoma
      Take a look at this page. It has information on the changes that were implemented in Flash 9 as far as getURL is concerned.
      Thanks Motoma, it has a nice explanation on the link, but I'm still having problems.

      im using the following code:

      Code:
      b_1.addEventListener(MouseEvent.CLICK, callCompany);
      function callCompany():void {
      	var myurl:String = "http://www.geekavailable.com";
      	var myrequest:URLRequest = new URLRequest(myurl);
      	navigateToURL(myrequest);
      }
      And I'm receiving this error message on the output window when I try to click the button:

      ArgumentError: Error #1063: Argument count mismatch on header_menu_fla ::MainTimeline/callCompany(). Expected 0, got 1.

      So now, I'm assuming I passed an argument I shouldn't, but my lack of knowledge on the language doesn't let me find what it is.

      Any other tips?

      Comment

      • Tiruak
        New Member
        • Jun 2007
        • 9

        #4
        Well, actually i got it to work.
        What was missing is the function definition as a mouse event. So correct code is:

        Code:
        b_1.addEventListener(MouseEvent.CLICK, callCompany);
        function callCompany(event:MouseEvent):void {
        	var myrequest:URLRequest = new URLRequest("mycompany.html");
        	navigateToURL(myrequest);
        }
        Thanks anyways.

        I just dont understand why Adobe did this kind of change on simple funcionts like getURL and some others. For experts it may be easy to figure out, but for me was just a pain in the butt.

        Comment

        • Motoma
          Recognized Expert Specialist
          • Jan 2007
          • 3236

          #5
          I am glad you have found your solution. Thank you for posting the correct code. You are welcome back here anytime you have a question, or feel like answering someone else's.

          Comment

          • Phat
            New Member
            • Jun 2007
            • 2

            #6
            can someone tell me how i could properly add an href tag to this?
            i want my link to open on the same browser , not a different one each time and this didn't work:

            btnLocation.add EventListener(M ouseEvent.CLICK , callLocation);
            function callLocation(ev ent:MouseEvent) :void
            {
            var myrequest:URLRe quest = new URLRequest("htt p://alpha.cvscardio .com/Locations.aspx" );
            navigateToURL(m yrequest,'_self ');
            }

            Comment

            • Motoma
              Recognized Expert Specialist
              • Jan 2007
              • 3236

              #7
              Originally posted by Phat
              can someone tell me how i could properly add an href tag to this?
              i want my link to open on the same browser , not a different one each time and this didn't work:

              btnLocation.add EventListener(M ouseEvent.CLICK , callLocation);
              function callLocation(ev ent:MouseEvent) :void
              {
              var myrequest:URLRe quest = new URLRequest("htt p://alpha.cvscardio .com/Locations.aspx" );
              navigateToURL(m yrequest,'_self ');
              }
              You cannot navigate the special windows "_self", "_top", or "_parent" if your SWF file is contained by an HTML page that has set the allowScriptAcce ss to "none", or to "sameDomain " when the domains of the HTML file and the SWF file do not match.

              You will have to change your embed tag to have the AllowScritpAcce ss set, as well as add a param tag to do the same thing.

              Comment

              • Phat
                New Member
                • Jun 2007
                • 2

                #8
                that did not work for me.. i changed the allowscript to always

                I'm new to all this, thanks for your help.

                any other ideas?

                Comment

                • Motoma
                  Recognized Expert Specialist
                  • Jan 2007
                  • 3236

                  #9
                  Heh...Google maybe? I don't have Flash 9 so my web-spelunking will be just as effective as yours.

                  Comment

                  • Motoma
                    Recognized Expert Specialist
                    • Jan 2007
                    • 3236

                    #10
                    If you find the answer, it would be nice to know what the solution is.

                    Comment

                    Working...