Please help : two events on one button

Hi there
I set up a simple Flash banner with the following code to click through  to a web page:
function buttonClickHandler(event:MouseEvent):void {
navigateToURL(new URLRequest("**URL**"));
trace("You clicked me.");
This worked fine, no problems.
However, I was then asked to include a click counter by using this code:
btn.buttonMode = true;
btn.addEventListener(MouseEvent.CLICK, goOut);
function goOut(e:Event){
var url:String = root.loaderInfo.parameters.clickTag;
var request:URLRequest = new URLRequest(**URL**);
try {
navigateToURL(request);
catch (e:Error) {
I've tried various ways to combine the two events, but it just doesn't  seem to work. I'm only used to one simple action at a time(!) and this  is needed urgently.
Can anyone please help me resolve this problem? I will keep an eye on  the forum to update with any necessary info asked for.
Many thanks in advance.

You can just call two different functions by adding two listeners:
btn.addEventListener(MouseEvent.CLICK, goOut);
btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);
If you want to combine them though, you do have one error - the goOut function needs to accept a MouseEvent, not a regular Event:
function goOut(e:MouseEvent){
Also, you shouldn't need the root when grabbing the FlashVar:
var url:String = loaderInfo.parameters.clickTag;
You should put a trace in there to make sure it's working as expected.
And you didn't really say what isn't working. Do you get any errors?

Similar Messages

  • Control two functions on one button click

    Hello,
    first off, I am relatively new to actionscript 3.0. I was
    wondering if anyone knows how I can control two events on one (the
    same) button click. On click, the first function must jump the user
    to a particular frame label and at the same time trigger a second
    function which is a movie clip on that particular frame. I must
    note that the event listener is attached to an actual Button and
    not a movie clip.
    Any help would be greatly appreciated.

    Thanks for the quick response. I tried out your solution but
    I get the following error...
    TypeError: Error #1009: Cannot access a property or method of
    a null object reference.
    at index_fla::MainTimeline/rev()
    at index_fla::MainTimeline/resources()
    I also tried to create another event listener on Mouse_UP
    ex:
    topNav1_btn.addEventListener(MouseEvent.CLICK, resources);
    topNav1_btn.addEventListener(MouseEvent.MOUSE_UP, rev);
    but I get another strange error...
    ## [Tweener] Error: [object MovieClip] raised an error while
    executing the 'onComplete'handler.
    TypeError: Error #1009: Cannot access a property or method of
    a null object reference.
    at MethodInfo-218()
    at Function/
    http://adobe.com/AS3/2006/builtin::apply()
    at caurina.transitions::Tweener$/updateTweenByIndex()
    at caurina.transitions::Tweener$/updateTweens()
    at caurina.transitions::Tweener$/onEnterFrame()
    ## [Tweener] Error: [object MovieClip] raised an error while
    executing the 'onComplete'handler.
    TypeError: Error #1009: Cannot access a property or method of
    a null object reference.
    at MethodInfo-241()
    at Function/
    http://adobe.com/AS3/2006/builtin::apply()
    at caurina.transitions::Tweener$/updateTweenByIndex()
    at caurina.transitions::Tweener$/updateTweens()
    at caurina.transitions::Tweener$/onEnterFrame()
    any other thoughts? Thanks in advance.

  • I forget my apple ID and password. i can't activate my iphone model A1332 EMC 380A.please please help me.if any one read my massage.please.

    i forget my apple ID and password. i can't activate my iphone model A1332 EMC 380A.please please help me.if any one read my massage.please.

    Go to http://appleid.apple.com and click 'Find your Apple ID'.

  • Associating two events with submit button using  javascript in jsp

    Hi
    How can i Associate two events with submit button using javascript in jsp. Firstly it should insert the data to database and secondly it should close the same pop-up window

    Have something like :
    <input type="submit" name="submitbtn" value="Click me" onClick="function1(); function2(); " />
    You just call both functions sequentially, it's that simple. Although using javascript to work with a database, that seems a bit tricky.

  • Hi please help i pressed my home button on my i phone 5  this morning to check the time and my phone went big(like its zoomed in) i have switched it off but when it came back on again its still got a big screen any ideas?

    hi please help i pressed my home button on my i phone 5 this morning to check the time and the screen went big as if its zoomed in i have switched the phone off but when it came back on the screen is still big i cant connect to i tunes either as i have a pass code on my phone i cant type it in as the screen is to big. please has anyone got any ideas on how to fix this.

    tweetypie80 wrote:
    thank you for your help
    You're welcome.

  • Can we perform two actions with one button with two clicks one after other?

    Sir,
    can we perform two actions with one button with two clicks one after other?
    I want that when I click an Add Button first time it add data to the database and when I click again this button it clear the form data to empty fields.
    Regards
    Tanvir

    In code it should be easy.
    The following code adds a button called butman with a text "ADD".
    It then registers a listener that will be called if the button is clicked.
    This listener then calls the runAddData method if you clicked on butman while it contained the "ADD" text and it will call the runClearData method otherwise.
    Therefore it will swap the button's functionality between ADD and CLEAR on every click.
    final Button butman = new Button("ADD");
    butman.setOnAction(new EventHandler<ActionEvent>() {
              @Override
              public void handle(ActionEvent t) {
                        if (butman.getText().equals("ADD")) {
                                  butman.setText("CLEAR");
                                  runAddData();
                        } else {
                                  butman.setText("ADD");
                                  runClearData();
                        } // END IF-THEN
              }});I hope this is what you wanted.
    Some extra food for thought.
    You might want to run the ADD and CLEAR methods in their own threads so that it can run in the back ground, without slowing down your user interface.
    I also like to rather reuse one button for multiple functionality in stead of making an application with hundreds of nodes only used rarely with masses of code to show and hide them if needed.

  • Thanks.. can u please help me out in one more question. how can i transfer files like pdf, .docx and ppt from my laptop to iPhone 5 ? please its urgent.

    thanks.. can u please help me out in one more question. how can i transfer files like pdf, .docx and ppt from my laptop to iPhone 5 ? please its urgent.

    See your other post
    First, i want to know how can i pair my iPhone 5 with my lenovo laptop?

  • Two actions on one button click

    Hi All,
    I have one button that I want to do two things. When I test
    the movie I have to click on the button twice to make both actions
    happen. Is my machine on drugs or is there something I'm missing?
    Here's the AS I'm using on the button.
    on (release) {
    gotoandStop(2)
    on (release) {
    holder_mc.loadMovie("my_movie.swf",1);
    Thanks for any help,
    Mike

    on (release) {
    gotoandStop(2)
    holder_mc.loadMovie("my_movie.swf",1);
    }

  • PLEASE HELP!!! power button stuck and wont turn on!

    So I've had my iphone4s for a little bit over a year and before the power button got stuck, I had problems with it turning off sometimes during school and it wouldn't turn back on without a hard reset. Then afterschool one day I could no longer hard reset it and it wouldn't turn on! Then after a few days of examining it i reazlized that the power button is jammed inside, but i could still wiggle it. I tried charging in against the wall, plugging it into the computer and nothing worked; itunes didn't even recognize it anymore! So I brought it to the Apple store to have them look at it, and they said that they couldn't turn it back on and its not possible to just replace the power button ALSO my warranty is up and therefore they can't replace it for me...and I'd have to pay the full price of a new iphone if I want to replace it...
    Is anyone else experiencing this problem? Have you found a solution besides replacing it? I really don't want to purchase another...please help! ):

    Try rebooting it by holding the Lock button and the Home button at the same time for about 10 seconds until the Apple logo shows up on the screen.
    This usually works when your device is frozen

  • Please Help! E-mail Setup Button Doesn't Do Anything

    Hi!
    This is my first posting in here, and I do apologize right now if the same issue has happened and has been posted before...
    I got the OS 6 a couple of weeks ago (I have a Curve 9300 3G) and everything was working just fine until I changed my gmail address's password from my laptop and then my email stopped working on my phone. When I go to setup and see the email accounts (it says I have 2 which is normal- I have my Yahoo! email as well). When I press on the icon though either nothing happens or I'm being brought back to the main screen. I still receive my yahoo! emails but I can't even try to sign in with the new gmail password since the button seems to be frozen.
    Please help me!!

    The primary button is only for editing metadata like keywords. Adjustments have to use the lift and stamp tool to copy them to other images.

  • Please Help.I have upload one Music Free icon from Apple store,after installation.I have opened the music video but 5 min after the mobile screen stopped to work.The screen touch is not reacting.And exist the voice e mail.What I have to do?

    Please help!! I have iPhone 4.Version 6.1.3.I have upload and purchased a lot of things from Apple store.It was Music free icon Japanese media,also Movie uploader icon.I was intended to open but requested to sign in and I was registered in You tube and Google.The Video has been opened and after 5 min,everything stopped.Screen Touch dont recognize anything.I mean I was trying to close the video but screen touch was not reacting.After I have switched off/on the iPhone but no result.I can switch on but cant press the buttons.And there is a voice which is just repeating if you are trying to press the button.Now I dont know what to do ? I am just thinking about virus but, how,I was thinking that all devices purchased from Apple Store is safely?maybe i am mistaken.please advice,maybe i need to go to Apple services Center????

    No, I have not tried any backup tools. I havent restored my ipod back to factory settings yet and then sync everything back on it. I am kind of scared too because I dont want to lose anything. I have just been hoping some new apple software update will come out because I know several people have had problems when updating to the newest version available.

  • New at Flash, please help! Sound On/Off Button

    I'm trying to create a button that when clicked once, it plays music, and when clicked again, it stops. I don't need the button image to change at all, I just need a simple start/stop.
    I've been able to make the button start the music when clicked but I've not been successful in making it stop.
    I am using CS4, and have no scripting experience.
    This is for a graphic arts assignment so please help!

    drag your button to the stage and assign it an instance name (eg, btn).  you can then use:
    var sound:MP3=new MP3();
    var sc:SoundChannel = sound.play();
    btn.addEventListener(MouseEvent.CLICK,f);
    function f(e:MouseEvent):void{
    if(sc){
    sc.stop();
    sc=null;
    } else {
    sc=sound.play();

  • Should I return this laptop? Ebay purchase. Please help - need more than one opinion! College student here

    First, it was an amazing deal of $525 for a 2011, 6gb RAM, 640 GB hard drive.
    BUT, i took it to the apple store and they said I should return it because...
    1) the screws on the bottom meant the seller refurbished it because they arent apple screws
    2) the hard drive failed their test which was sad for me to see
    3) the RAM sticks are two different sticks, one apple stick and one something else
    4) the keyboard only lights up in the middle which the apple people think is water damage but they cant really tell without opening it. they wont open it because of the screws.
    The reasons I dont think I should return it are....
    1) I can get a squaretrade warranty so if it does break I can return it
    2) $525 for a 2011 mac laptop is sooo good and unheard of, but I may be able to find another similar deal on craigslist so this might not be a valid reason
    3) i've been heavily using it for a week without any issues
    4) i dont want to spend more new hours searching for a laptop
    5) i might not be able to find one on time for when school starts
    BACKROUND INFO #1: it has ZERO dents, scratches, or dings - nothing else except whats listed above is wrong with it
    BACKGROUND INFO #2: I am a college student who has had 7 PC's crash in the past 5 years. I gave up on PC and invested in this mac. I'm tired of losing my files and forgetting to back it up into my emails every week.
    so looking at all that, what do you think I should do? AKA if you were in my shoes you would do what?

    Now you know why it was $525.  Also realize you are getting a computer that isn't a warranty computer.  How much did you save?
    Read the fine print on the Squaretrade warranty.  Make sure they won't turn it away for the same reason Apple does.
    Can you live without the light?  Even if it got wet in the past it boots now.  If I buy a used car and the radio doesn't work but I get it for a really good price then I figure that's part of it if I can live with it and it doesn't interfer with day to day use.
    It would be nice to know why the hard drive failed their test. Obviously if the computer boots it isn't total toast.  Clearly somebody has been inside the computer to add RAM and maybe change the drive?  That doesn't freak me in a used computer.
    Maybe somebody can comment on non idential RAM but with some computers with RAM from a reputable upgrade source it doesn't matter.  Post the exact specs of the second chip.
    My only question is, how up-front was the person from whom you bought the computer?  Did they tell you about the light?  It isn't a critical part but it is something you can assume to be working unless they tell you it isn't.  If they didn't, what else didn't they tell you?
    Screws will freak Apple Service because they only look at stuff where they know 100% what's been done to it and nobody not-certified has messed with it.  I have done all kinds of things to my computer that would have voided the original warranty 20x over but it long ago went out of warranty.  It purrs.

  • Play two MCs with one button

    Hi,
    I'm trying to make the main timeline go to frame 2, and a separate MC go to frame 2 by clicking one button.
    Here's what I'm trying ...
    on (release) {
        _root.gotoAndPlay(2);
        snap1.gotoandplay(2);
    When the button is clicked, the main timeline goes to frame 2, but the MC (instance name) snap1, doesn't play. I'm using AS2.

    actionscript is case-sensitive.  use:
    on (release) {
        _root.gotoAndPlay(2);
        snap1.gotoAndplay(2);

  • URGENT PLEASE HELP: Broker only serving one queue consumer at a time

    Hello all,
    I have multiple consumers listening on a queue. The broker sends a message to the first listening consumer. This consumer receives that message and acknowledges it. and does some processing with it.
    All other consumers do not get any message from the broker. They are all listening on the queue for a long time. After i kill the first consumer one of the listening consumer gets a message.
    How can I configure the queue so that it sends multiple (different) messages to all the listening consumers with minimum delay?
    I am using a persistent queue and using 3.5 sp2 on windows.
    Thanks a lot in advance

    Sounds like your number of active consumers is set to 1 which is the default. Use imqcmd to set the maxNumActiveConsumers on your queue. The Platform Edition supports up to two active and one backup consumer. The Enterprise Edition does not have any limits.

Maybe you are looking for

  • ITunes wont let me download albums onto my ipod touch- only individual songs - help!

    Ive tried switching it on and off and downloading 2 songs to see if that would help but it hasnt worked. The box that I would touch to buy (the one with the price of the album) doesnt do anything when I touch it and doesnt have a little '+' symbol in

  • Fan, power consumption etc

    Hello everyone. I am thinking about buying a 2012 MacBook Air to replace my 2011 one however I have one or two questions which I hope someone would be kind enough to answer for me... If I was to do exactly the same tasks on the more powerful 2012 one

  • HT1449 move itunes library to external hard drive : fails with error -50

    Following the steps to move my iTunes library to an external drive, everything is strating well, the copy beginns and after 2 hours of copy, I had this message failure with error -50. My external hard drive is a timecapsule with enough free space. Pl

  • Titling Best Practices

    Hello Working with AE and Premier I am starting to wonder what the best way of titling my videos in Premier is. When I use AE I can get all sorts of fancy results but sometimes the quality of the edges of the fonts and stuff looks jaggy. My project i

  • Treasury Management Curriculum Location

    On March 29 I sent one of my customers the following information which I cut and pasted from the UA web site. Now I can't find it. +In the TMP module the students use an ERP system (in this case SAP) to work in the field of Treasury Management. In th