A button with two functions CLICK

I'm sure that I must write an if else for it to almost 100% statement.  However, I'm not exactly sure how do.  Here is the code I have for a button (movieclip) that I created.  He is supposed to play an animation when you click on it.  Then when you click it again it was suppose to play a second animation that he will bring back the State of origin.  What's happening is, it goes directly to the State clicked without playing the animation.  However when you click the second time he plays the animation that takes back you to the original state.  Am I right to believe the only way to get the animation to play on two clicks is to use an if else statement and can someone help with the fi, the else statement.  I never wrote the script for one.

function clickPlus(event:MouseEvent):void {}
Btn1.gotoAndPlay ("clickOpen");
}
Btn1.addEventListener (MouseEvent.CLICK, clickPlus);

function clickX(event:MouseEvent):void {}
Btn1.gotoAndPlay ("clickClose");
}
Btn1.addEventListener (MouseEvent.CLICK, clickX);
Btn1. RemoveEventListener (MouseEvent.CLICK, clickPlus);

Have you tried moving the first btn1.addEventListener on top? All orders are executed in sequence given/written. I do not have to appoint executives, but they are probably right, I use the number of the frame. You could do/take a picture of the first image, convert to the key and make the movieclip on the next run frame. Then stop it on the frame and do the same thing with the button to operate the other movieclip, here's an example I did http://manamoppet.deviantart.com/art/Something-in-the-wall-127359486 . It is an alternative, but worked for my purpose...

An if else statement works like this, but I'm certainly NOT some cases what I write here will work with your movieclips, tracks used to find out if it has worked, so you can delete:

var variable1:Boolean = true;
var variable2:Boolean = false;

Btn1.addEventListener (MouseEvent.CLICK, clickPlus) ;//

function clickPlus(event:MouseEvent):void {}
var variable2 = false;

If (variable1 == true) {//goes to and playes animation btn1 if the variable is equal to the value 'true' (or the number of given number)}
Btn1.gotoAndPlay ("clickOpen");
trace ("Start nummer 1");
variable2 = true;
Variable1 = false;
}

else {//executes on all values which is not seized written if statement
trace ("start 454654 nummer");
Btn1.gotoAndPLay (click Close "")
Variable1 = true;

}

}

Tags: Adobe Animate

