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 ();
}

Tags: Adobe Animate

Similar Questions

  • 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.

  • Two actions with a single button Oracle adf

    Hello
    Dear all,
    I want two action with a single button. Before posting, I studied this thread, but it seems that it cannot solve my problem two actions with a single button?
    It's my button and its action http://4.bp.blogspot.com/-tpP5wIW8JLI/T66zhLZgG0I/AAAAAAAAAPY/F1A-Ka8KGPY/s1600/req1.JPG
    getReqID button is actually a call to a procedure that returns a value to his class of action. The cb1_action function is...
    public String cb1_action() {}
    BindingContainer links = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("getReqID");
    Object result = operationBinding.execute ();
    int id = Integer.parseInt (result.toString ());
    System.out.println ("result =" + id);
    If (! operationBinding.getErrors () .isEmpty ()) {}
    Returns a null value.
    }
    Returns a null value.
    }
    It works very well. Don't know I want to, click this button, it also opens a page of .jsff. but I'm unable to open this page.
    Help, please
    Thank you
    Muhammad Nasir

    The first image you provided shows a small 'Attention' sign on the "request for quote-global-TF" which, I guess, gives you the sentence.
    This warning tells you that there is a problem with the task flow that you imported from the pot. Move the mouse over the warning sign a see what message you get from the frame on the error. If you don't get one, in 'source' view and look for red or orange squares in the gutter of the right hand. Scroll to the position of the red square and move the mouse over the underlined part red or orange of the code.

    Timo

  • Two calls with a single button - I'll explain

    I have a URL button that calls the following in my column in the APEX;
    <script language="JavaScript" type="text/javascript">
    
    function executeCommands() 
    {
      // Instantiate the Shell object and invoke
    //its execute method.
    var oShell = new ActiveXObject("Shell.Application");
    var commandtoRun = "c:\mybook_start.bat";
    
    // Invoke the execute method.
    oShell.ShellExecute(commandtoRun, "", "", "open", "0");
    }
    
    </script>
    Now before you all go security mad, that's the only way I can call a java program of APEX I could think, if there is a way safer please let me know.


    Now before this process works I need a call to a stored procedure to run (it is an APEX process to call a stored procedure)
    Begin
    bi_pub_data_1();
    END;
    I have a button, can the button first call the stored procedure then call java script code? Please help, thanks, Doug

    You can use a java stored procedure? Or should it be called from this server?

    Also I have the second idea of Kofi in the link he gave out... We use a java stored procedure for some of our unix systems to make pl/sql stuff. Of course, you have to be careful because it can execute OS commands, but its another option.

  • Two actions of a single button-click

    Hi all
    I have a button I want to do two things. When I test the movie I have to click the button twice to make two things happen. Is my machine on drugs, or is there something that I am missing? Here's where I use the button.

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

    Thanks for any help,
    Mike

    Yes, it worked perfectly. Thanks for the basic lesson.

  • Please check my code to call 8 sequential functions with a single button

    This code looks good to call the Func1 thru Func8 functions whenever you click on next_btn?

    I get the following error: mismatch number of arguments on FWA_fla::MainTimeline / nextReg (). From 0, 1.

    My research tells me its probably incorrect syntax. Do I need a function 'private '? Thank you very much, I'm lost!

    var counter:number = 0;

    this. next1_btn.addEventListener (MouseEvent.CLICK, nextFunc);

    function nextFunc (event: MouseEvent): void

    {

    If (counter == 9) {}

    (counter == 0);

    }

    counter ++;

    trace (Counter)

    ce ["Func" + counter] ();

    }

    Reg1 thru reg8 are defined below

    function Func1 (event: MouseEvent): void

    {

    do something

    }

    function Func1 (event: MouseEvent): void

    {

    do something

    }

    etc.

    Because the way you seem unable to post messages of error/code real, the best that I can offer, it is... the error indicates that you do not specify the argument that you show in the code that you have validated the nextFunc function

    Your other functions that you show having an argument, but you do not send one of them.

    function nextFunc(event:MouseEvent): void / / this line requires the 'event. MouseEvent.

    function Func1 (event: MouseEvent): void / / these lines should not "event. MouseEvent.

  • Switch between two intelligent forms with a single button?

    Hello!  I work at 8 Captivate and try to use a single button to switch between two smartshapes.  I can't for the life of me figure out how to do it.  I know its possible to make it 'show' and 'hide', but is it possible to simply create a user click on a button and whenever we click on it, it comes and goes between two different smartshapes?

    Im trying to show the user the functionality on a piece of equipment when they press a button.  When they push the button, it comes and goes between two different read out on the screen.

    Thanks in advance!

    Have you looked at the blog post that I posted a link: I offer 4 scenarios.

    It can also easily be done, if you have a separate (shape) button to switch between two different objects:

    1. Create a user with a default value of 0 v_visib variable
    2. Create two objects and one of them is visible, the other invisible output ("eye" in the Properties Panel icon); I've tagged the ShapeOne and ShapeTwo, where ShapeOne is visible at the beginning
    3. Create this advanced conditional action (you can also turn it into a shared action):

    IF v_visib equals 0
    Hide ShapeOne
    See the ShapeTwo
    Toggle v_visib
    ON THE OTHER

    Hide ShapeTwo

    See the ShapeOne

    Toggle v_visib

    4 assign this action to the success of the button event

  • Can we apply a createInsert single button for the two master form, details of Table?

    Mr President.

    Can we apply a createInsert single button for the two master form, details of Table?

    I want to just click a button and fields are available in form-Master and details-table.

    As below

    vfdt.png

    Concerning

    Mr President.

    My worm jdev is 12 c

    And I can do your job for you.

    His code

    For any organization that wants to do this job

     public void createVoucherAndVDetailsRow(){
                VoucherViewImpl voucherVO=this.getVoucherView1();
                VoucherViewRowImpl row=(VoucherViewRowImpl)voucherVO.createRow();
                voucherVO.insertRow(row);
                RowIterator iterator= row.getVoucherdetView();
                String voucherNumber=row.getVoucherId();
                NameValuePairs nvps=new NameValuePairs();
                nvps.setAttribute("VoucherId", voucherNumber);
                VoucherdetViewRowImpl voucherdetRow=(VoucherdetViewRowImpl)iterator.createAndInitRow(nvps);
                iterator.insertRow(voucherdetRow);
                }
    

    Concerning

  • using two instructions updated under a single button

    Hello
    I want to know if we can use two instructions update under a single button (when the button is pressed the shutter);

    in fact, the thing is when I press the button BOOK...

    the first statement updates the TRANSIT value with the sum of reserved posts to...

    the second update statement will deduct the value of the items available...

    ex:
    Sum of reserved point: 4
    Available: 14

    First update:
    Public transport: 4

    Second update:
    Avaiable: 14-5 = 10

    Suhail Faraaz says:
    Hello
    I want to know if we can use two instructions update under a single button (when the button is pressed the shutter);

    in fact, the thing is when I press the button BOOK...

    the first statement updates the TRANSIT value with the sum of reserved posts to...

    the second update statement will deduct the value of the items available...

    ex:
    Sum of reserved point: 4
    Available: 14

    First update:
    Public transport: 4

    Second update:
    Avaiable: 14-5 = 10

    Hello

    You can have two and also more updates of the statements under a single button, there is no problem, just check the condition for the update and corresponding to the value in the display :)

  • How to use a single button to drive another click of the button

    I am trying to find a way to fix a bug in my application.  The simple solution would be to have a single button that animates a mouse on another button click event whenever the PlayBar in my application reaches the end of the screen and go back to its origin.

    How could do?  I made a lot of progress since my last post a question in the forum of the ActionScript 3, which was last night.

    Thanks in advance,

    Markerline

    So just run the function one of the buttons would otherwise be run when you click on it, then just call this function when you need to.  If you set the event to the function null argument, you can call it without havoing of clicking on anything...

    function whateverBtnClicked(evt:MouseEvent=null):void {}

    etc...

    }

    So if you need perform this function without clicking the button you can just use...

    whateverBtnClicked();

  • Read multiple audio files with a single button - Playlist

    Hello

    im working on an interactive project that require the playlist function,

    The idea is to have a single button on a page that will play all the audio files on the page in the order they

    as you play a complete album in itunes or other players, when the first ending song the following begin to play and so on.

    Any ideas?

    Thank you

    Guy

    (1) put all the audio files in the Indesign document.

    (2) create a button,

    3) go to the Control Panel button and add multiple actions for 'Her', and for what actions define the audio file name

    Now go to the Panel of Timing and to organize the sequence of the audio file to read, just as the Panel layer, (drag / drop)

    Check the output.

  • Removal of MSQL 2 tables with a single button

    As I was able to add data from two tables mysql with a single button, I guess I should be able to delete the two entries in a similar way, but I can't seem to get there. The code is written in large part by DW and I have only the level minimum idea of the meaning of the php, so please be patient in no explanation as to where I'm wrong!
    At the present time, to the chk_sixmonth of the table entry is removed, but at table cel_contents incorrect records are deleted.
    The corresponding code is, I think;
    If ((isset($_POST['ck_pk'])) & & ($_POST ['ck_pk']! = "") & & (isset($_POST['gone']))) {}
    $deleteSQL = sprintf ("DELETE FROM chk_sixmonth WHERE ck_pk is %s",
    GetSQLValueString ($_POST ['ck_pk'], "int"));

    @mysql_select_db ($database_tormented3, $tormented3);
    $Result1 = mysql_query ($deleteSQL, $tormented3) or die (mysql_error ());

    $deleteGoTo = "chk_insert.php";
    If (isset {}
    $deleteGoTo. = (strpos ($deleteGoTo, '?'))? « & » : « ? » ;
    $deleteGoTo. = $_SERVER ['QUERY_STRING'];
    }
    header (sprintf ("location: %s", $deleteGoTo));
    }

    If ((isset($_POST['cel_pk'])) & & ($_POST ['cel_pk']! = "") & & (isset($_POST['gone']))) {}
    $deleteSQL = sprintf ("DELETE FROM cel_contents WHERE cel_pk is %s",
    GetSQLValueString ($_POST ['cel_pk'], "int"));

    @mysql_select_db ($database_tormented3, $tormented3);
    $Result1 = mysql_query ($deleteSQL, $tormented3) or die (mysql_error ());

    $deleteGoTo = "chk_insert.php";
    If (isset {}
    $deleteGoTo. = (strpos ($deleteGoTo, '?'))? « & » : « ? » ;
    $deleteGoTo. = $_SERVER ['QUERY_STRING'];
    }
    header (sprintf ("location: %s", $deleteGoTo));
    }

    $colname_rstSix = "1";
    If (isset($_GET['scrap'])) {}
    $colname_rstSix = (get_magic_quotes_gpc())? $_GET ["scrap"]: addslashes($_GET['scrap']);
    }
    @mysql_select_db ($database_tormented3, $tormented3);
    $query_rstSix = sprintf ("SELECT * FROM chk_sixmonth WHERE ck_pk = %s", $colname_rstSix);
    $rstSix = mysql_query ($query_rstSix, $tormented3) or die (mysql_error ());
    $row_rstSix = mysql_fetch_assoc ($rstSix);
    $totalRows_rstSix = mysql_num_rows ($rstSix);

    $colname_rstCont = "1";
    If (isset($_GET['scrap2'])) {}
    $colname_rstCont = (get_magic_quotes_gpc())? $_GET ['scrap2']: addslashes($_GET['scrap2']);
    }
    @mysql_select_db ($database_tormented3, $tormented3);
    $query_rstCont = sprintf ("SELECT * FROM cel_contents WHERE cel_pk = %s", $colname_rstCont);
    $rstCont = mysql_query ($query_rstCont, $tormented3) or die (mysql_error ());
    $row_rstCont = mysql_fetch_assoc ($rstCont);
    $totalRows_rstCont = mysql_num_rows ($rstCont);
    ? >
    <! DOCTYPE etc...

    < form action = "" method = "post" name = "scrap" id = "scrap" > "
    < input name = "gone" type = "checkbox" id = "gone" value = "gone" / >
    < input type = "submit" name = "Submit" value = "Remove" / >

    < input name = "ck_pk" type = "hidden" id = "ck_pk" value = "<?" PHP echo $row_rstSix ["ck_pk"];? ">" / >
    < input name = "cel_pk" type = "hidden" id = "cel_pk" value = "<?" PHP echo $row_rstCont ["cel_pk"];? ">" / >
    < / make >
    Thanks for any help

    Problem has now well sorted.

  • can I save two devices on a single iCloud?

    can I save two devices on a single iCloud?

    Yes, if they use the same account Apple ID (iCloud).

    http://www.Apple.com/icloud/Setup/

  • can I have two apple on a single device ID

    can I have two apple on a single device ID

    Hi, no you can use only a single iD associated with a single device.

  • HP 50 g: connecting two functions in hp 50g

    Hi, is it possible to create a library by linking the two functions. I mean, the output of one function matches the entry of another function?

    Thank you!

    REYNEL.

    REYNEL wrote:

    Hi, do, I thank very you much for your interest to help with this problem.

    I want to create a library that connects or call s one or more functions or expressions seated in different libraries. For example.

    There is in the library has a function y = f(x) * g(x) + h (x)

    In the library there is another function, called m (x) = 2 x + bx ^ 2 + y for example.

    I want the new library will be able to call A library and use the result of this library in this case (y) and put it as an entry in the function of m (x) of the library.

    Is it clear now?

    Thank you very much for your support.

    REYNEL.

    Still not clear enough, pls give more specific example, as in "m (x) = 2 x + bx ^ 2 + y".

    How many libraries you want, two (has and B), or three (has, B and a new library - "I want the new library of power...") »).

    If you give an example detailed perhaps someone will be able to give you the answer, if you ask a general question, you will get references to books or comments of a general nature only.

