A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: rotating banner with 2 outward links

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    8

    rotating banner with 2 outward links

    Hi there,

    Flash noob here using cs3/as3. I'm trying to create a simple banner which fades between 2 images, looped. (This I can do!). What I'd like is to have each image link to a different url.

    I've tried changing the images to buttons with the following actionscript:

    on (release) {
    getURL('http://www.mysite.com', '_self');
    }

    but get the following error: Mouse events are permitted only for button instances even though they are buttons!

    I thought this would be really simple, but obviously not! Any ideas are gratefully received.

    Thanks for your help in advance

  2. #2
    Senior Member
    Join Date
    Jun 2008
    Posts
    549
    on (release) {
    getURL('http://www.mysite.com', '_self');
    }
    Your code will not work with Actionscript 3.0. Take a look at this tutorial for Actionscript 3.0: http://www.ilike2flash.com/2009/06/open-url-in-as3.html

  3. #3
    Junior Member
    Join Date
    Nov 2009
    Posts
    8
    thanks. I'm getting the following error now:

    Description:
    '{' expected

    Source:
    function openurl(event:MouseEvent):void

    Even though the '{' is there
    Last edited by facio; 11-19-2009 at 01:00 PM.

  4. #4
    Senior Member
    Join Date
    Jun 2008
    Posts
    549
    Quote Originally Posted by facio View Post
    thanks. I'm getting the following error now:

    Description:
    '{' expected
    This basically mean you have a '{' missing. You may have missed out the curly bracket.

  5. #5
    Junior Member
    Join Date
    Nov 2009
    Posts
    8
    It's there. I copied it directly from the site. This is what I have:

    recruit.addEventListener(MouseEvent.CLICK, openurl);

    function openurl(event:MouseEvent):void {
    var url:URLRequest = new URLRequest("http://www.ilike2flash.com");
    navigateToURL(url, "_blank");
    }

    Does it matter if there are single or double quotes?

  6. #6
    Senior Member
    Join Date
    Jun 2008
    Posts
    549
    What other code are you using?

  7. #7
    Junior Member
    Join Date
    Nov 2009
    Posts
    8
    that's it. I have one button with that code in and another with exactly the same except for the button name and it pointing to a different url.

    with both buttons it gives me the same '{' error and although the cursor changes, nothing happens when it's clicked on

  8. #8
    Senior Member
    Join Date
    Jun 2008
    Posts
    549
    This is very odd. Can you upload your fla?

  9. #9
    Junior Member
    Join Date
    Nov 2009
    Posts
    8

  10. #10
    Senior Member
    Join Date
    Jun 2008
    Posts
    549
    Quote Originally Posted by facio View Post
    Hi there,

    Flash noob here using cs3/as3. I'm trying to create a simple banner which fades between 2 images, looped. (This I can do!). What I'd like is to have each image link to a different url.
    The file you uploaded is using Actionscript 1.0, you are not using Actionscript 3.0. So, using Actionscript 3.0 code is giving your errors.

  11. #11
    Junior Member
    Join Date
    Nov 2009
    Posts
    8
    That's strange because I chose the document from the 468 x 60 template. i would have thought this would have defaulted to as3?

    Is there any way of changing to as3 retroactively?

  12. #12
    Junior Member
    Join Date
    Nov 2009
    Posts
    8
    Just created a new file and started again. Now I'm getting the error:

    1021: Duplicate function definition. function openurl(event:MouseEvent):void

    I'm now assuming you can't have 2 openurl in the same scene?

  13. #13
    Senior Member
    Join Date
    Jun 2008
    Posts
    549
    You can't have two function with the same name.

    Change one of the functions to

    Code:
    yourInstanceName.addEventListener(MouseEvent.CLICK, openurl2);
    
    function openurl2(event:MouseEvent):void {
    var url2:URLRequest = new URLRequest("http://www.ilike2flash.com");
    navigateToURL(url2, "_blank");
    }

  14. #14
    Junior Member
    Join Date
    Nov 2009
    Posts
    8
    Thnaks very much for your help.

    I'm now getting:

    ReferenceError: Error #1065: Variable recruit is not defined.

    Eventhough (as you can see in the attached) it is defined... CercoFlashbanner1.fla

  15. #15
    Senior Member
    Join Date
    Jun 2008
    Posts
    549
    This is an obvious error, you have not given an instance name to the recruit button.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center