Similar Questions

  • two buttons with single function

    I want to create two buttons for single function and a single button for a function. For example, I click on button1, the display shows "clicked1".

    If I clicked on button2, the display shows "clicked2". If I click on button1, and then click button2, it will show that "the two buttons are clicked. However, it does not work in two buttons with single function. What is the problem? Here's the code.

    import flash.display.MovieClip;

    import flash.events.MouseEvent;

    var button1:MovieClip = new Button1();

    Button1.x = 200;

    Button1.y = 200;

    addChild (button1);

    var button2:MovieClip = new Button2();

    Button2.x = 300;

    Button2.y = 250;

    addChild (button2);

    Button1.addEventListener (MouseEvent.CLICK, onClick);

    Button2.addEventListener (MouseEvent.CLICK, onClick2);

    var isClicked:Boolean;

    var isClicked1:Boolean;

    function onClick(evt:MouseEvent):void {}

    isClicked = true;

    trace ("clicked1");

    }

    function onClick2(evt:MouseEvent):void {}

    isClicked1 = true;

    trace ("clicked2");

    }

    If (isClicked & & isClicked1) {}

    trace ("two buttons are clicked");

    }

    Copy the following code

    If (isClicked & isClicked1) {}

    trace ("two buttons are clicked");

    }

    should run WHEN you click on your buttons.  That is to say, place it in a function and call that function when you click on your buttons and after that your Boolean values are updated.  (probably then want to reset these Boolean values in the called function).

  • How can I associate a button with two slices?

    Hello
    I need help please. How can I associate a button with two slices? or combine the two slices to make one cut or make a form of true polygon on the edges, it will make to the polygon, but it leaves the red lines and I cannot work under this installment... If you understand. Someone help please. Thank you very much.

    Two points.

    First of all, I see that you have forms stars in your image, but that does not mean that you need a star-shaped slice. You can use a little square that is centered on your star. That could make it easier to create your slices. All you have to do is drag lines of leaders in the left seat and superior, two pairs around each star and then drag a slice from one end to the other.

    Noting that brings me to my second point: images must be rectangular. If you want to change the L-shaped area, then you need to swap two images, not one only. This is perhaps why you cannot have the buttons under the threshold of upper sliding of your L shaped section. Because Fireworks needs to make a rectangular image, it is by default in an area that encompasses the range - area you can not the buttons in. It is the lock area non cut which still need to be part of the image, since the part will swap, too.

  • button with two URL field

    I want to use a button 'Link' field with 2 different links in combination with a 'response' option field (options: Yes or no).

    If the option field 'response' is on 'Yes', url1 links "link" button, if the user clicks the option 'no', this field to url2 button, if the user has not selected anything whatsoever, the domain of the 'Link' button should not send to all URLS. Is this possible in javascript?

    Yes, to use the statement 'if' twice or a switch statement. First, you will need to check to see if there was a selection of one of the checkboxes, then if one of the buttons has been selected, you run the code for the appropriate selection. Using a switch statement that is enough to test the none selected, option 1 or option 2.

  • Button with two linked actions. Doesn't work

    My folio I have two buttons (to change the language) I have change the State of the text and the title.

    With a simple TOUCH, she changes two States (two measures).

    In the preview with the Office Viewer that works, but on the ipad isn't (I need two consecutive tap the same button).

    Why?

    I think you came across a weird bug that has not yet been set. In your target MSOs, try to set a Cross Fade with a minimum delay, such as 0.125 seconds. Then it should work.

  • Add a button with zoom function

    Hello

    I work on a catalogue of products, and for this we used a professional photographer to take pictures of product. The photos are really nice and they can be zoomed to discern details. Pictures have been inserted in the pdf catalogue, but due to limited space, they are not very detailed.

    Is it possible to add a button or a link with the zoom feature? For example, an icon like a magnifying glass, or simply the word zoom, so when a user clicks on it, it zooms in the game area before an upgraded pre and Center it.

    Sounds quite right fantasy? I think maybe the impossible... but it's worth a try here :)

    Kind regards

    Rudi

    Additionally, to prevent Acrobat inviting you to register, add the following line of code at the end of the script:

    dirty = false;
    

    This means, there is something else in the document, like a form to fill out, which could cause the document legitimately require a backup. In this case, you will need to check the property dirty at the beginning of the script and only false if that's what it was at the beginning. If you need assistance with this, post again.

  • How can I change the skin of button with the function arguments?

    Hi guys, I am building a card witch I represent with grid 40 * 26 buttons, now I used to create an action script function that will get a string that contains the name of the folder where I store the data for example skin buttons:

    [Embed("maps/grass/upSkin.jpg")]

    _upSkin: class private var;

    [Embed("maps/grass/overSkin.jpg")]

    _overSkin: class private var;

    [Embed("maps/grass/downSkin.jpg")]

    _downSkin: class private var;

    private void changeMap (): void

    {

    slot: Button = new Button();

    slot.setStyle ("upSkin", test);

    slot.setStyle ("overSkin", _overSkin);

    slot.setStyle ("downSkin", _downSkin);

    }

    That's what I managed to do so far, what I would do is send to changeMap() a string with the path name access, but some how I can't integrate a variables, I'll be glade if you could find a solution for this.

    Here's the link to my site, so you can see what I mean. I'm not always online, but you can try.

    http://gazmanwars.zapto.org/

    * Best discovered ground less 1280 * 960

    You can use the selector of a CSS class rather then type selector you probbably do something similar in your css

    Button {}

    upSkin:

    DownSkin:

    }

    This will apply style on all of the buttons in your application as its happening now so you can use the Selector class more like this

    {.myButtons}

    upSkin:

    DownSkin:

    }

    the grid of buttons that make you can then use this statement

    Var b:Button = new Button()

    'b.styleName =' myButtons

  • Show the button with a single click to edit the table only after click

    Hi all

    I love the click to change features in tables in the ADF and have a button in one of the columns I want to only be displayed in the mode (it is only once the user has clicked on a particular line) edition. Currently, all fields appear as read-only and can be changed when the user clicks on a line, but it seems that the button is always visible. I tried a few EL expressions to set the visible property of the button but have not found one that works. Could you help to define an EL or give me a hint on how I could hide the buttons in the table and only then display the row that is clicked and can be changed?

    Thank you

    Jobinesh blogged about this here decompilation binary ADF: made conditional editor components for a table of clickToEdit

    Timo

  • button with double function

    Is there a way to create a button that has a rollover caption?

    I want the user to substitute, the button and the text appears above the button, a bit like a ToolTip and disappear when the user leaves the key... but the button to act like a button (need to navigate to another slide).

    I hope than that maks sense.

    Thanks in advance!

    Hello

    Sure thing. Insert a standard button. Then click on the Options tab.

    Select the legend of suspicion.

    See you soon... Rick

    Useful and practical links

  • single button with two expression?

    Hello

    How to configure 2 expressions for a Single_Button in terms of the 'Condition' of the Page Edit button.

    I already have an expression like:-'Expression 1 = P1_NO' and condition_type = "Value of the element in the Expression 1 is NULL", but this being specified I want to add an expression in the expression 2 how I can do?

    apprecaited


    In depth.

    Hello deep,

    I just created an example (form & report on a Table) and changed the State of the button [Apply Changes] to the Condition Type = PL/SQL Expression and Expression 1 is
    : P20_PRODUCT_ID IS NOT NULL AND: P20_PRODUCT_AVAIL = 'Y '.
    And that works like a charm.

    Greetings,
    Roel
    http://roelhartman.blogspot.com/
    You can reward this response in marking it as useful or Correct ;-)

  • I want to move a large number of photos but don't want to unique, click each photo. I know there is a simple control function that allows to select groups of files with ' two'clicks ', as opposed to the selection of each file. Suggestions?

    I want to spend a lot of photos (they are in order) but and do not want to have to click to move each photo. I know there is a simple control function that allows to select groups of files with ' two'clicks ', as opposed to the selection of each file. Suggestions? I know it's apple 101, but I don't remember what order to press the button command, or shift, or other. Thank you

    Select the first file, then hold down the SHIFT key, and then click the last file. Or, select any file in the folder and then press command + A

  • can perform us two actions with a single button in two clicks, one after the other?

    Mr President.

    can perform us two actions with a single button in two clicks, one after the other?

    I want that when I click on the button Add once it add data to the database and when I click again on this button it clears the form data to the empty fields.

    Concerning

    Tanvir

    In the code, it should be easy.

    The following code adds that a button called butman with text 'ADD '.
    It then registers a listener that will be called if the user clicks the button.

    This listener then calls the runAddData method if you clicked butman while it contained the text of "ADD" and it calls the runClearData method otherwise.
    That's why he will swap the functionality of the button between ADD and CLEAR on each click.

    final Button butman = new Button("ADD");
    butman.setOnAction(new EventHandler() {
              @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 that's what you wanted.

    Further reflection.
    You might want to run the ADD and CLEAR methods in their own son so that it can run in the background without slowing down your user interface.

    I also reuse rather a single button for several features instead of to apply with hundreds of nodes used only rarely with masses of code to show and hide as needed.

  • Addition of two functions in a single button (gotoAndStop, sound judgment)


    Hi all! First of all, I would like to say that I am a beginner total with respect to as3. Okay, let's look at my problem... I have 2 scenes (first of all is a main menu with the button New Game; second scene is the intro for the game). I'm having difficulties to do two functions within a single button. Why do I need that? The first function is to go to the next scene (in my case, IntroScene). Second is to disable the sounds, so I can not hear them in the next scene.

    Here is the code:

    var bobobg:bobomusic;
    var sndChannel:SoundChannel;

    bobobg = new bobomusic;
    sndChannel = bobobg.play ();

    MAIN - NEW GAME MENU BUTTONS
    newgame_btn.addEventListener (MouseEvent.CLICK, buttonClick3);
    newgame_btn.addEventListener (MouseEvent.CLICK, buttonClick4);
    function buttonClick3(event:MouseEvent):void {}
    gotoAndPlay (1, "IntroScene");
    }
    function buttonClick4(event:MouseEvent):void {}
    bobobg. Stop();
    }


    Error message: "TypeError: Error #1006: stop is not a function."
    to MainMenu_fla::MainTimeline/buttonClick4().

    I would appreciate if someone could help me with this. Thank you!

    Ok.  Just do this:

    var bobobg:bobobgmusic = new bobobgmusic();
    var sndChannel:SoundChannel = new SoundChannel();

    sndChannel = bobobg.play ();

    MAIN - NEW GAME MENU BUTTONS
    newgame_btn.addEventListener (MouseEvent.CLICK, buttonClick3);

    function buttonClick3(event:MouseEvent):void
    {
    gotoAndPlay (1, "IntroScene");
    sndChannel.stop ();
    }

  • Error with the function "Open/create/overwrite file" with cancel button

    I have attached a very simple VI who embodies what I want to do with my function to open the file. I just want to stop the rest of my program (theoretically embedded in the Structure box) to run if the user deigns to do not to specify a file location.

    However, if you click on the button cancel an error is produced before the rest of the program is running. If ignore you the error and continue, the "canceled" properly true made variable and the Structure of business runs correctly. "" I just want to remove the error message given to me by LabVIEW.

    Any ideas on why or how?

    Read the help of LabVIEW on automatic error handling.

    In your case, you can just wire the output of cluster of error to the structure of your business.

  • Single-click buttons requires two clicks to work. Someone at - it solutions?

    In Captivate 9.0.0.230 I have a slide with two buttons that beep if you click on it. However, one of two simple clicks (not double-click) required to work.

    Settings are the same on both buttons.

    Problem returns only if I publish/Preview in HTML5 (even in different browsers on Windows). All buttons works fine in Flash.

    Someone had the same problem, or better, a solution?

    Adding the zipped file: 2_f5_f2_p1-two https://connect.wezupport.se/two-clicks/source/d1_k2_f5_f2_p1-two-clicks.zip?download=d1_k - clicks.zip

    Update:

    Seems that the problem only comes up (in the combination, I described above) if I publish in the form of a scorm package and view it locally. If I publish to LMS (in this case Opigno) it works fine.

    Detective Conan.