Maybe you are looking for

  • automatic redirection problem 9.3 IOS

    I'm almost in tears at the moment that my Apple products are practically unusable - I even had to resurrect my faithful laptop windows in order to access the Apple support. We have pro iPad and iPhone 6 s, 6th Gen iPod, iPad Air II and since upgradin

  • How to install a "USBAUDIO.sys" under windows XP?

    I just bought NSB USB Mini speaker, model - V300-black of the Wal-Mart store. I just plugged my USB speaker for my Netbook (OS Windows XP) and then the "USBAUDiO.sys or USBAUDIO.sy_ files are missing in Windows XP. After that, I try to download the f

  • How can I restore my computer to factory settings with using the computers original disc?

    Original title: ' ideas: insert an error code or give a brief description of what you're trying to accomplish or difficulty. " __ » I want to know how I can restore my computer settings to factory with using the original disk of computers or to creat

  • Windows 7 se shutsdown

    Hi, I'm having a problem with Windows 7, it keeps restart unexpectedly.  I have it installed on a new hard drive, cleaned the pc of dust on the fans, still of processors etc (only in case of overheating problem), but it restarts. Very frustrating whe

  • All printers are gone

    I have a computer with Windows 7 family SP1 updated with a HP OfficeJet 6600. I've used this for over 3 years. Now, when I restart or shut down the computer and I try to print, I get "no printer installed." "Is not only my 6600 does not, but"Foxit Re