AS3 button = 2 functions a bit complicated

I have swing_mc on the main timeline of an .swf
I need to have swing _mc do two things
1. on rollover to play
2. on click to gotoAndStop ("framename") main timeline
I have an invisible button INSIDE swing_mc on the top layer, this is because the mc is supposed to swing back and forth so the inv btn must be on top of the mc to follow the motion path.
if there is a solution this way that would be fine, if not I was just thinking:
the mc is a picture swinging from side to side, if I put an invisible button on the main timeline over most of the area the button swings over and covers I think that would work, but then I would have to target the swing_mc timeline for it to play correct?
How and which way do I code this?
Thx!

For the first function you should only need...
function swingBtnRoll(event:MouseEvent):void{
    swing_mc.play ;
The parent reference could be a problem since there is none except maybe the Stage.
And for the second function, you need to place the frame argument in parentheses
function swingBtnClick(event:MouseEvent):void{
    gotoAndStop("swing") ;
You mention something about a button, so I don't know if you want to assign the event listteners to the swing_mc or the button you mention.

Similar Messages

  • My AS3 buttons only work the first time

    I have set up my buttons so that are each a movieclip with 'over' and 'out' states/frame labels. They exist on the main timeline. The actionscript controlling them is situated in a frame on the main timeline and the frame holding that actionscript is on the same point within the main timeline where the buttons are introduced. I am using actionscript 3.
    The buttons have been set up so that they navigate to another frame on the same main timeline and on that frame is a movie. The movie dimensions are smaller than the main stage so the buttons are still accessible when each movie is played.
    The problem is my buttons are only working once - by that I mean they go to the correct place when clicked the first time, but when they are clicked again they navigate elsewhere.
    Totally doing my head in trying find a solution and if anyone can help and show me what I'm doing wrong that would be really really helpful. Here's 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");
    ///////// INDIVIDUAL BUTTON CLICK 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);
    ////////// Button 2 Listeners
    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);
    ////////// Button 5 Listeners
    mainBtn5.addEventListener(MouseEvent.ROLL_OVER, mainBtnOver);
    mainBtn5.addEventListener(MouseEvent.ROLL_OUT, mainBtnOut);
    mainBtn5.addEventListener(MouseEvent.CLICK, mainBtn5Down);
    I'm sure it's me doing something very stupid - I'm very new to AS3. Any help much appreciated.
    Thanks :-)

    If the frame labels you are going to have movie clips that have your presentation content, you should use gotoAndStop("frameLabel") instead of gotoAndPlay("frameLabel"). There's no need to play the main timeline when you go to and show any of these movie clips. I'm not sure if this is your issue, though... Using your code, I had no problems.
    Also, you can set up your animated buttons in a way that eliminates the need to have your ROLL_OVER and ROLL_OUT events. This isn't necessarily better, but just another method. Although I might use other ways to animate a button, I do like to reduce the code it takes to use the buttons in an interface, and only use CLICK in most cases.

  • Exit button not functioning in MSS Team - Recruiting - Create new Candidate

    Hello Experts,
    Exit button not functioning in MSS Team - Recruiting - Create new Candidate Assessment iview
    Location of exit button :Create new Candidate Assessment iview we have next button when we click on we can see exit button in next iview
    any idea why it not functioning / help on this / or is it a bug from SAP
    Thanks,
    Regards
    Vijay

    Hi Krishore,
    Thanks for reply,
    The version of BP_ERP5ESS is 1.0 SP8 and The version of SAP_ESS is  600 SP8.
    do need to add extra patch for this.
    please help me on this issue. 
    Thanks,
    Regards
    Vijai

  • Radio buttons in function module.

    Hi,
    I have developed a function module which internally calls abap report with SUBMIT command.  However, the abap report has radio buttons on selecton screen.  So I would like to know how to define radio buttons in function module or is there any alternative to overcome this problem?
    ABAP code in function module :
    submit zodmr_report    with p_vkorg = bukrs
                             with s_off  in vkbur
                             with s_vtweg in vtweg
                             with s_spart in spart
                             with s_dsa in dsa
                             with s_ext in allocation_id
                             with p_yyyymm = year_month
                             and return.
    ( ABAP report "ZODMR_REPORT" has two radio buttons)
    Regards,
    Santosh

    Hi,
    To the best of my knowledge you need to create an IMPORT parameter of type SY-DYNNY And pass your selection screen to the FM. If this will not serve your purpose, then Instead of Standard Selection Screen with number 1000, use custom defined Screen number.
    Cheers
    Ram

  • IPOD Mini front panel buttons not functioning

    First of all, thanks for reading my message.
    I have this wierd problem. My front panel buttons namely Menu, forward, rewind, play/pause and wheel donot work.
    The thing that is wierd is that my ipod is still functional using the remote. Even when I am playing MP3s using remote, those regular buttons dont function. They look like they are dead, no response what so ever.
    Since the remote has limited buttons I want my front panel buttons to work. Any inputs on this regard is appretiated.
    P4   Windows XP  

    More details:
    I can charge my IPOD.
    sync it to itunes.
    Hold works.
    ear phone jack works.
    In all my IPOD is in a state similar to what you have when you switch to "HOLD". Irespective of whether I swith the hold button or not.
    P4   Windows XP  

  • How to create a push button to function like a File Browsing button

    Hi...
    I am a beginner with Oracle Forms developer.. and I have a project which requires me to create a button to function like a file browsing button.. so that I can select a file to check for changes made to it.. And if changed to copy the file to another location...Please could u guys help me with this!!
    Thanks!!

    Hi,
    What is your forms version?
    Check this out if you are using web forms.
    http://www.oracle.com/technology/sample_code/products/forms/extracted/hyperlink/fileupload.html
    If you are using client server, check out the online help for GET_FILE_NAME built-in
    Also, you can check out the webutil (for web forms >= 10g)
    -Arun
    Edited by: Arunkumar Ramamoorthy on Sep 10, 2009 1:49 AM

  • My N73 ME Music Button Not Function

    Dear All,
    Please help me.
    My Nokia N73 ME, I buy last 2 month having problem.
    {problem}
    Music Button stop functioning after ON so long time.
    Power OFF and ON again the Music Button can function again.
    After several hours ON, the problem occured again.
    Last week I already update New Firmware version V4.0727.2.2.1 04-07-2007 still can not solve this problem.
    Anyone facing same problem and what the countermeasure?
    Thank you.
    Best regards,
    Abramosa

    I have got the same problem...No choice I have add shortcut to top menu to play my music
    N73 ME - V 4.0839.42.2.1 (27-09-2008)

  • N73 ME Music Button stop functioning

    Dear All,
    Please help me.
    My Nokia N73 ME, I buy last 2 month having problem.
    {problem}
    Music Button stop functioning after ON so long time.
    Power OFF and ON again the Music Button can function again.
    After several hours ON, the problem occured again.
    Last week I already update New Firmware version V4.0727.2.2.1 04-07-2007 still can not solve this problem.
    Anyone facing same problem and what the countermeasure?
    Thank you.
    Best regards,
    Abramosa

    I have got the same problem...No choice I have add shortcut to top menu to play my music
    N73 ME - V 4.0839.42.2.1 (27-09-2008)

  • My sound button cant function even the sound also not sound but when i received call, it do ring..just when i try to play utube or play music it will never have sound...please help me. now i'm using ios7. It just recently happened.

    My sound button cant function even the sound also not sound but when i received call, it do ring..just when i try to play utube or play music it will never have sound...please help me. now i'm using ios7. It just recently happened.

    Hi hayscart,
    This article contains steps to try when you are having trouble with the iPhone's speaker:
    iPhone: Can't hear through the receiver or speakers
    http://support.apple.com/kb/TS1630
    Cheers,
    - Ari

  • Bluetooth keyboard button stops functioning

    Hey guys,
    I got to buy me each year at least one new bluetooth keyboard as some day one of the keys stop to work.
    Last time it was the W and this time now it is Q button stop functioning.
    Any idea if this is a known qality issue of the keyboard or if there is a way to reset or any thing like that.
    I like the kb but it really ***** I got to buy me a new one at least once a year.....
    Let me pls know if you have got any advise or having made same experience..
    /frank

    Hi JMackey,
    Is there the same issue when sending emails via OWA?
    If you use "Ctrl+Enter" shortcut to send the email when the issue occurred, how about the result?
    Best regards,
    Niko Cheng
    TechNet Community Support

  • Stolen iPad (bit complicated)

    Dear Y'all,
    Like the title said, it's a bit complicated situation I'm in now..recently my iPad got stolen, and I managed to track it back to the last location the culprit was. However the culprit immediately shut off the device so I couldn't track it further. I try the Police, but they ask me for proof of ownership..and here is the my situation...:
    I bought the iPad from my friend who had his iPad replaced due to product defect. He got a receipt that concisted all the new information regarding the replacement iPad from Apple authorized reseller. The thing is, I lost the receipt...I only have its box that doesn't match with the iPad serial number nor IMEI because it has been replaced... However, months before the event, I registered my device to "Find my iPhone" app... to process my case, the Police needs my serial number and IMEI, and my question is: "Is there possible to retrieve the iPad information from iCLoud?" because I tried and there was not much information you could access into your each device..
    Thanks

    These links may be helpful.
    How to Track and Report Stolen iPad
    http://www.ipadastic.com/tutorials/how-to-track-and-report-stolen-ipad
    Reporting a lost or stolen Apple product
    http://support.apple.com/kb/ht2526
    Report Stolen iPad Tips and iPad Theft Prevention
    http://www.stolen-property.com/report-stolen-ipad.php
    How to recover a lost or stolen iPad
    http://ipadhelp.com/ipad-help/how-to-recover-a-lost-or-stolen-ipad/
    How to Find a Stolen iPad
    http://www.ehow.com/how_7586429_stolen-ipad.html
    Apple Product Lost or Stolen
    http://sites.google.com/site/appleclubfhs/support/advice-and-articles/lost-or-st olen
    Oops! iForgot My New iPad On the Plane; Now What?
    http://online.wsj.com/article/SB10001424052702303459004577362194012634000.html
    If you don't know your lost/stolen iPad's serial number, use the instructions below. The S/N is also on the iPad's box.
    How to Find Your iPad Serial Number
    http://www.ipadastic.com/tutorials/how-to-find-your-ipad-serial-number
     Cheers, Tom

  • Confused about AS3 buttons (did read David Stiller's blog)

    I'm trying to convert an AS2 file over to AS3 and I can't get
    the buttons to work. They do not want to gotoAndStop at certain
    frames in specific scenes. In the following code, if you click on a
    button it works fine, but when you attemp to change to a new Scene,
    it breaks and both buttons won't work thereafter. I've tried
    everything for almost a day now and cannot get this to work and
    cannot find any reference to the problem. Is AS3 buttons not able
    to go to a new scene as it suggests in the Help files?:

    Laura,
    > Old patterns, old habits...time to change.
    Well, not necessarily! The old ways still work. :) Just
    configure
    your publish settings for AS2 or AS1, and bingo. It all
    depends on what
    you're trying to accomplish. If your aim is to output to TV,
    then by all
    means, use scenes! If you're not using code -- or using very
    little code --
    then it basically doesn't matter what version of ActionScript
    you use.
    > Now the flash animation drawing tools are so lame it's
    just
    > embarrassing. It's all about interactivity and coding is
    essential.
    I can hear that you're frustrated, and it probably helps to
    vent (it
    often helps me), but for the sake of others who might be
    reading this
    thread, I'm respectfully asking you for specifics. What new
    animation
    and/or drawing tools do you mean? How are they embarrasingly
    bad?
    The 3D and inverse kinematics (IK) tools, new to CS4, are
    hardly
    something I'd call embarrassing. On the contrary, they're
    cool all hell!
    True, the 3D tools require the FLA to be configured for AS3,
    but no
    scripting is required to use 3D or IK (though you *can*
    script them if you
    want to).
    The blend modes and filter effects introduced in Flash 8
    were a welcome
    edition. They didn't hinder anyone's workflow, as far as I
    know. If you
    wanted to use them, great! If not, great! Improved text
    rendering has been
    a joy ... and again, use it or not -- the choice has always
    been up to the
    designer's whim.
    > Ok, scenes are kinda old school. I can see why.
    They're only problematic (speaking historically) in cahoots
    with
    ActionScript. Unlike some, I actually do endorse the use of
    scenes ;) --
    just not in the context of programming. Keep using old school
    if that's
    what works for you. If you like, experiment with the new
    stuff as your
    schedule allows.
    > Why do anything in the timeline if you can do it in the
    code?
    I can't tell if you're being sarcastic in this line, but
    either which
    way, the answer (at least, from my perspective) is a
    pragmatic one. Use the
    timeline when doing so takes the least amount of work; the
    reverse holds
    true for code. There are plenty of animations --
    specifically, character
    animations, including lipsynch -- that, for me, are easier to
    do by hand, by
    direct manipulation of the symbols with my mouse and/or
    graphics tablet.
    I find it easier to design complex gradients using the
    drawing tools. I
    often find it easier to design complex tween eases by hand.
    When I'm
    working on animation, I tend not to code as often; when I'm
    building a
    Flash-based website, it's likely to be a combination of
    timeline techniques
    and code; when I'm writing applications, it's obviously a
    case of
    mostly-code.
    > [code gives you] more control. It can be more dynamic
    and
    > flexable. It is easier to edit. Next I need to do more
    external
    > .as doc scripting.
    Writing custom classes is another layer of technique.
    Depending on your
    workflow, it may or may not be useful. For what it's worth, I
    wrote a
    tutorial series for Community MX not so very long ago that
    might help
    illustrate this point ...
    http://www.communitymx.com/abstract.cfm?cid=ECBF0
    ... the first article is free, and demonstrates a technique
    (using code) for
    causing letters to wiggle into place. Over the course of
    several
    installments, this series works toward moving the code from
    the timeline to
    a class file, which shows how custom classes can provide a
    workflow boost,
    even for a movie that doesn't necessarily need to be
    übercoded in other
    respects. I hasten to add, I'm not one who relishes the role
    of a "Here,
    the first one is free" salesman, so be aware that you can
    also read the
    remaining articles free if you sign up for a trial
    membership, which you can
    cancel without obligation in a week's time.
    > My working file is now all on a single timeline with no
    scenes.
    > Who needs scenes. Yipee!
    Under the hood (meaning, in the SWF) all those scenes are
    ultimately
    converted to one big timeline anyway. Granted, the use of
    scenes is a
    convenient organizational tool during authoring, and I don't
    deny that
    scenes-with-ActionScript would be equally convenient, but
    again ... scenes
    have been "broken" in ActionScript for a long time. It looked
    like Flash
    CS3's AS3 finally resurrected the workflow, and -- for the
    time being -- it
    looks like CS4 might somehow be missing the mark. If so, as
    kglad proposes,
    the AS3 gotoAndPlay() issue is a bug in CS4, and we can hope
    for a fix from
    Adobe.
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • Is the on/off button bad function a hardware problem? What can I do if a mobile company don't fix this? Besides, my phone still have the apple warranty

    Hello everyone, I bought an iPhone 5 six months ago from a mobile company. now the on/off button is not working properly. I send it to this company technical service support and they didn’t fix it saying that the button problems are not covered by the warranty; moreover they say that warranty just covers software and hardware problems. First, is the on/off button bad function a hardware problem? What can I do if a mobile company don’t fix this? Besides, my phone still have the apple warranty

    Customer Service: Contacting Apple for support and service - this includes international calling numbers.
    Apple Store Customer Service at 1-800-676-2775 or visit online Help for more information.
    To contact product and tech support: Apple - Support - Contact Apple Support.

  • AS2 vs. AS3 Button

    So in AS2 to add button functionality to a movie clip, you'd
    type:
    myButton_mc.onPress=function(){
    gotoAndPlay("something");
    How is this accomplished in AS3 WITHOUT using external .as
    files, classes, etc?
    It seems like all the tutorials/books I read, they want to
    create the bible before anything can be done.
    If this is the case, why is AS3 better? I understand it
    appeals more to hard core programmers of Java, but what about
    therun-o-the-mill types who actually like Director's Lingo and can
    cope with AS2?
    Thanks!

    Well, one of the big advantages AS3 has is that it`s 10 times
    faster than AS2. Then, it`s easyer to learn for beginners, because
    everyting is done similarly( you decalre any variable the same way,
    every listener etc...) etc...

  • AS3 button state

    How to make a button stay down state after been clicked?
    stop();
    var ldr:Loader = new Loader();
    ldr.x = 300;
    ldr.y = 0;
    addChild(ldr);
    ldr.load(new URLRequest("myclip.swf"));
    projects_btn.addEventListener(MouseEvent.CLICK, clickFunction1);
    function clickFunction1(evt:MouseEvent):void {
    gotoAndPlay(2);

    If you create the button as a movieclip you can control of which frame/state it is in.  Otherwise, if it is a SimpleButton symbol, in AS3 you can change the upState property to equal the downState property, but then you would need to retain some reference of the upState if you plan to return there sometime later.  The movieclip approach gives more reliable control.

Maybe you are looking for