My AS3 buttons only work the first time

I set up my buttons so that are each a movieclip with 'plus' and 'out' States/frame labels. They exist in the main timeline. Their control actionscript code is located in a frame on the main timeline and the holding frame that actionscript is about even in the main scenario where the buttons are introduced. I use actionscript 3.

The buttons have been implemented so that they navigate to another image in the main scenario and on this frame are a film. The dimensions of the movie are smaller than the main stage so that the buttons are still accessible when each video is played.

The problem is that my buttons work only once - by that I mean they go to the correct place when you click on the first time, but when they are clicked they still sail elsewhere.

Totally doing my head in trying to find a solution and if someone can help and show me what I'm doing wrong, what would be really useful. Here is the code I used for the buttons...

Stop();


function mainBtnOver(event:MouseEvent):void {}
event.target.gotoAndPlay ("over");
}
/////////
function mainBtnOut(event:MouseEvent):void {}
event.target.gotoAndPlay ("out");
}

CLICK INDIVIDUAL BUTTON FUNCTIONS
function mainBtn1Down(event:MouseEvent):void {}
gotoAndPlay ("01Movie");
}
function mainBtn2Down(event:MouseEvent):void {}
gotoAndPlay ("02Movie");
}
function mainBtn3Down(event:MouseEvent):void {}
gotoAndPlay ("03Movie");
}
function mainBtn4Down(event:MouseEvent):void {}
gotoAndPlay ("04Movie");
}
function mainBtn5Down(event:MouseEvent):void {}
gotoAndPlay ("05Movie");
}


Button 1 listeners
mainBtn1.addEventListener (MouseEvent.ROLL_OVER, mainBtnOver);
mainBtn1.addEventListener (MouseEvent.ROLL_OUT, mainBtnOut);
mainBtn1.addEventListener (MouseEvent.CLICK, mainBtn1Down);
2 button headphones
mainBtn2.addEventListener (MouseEvent.ROLL_OVER, mainBtnOver);
mainBtn2.addEventListener (MouseEvent.ROLL_OUT, mainBtnOut);
mainBtn2.addEventListener (MouseEvent.CLICK, mainBtn2Down);
Button 3 listeners
mainBtn3.addEventListener (MouseEvent.ROLL_OVER, mainBtnOver);
mainBtn3.addEventListener (MouseEvent.ROLL_OUT, mainBtnOut);
mainBtn3.addEventListener (MouseEvent.CLICK, mainBtn3Down);
Button 4 listeners
mainBtn4.addEventListener (MouseEvent.ROLL_OVER, mainBtnOver);
mainBtn4.addEventListener (MouseEvent.ROLL_OUT, mainBtnOut);
mainBtn4.addEventListener (MouseEvent.CLICK, mainBtn4Down);
Key 5 listeners
mainBtn5.addEventListener (MouseEvent.ROLL_OVER, mainBtnOver);
mainBtn5.addEventListener (MouseEvent.ROLL_OUT, mainBtnOut);
mainBtn5.addEventListener (MouseEvent.CLICK, mainBtn5Down);

I'm sure it's doing me something very stupid - I am very new to AS3. Any help much appreciated.

Thank you :-)

If the image labels, you have video clips that have the content of your presentation, you must use gotoAndStop ("frameLabel") instead of gotoAndPlay ("frameLabel"). There is no need to play the main scenario, when you go to and present one of these clips. I don't know if that's your problem, but... Using your code, I had no problem.

In addition, you can configure your animated buttons in a way that eliminates the need to have your ROLL_OVER and ROLL_OUT event. It is not necessarily better, but just another method. Although I could use other ways to animate a button, I don't want to reduce the code to use the buttons in an interface and use only the CLICK in the majority of cases.

Tags: Adobe Animate