Maybe you are looking for

  • I can't play a videosequence with the playbutton

    I can't play a videosequence in the mediathek. The playbutton does not work. The playbutton to the Viewer does not work. The only thing I can do is to go with the cursor on the video or shuttle Xpress (but only the manual way, no game in real time...

  • How to group the text on the Razr Maxx-JB 4.1.1 HD

    I have a problem, try to send a group text. Icon text not available when looking at groups of people. Groups are not available in searching of text messaging contacts. Any ideas? Thanks in advance, Dave

  • KB 954430 with error message on log files.

    Cannot install Windows Update KB 954430 XML Core Services.  I get the error message is: error opening installation log file.  Verify that the specified log file location exists and is writable. Windows Update does not appear if care I do not download

  • BlackBerry.BBM.Platform.Register does not

    I use the Simulator with webworks.  I simply call the register method, but nothing happens: blackberry.event.addEventListener("onaccesschanged", _bbm.test); options = { uuid: "aaa90f91-ad95-4ba9-82c4-33f6ad69aaaa" }; blackberry.bbm.platform.register(

  • PN-online, publication in InDesign error

    Hi my problem is that I'm loading a file and keep getting and error #40 ID bac66480-5d36-11e6-8499-ebe4604817a1Also what is memory wise to the amount of files limit, you can publish and if there is a limit can you get more?I hope you can helpThank yo