Similar Questions

  • Menu Spry - only works the first time, or two

    I've implemented a Spry menu, according to the book (a half dozen or more main menu items, a couple of those, with three elements of the submenus - of course, it is a model applied to the relevant pages). It works very well in live pages on the web. Then after one or two openings of the menus, the lower two-thirds of the menus stop working! The menus of one or two albums always do their thing, but the rest of them no longer open the linked page. This has happened at the opening of the page on Mac Safari and IE7 Windows.

    At least once, clear the cache on Safari fixed temporarily - then the problem came back...

    Is this a known issue? Are there workarounds?

    Very well, thank you in advance! I need to make this page work, and this problem has me buffaloed.

    Well you helped me a lot, thanks

    Your insight on the code was right, and we had a bad page. Incidentally the model was not correctly updated until what we fixed another problem.
    lmo1

  • Firefox anchor link works the first time, fails the second time

    My site uses anchor of the form href = #1234 file.htm links to access < a name = 1234 > in file.htm.

    It works fine when the site is loaded locally on my PC at home. When I download on my site platform it works the first time I use, then fails by jumping to the top of file.htm. IE works fine on the platform of the site as well as on my PC at home.

    Hello

    I'm glad to hear that your problem has been resolved.

    If you have not already the case, please mark this thread as solved by the solution of marking.

    This will help other users experience similar problems helps to find faster and more efficiently.

    I hope that you will continue using our products and we thank you for contacting the Mozilla Support.

  • Why the VI does not work the first time?

    Hello fellow users of LabVIEW

    I did a VI that pulls data from a worksheet and then manipulates the data in different rows and columns to give a final spreadsheet of desired values.

    This VI works fine for me, except when I run the first time only, in which case it gives me values of nonsense.

    Could you please tell me what I'm doing wrong with the block diagram. It could be a problem with the data stream.

    Thank you

    mhaque

    My guess was very good.

    Yes, you have a race condition.  You read some values through a local variable in the upper part of your VI.  But you write in fact of all values of these indicators until the first image in your sequence structure.  Either thing could happen first, but it is very likely that your local variables are read first.  Thus the default data meaningless.  You should put these calculations in the first image of the sequence structure.  And use wire to one of the constants in the calculations rather than a local variable.

    In fact, I don't know if you need to use local variables anywhere in your VI.  And I also believe you can eliminate both your internal and external sequence structures.  You should always use wires to define your data flow.  The structure of your internal sequence pretty well done this already.  And if you get rid of your local variables and connect to the source of these values, no sequence structure, no variables, and no race condition.

    Try this VI.  I cleaned up.

  • Music player "Shuffle all" don't work the first time, you must go back and tap it again every time that the application starts, what gives?

    On the Open of ZTE, the music player "Shuffle all" failed the first time, pressed, instead, it will just load a song at random and read the rest of the list in the order; It's not until I click "Shuffle all" and back again it will play in fact mixed. Is this a bug? All solutions?

    Hello

    Yes, I think that it is a known bug in Firefox OS v1.0. Bug 883781.

    The bug is marked as resolved in Firefox OS v1.1. Once that ZTE full update to version 1.1 the bug on your device.

    version 1.1 of Firefox OS was officially released yesterday. If all goes well, it won't be too long before it reaches the Open of ZTE. See here for more details:

    Update OS of Firefox (1.1)

    I hope this helps.

  • AutoPlay doesn't work the first time

    Our client is to get a little upset by something happens with their outputs CP4, and I don't know if this is 'normal' or something is wrong.

    The .swf/html play very well the first time.  However, if a user goes again and run the file once again, he plays the first slide, and then jumps to the end.  We checked our navigation and it seems to be well (go to the next slide). We have removed the status indicators, think there is a kind of updated cookie that has identified this module as it was already performed by the user.  The problem occurs if it is served from a server web or played on a local computer.

    I take a great success on this.  And I don't know where else to look at.

    I need to fix it... any suggestions?

    Thanks heaps.

    Hello

    My guess is that you have to click on project > Table of contents. Then click on settings... and make sure that the Self Paced Learning option is disabled.

    If you find that the option is already cleared, you could then review the version of Flash Player.

    See you soon... Rick

    Useful and practical links

    Captivate wish form/Bug report form

    Certified Adobe Captivate training

    SorcerStone blog

    Captivate eBooks

  • I chose "sort bookmarks by name" and it worked the first time, but now with additional bookmarks, I can't sort by name more and it's a confused mess...

    I added new bookmarks, they are not produced according to the name that is the option I chose. Why is it no longer works? Even when I try to re - select "Sort by name", it does nothing. Someone at - it experience with this?

  • Reading text file takes a long time after the first time

    Dear experts LabVIEW,

    I'm having a problem with playback of text file. I'm reading only each Nth line from a file to preview with this sub vi:

    I seems to work the first time I do it well. The loop takes almost no time to perform an iteration.

    Then when I load the same file with exactly the same parameters an iteration takes about 50ms.

    Subsequent attempts always seem to take longer execution time.

    Only when I restart the calling vi fast for a single file.

    When executing the sub vi alone it is still fast, but I don't see how the main vi (too complex to post here) could hinder the execution of the Sub vi.

    I have no one else to open the file in the main vi, I do not use too much memory...

    Just now I have not now where to look. Does anyone have an idea?

    Concerning

    Florian


  • How to get on board to ignore a trigger after the first time she played

    Hi all

    I have a symbol that is activated by clicking a button.  The symbol has two triggers at various points on his script.  Each trigger activates a distinct symbol.  I want the two triggers to work the first time through, but on the second and each time, I would like to the first condition to be ignored.  There is probably a bit of code that will do this very easily (perhaps an if else statement?), but I'm afraid I'm not very good at that.  Any ideas on how to achieve this? Any help would be greatly appreciated!

    See you soon and good luck!

    Another attempt: Test-2-2 revised.zip - Box

  • iframe to open the pdf on the website does not work the second time

    On my site, I use < iframe > to open the pdf in the page.

    All the links work the first time.  But if I want to choose another, nothing happens.  If I refresh the page, it turns off, then will work once again.

    I've read a lot of old post, but couldn't find a solution or work around.  Any ideas?

    Or, if it does not, then I opened it with the bookmarks already open?  Then I shouldn't be the submenu nav for each chapter.  Afraid users wouldn't know how to open the bookmark on their own.

    This is for IE.  Help, please.

    Here are some of my code

    < ul class = "" >

    " < li > < a href =" http://sharepointFiles.PDF "target ="myIframe"> REGISTER < /a > < /li > "

    " < li > < a href =" http://sharepointFiles.PDF#page=5 "target = 'myIframe' > NEW LAYOUT < /a > < /li > "

    " < li > < a href =" http://sharepoinFiles.PDF#page=7 "target ="myIframe"> < /a > < /li > DROP market "

    " < li > < a href =" http://sharepointFiles.PDF#page=9 "target = 'myIframe' > new PRICE < /a > < /li > "

    " < li > < a href =" http://sharepointFiles.PDF#page=11 "target ="myIframe"> ADDITIONAL INFORMATION REQUEST < /a > < /li > "

    < /ul >

    < div class = "w3-show" >

    < iframe src = "#" name = "myIframe" style = "width: 718px;" height: 900px; "frameBorder ="0"> < / iframe >

    < / div >

    An "iframe" isn't a product, it is a type of HTML element used to incorporate another document within a web page.

    The OP is using Adobe software, most likely, or Open PDF settings would not work for them all the...

    To answer the question: he is probably the way the file is cached by the browser. I don't know there are many, you can about this, but you can tell the Bookmarks panel to appear by default using two ways: you can use the "pagemode = bookmarks' open parameter in the URL, or you can set options for initial view of the PDF file itself to show (under file - properties - view initial - tab Navigation).

  • Interactive report Javascript Refresh, working only the first time

    Hello

    I'm trying to implement a dynamic action on an interactive report that fires a pl/sql procedure and then reload the IR.

    I have something like this:

    Select par.*,
    CASE
    WHEN (SELECT 1 OF THE AddressBook ch WHERE ch.usr_id = (select id where email = usr: APP_USER) AND ch.address_id = par.id) IS NOT NULL
    THEN ' < img src = "" #IMAGE_PREFIX #wwv_cancel.gif "class alt"Y"="delAddressFromBook"id =" "| par.ID | "" / > "
    ELSE ' < img src = "" #IMAGE_PREFIX #add.gif "alt ="N"class ="addAddressToBook"id =" "| par.ID | " » / >"
    Mapped END
    of nominal addresslist

    My dynamic action uses the '.addAddressToBook' jquery selector, and it fires properly the first time I click Add image. My pl/sql code runs correctly and ist updated IR.
    It is, when I click the second time in another entry, nothing happens. Looks like the javascript works always something.

    Updating of the IR ist done with javascript gReport.pull ().

    Thanks in advance.

    Florian

    Florian,

    If you bind an event javascript on an element that is get updated then after that it gets updated, it will no longer be bound to her event. It is possible to use the event to this situation (http://api.jquery.com/on/) delegation, he took advantage of event bubbling (http://www.quirksmode.org/js/events_order.html) and handles the event to an element that is not updated to a kind of AJAX call.

    Edit
    The following code binds the event listener for the document, but it does that raise the event handler if the initiator of the event matches the selector ".addAddressToBook". I chose the document object, because each page has a document, but you can consider using a parent element that is much closer to the initiator of the event.

    //jQuery 1.7+ use "on"
    $(document).on("click", ".addAddressToBook", function(event){
        alert('addAddressToBook Clicked');
    });
    
    //jQuery1.4.2+ use "delegate"
    $(document).delegate(".addAddressToBook", "click", function(event) {
        alert('addAddressToBook Clicked');
    });
    

    Good luck
    Janet Tyson

    Published by: Tyson Janet on January 23, 2012 07:27

  • I want to record with &lt; alt &gt; &lt; s &gt; in the Exact program online. This function does not work. This is the first time I use this program with firefox.

    Question
    I want to record with < alt > < s > in the Exact program online. This function does not work. This is the first time I use this program with firefox.

    edit, escaped mod < s > in order to avoid the line through question

    A web page can be defined a "accesskey" for an item. Unlike IE/Chrome/Safari, who use the Alt key only, Firefox requires pressing Alt and Shift to activate the element. In other words, try

    ALT + SHIFT + S

    and see if it works.

    I don't know of any way to change this so that the change is not necessary. There may be an add-on?

  • Animation works, simply at the first time

    it :)

    I thought that I finished my animation film. But after a test in the browser, I recognized that my work doesn´t of very good animation. There is a symbol in my animated film, it appears when you click on an image and if you click on a button, it starts to play and loops. If you click again it closes.

    My problem is that it works when you start the symbol for the first time. If you close and open it again it s just start somewhere in the middle of the animation without hitting the button.  Some had the same problem or can help me?

    Mr. monsen

    HM sounds to me like you have the movie playing on the loop and when you click a button, it automatically the convening as the animation by showing it.

    Meanwhile, he always plays on the loop.

    What you probably need to do, is to tell him to play from the first image of this symbol (0).

    I don't know how you got your composition in place, but something like this:

    sym.getComposition () .getStage ().getSymbol("ANIMATIONSYMBOL").play (0);

    .. prolly could be simplified if you use the coding directly on the button.

    So basically, as well as the code that turns on the visibility of the button, you'll want to play 0.

    I hope this helps!

  • Order for the first time lost all work and settings.  It can be recovered?

    Close my new Macbook Pro for the first time.  I lost all my work and my settings.  Almost anything can be recovered?

    He was an administrator account or a guest account?

  • Satellite Z30-A104 - the first time I try to turn on the pc do not work

    I need to press the button 'market' twice to turn on the laptot if the laptop is turned off. The first time that I press the button, I see the toshiba logo and a second later disappear and they turn out at all. The second time, I don't have any type of problem. Still it happened, any solution?

    The laptop is running windows 8 and I bought last month.

    Hello

    If Windows 8 is installed, I guess that the laptop is not to stop completely, but his game to + closed hybrid. +

    I would recommend that you do not have a full stop down as described here:

    [Perform a complete shutdown in Windows 8 | http://aps2.toshiba-tro.de/kb0/TSB2B03EY0002R01.htm]

    Your comments would be appreciated

Maybe you are looking for

  • Firefox will import the homepage automatically from my old browser when it is installed?

    Firefox will import the homepage automatically from my old browser when it is installed? If so, is this the case for IE8, Chrome etc.?

  • This win to install a SSD drive in a PowerBook G4?

    Hello I wonder if installing an SSD in my PowerBook G4 17 "would make sense, either replace the drive of 80 GB original or being a carrier of replacement instead of the SuperDrive, which can be done. I read somewhere, but that because of the PB G4 PA

  • startup problem, this entry is normal?

    Hi, I have a few annoying problems when I start my pc, I still get startup entries and I can't seem to find a way to get rid of them.Ive tried to install Windows xp on another partition but I failed and now whenever I start my pc I get this entry at

  • Embeded Web Server is not responding

    I wanted to use the scan to a network using this HowTo folder: http://h20628.www2.hp.com/km-ext/content-webapp/document?docId=emr_na-c03518544&dtd=default&locale=d... (German, but I suppose a similar site is available in English). However, it seems t

  • InDesign CC Installation uber Cloud Creative

    Hallo,ICH would unbedingt InDesign CC 2015 testen - leider die Installation EIB 45% AB Gingold. So uber creative cloud.Am mit Win7, PC...Für Tipps und Hilfe ich sehr thankful ware.