Simple two button AS3 problem

I have a (simple?) problem with Actionscript 3.0 in Flash CS4.

I'm eager to a button in a part of the timeline to jump to a button in another part of the timeline and then on again.

layers.gif

Click btn1 10 goto frame then click btn2 goto frame 1 - basic stuff.

This code works fine on its own for the 1 button:

Stop();


Btn1 is part 1-9

Btn1.addEventListener (MouseEvent.CLICK, btn11);

function btn11(event:MouseEvent):void

{

gotoAndStop (10);

}

But if I add the code to the second button I get and error:

TypeError: Error #1009: cannot access a property or method of a null object reference.

to Untitled_fla::MainTimeline/frame1()

Stop();


The two buttons are on the main timeline

Btn1 is part 1-9

Btn1.addEventListener (MouseEvent.CLICK, btn11);

function btn11(event:MouseEvent):void

{

gotoAndStop (10);

}


btn2 is in the frame of 10-20

btn2.addEventListener (MouseEvent.CLICK, btn22);

function btn22(event:MouseEvent):void

{

gotoAndStop (1);

}

Any help would be appreciated.

Kind regards

Richard

btn2 code must be attached to the frame 10 where the button is first.

When you attach it to the frame 1, this button does not exist when this image plays and the compiler produces an error warning you that your code does not work.

Tags: Adobe Animate

Similar Questions

  • Synchronization of the configuration shows two buttons

    I have correctly set up Firefox Sync and used Firefox for a while successfully Sync in the PC Windows standard user on 3 computers accounts. However, when I tried to sync the administrative account on a computer, I was unable to. Since then, whenever I'm doing a tools/configuration synchronization, or Tools/Options/synchronization on all my computers, only two buttons to the top: "Create a new account" and "I have an account". There is no button 'Manage account', not related to Unlink this computer from Sync, nothing. I tried all kinds of things and I looked a long time for help on this problem and have not found something to help. If I delete my account just to start and complete synchronization, it will work, or could I be causing other problems by doing this? Any other suggestions? Thank you.

    What do you see in the list of menu drop-down menu button Firefox?

    Is - this set up sync or synchronize now?

    If you have 'Set up sync' then you seem to have lost the configuration of the synchronization and you will have to redo the set up Sync.

    If this is not possible, then try to delete (or rename) the armor in the Firefox profile folder file and reset synchronization preferences on the topic: config page.

    You can use this button to go to the Firefox profile folder:

    • Help > troubleshooting information > profile directory: see file (Linux: open the directory;) Mac: View in the Finder)

    You can open the topic: config page through the address bar and to search for the prefs that begin with services.sync and reset set user prefs ("BOLD") through the context menu on the default value.

    If it still fails, then you can try a new profile.

    Create a new profile as a test to see if your profile is the source of the problems.

    See "create a profile":

    If the new profile works then you can transfer files from a profile in the new profile, but be careful not to copy files corrupted to avoid transporting on the problem.

  • Tecra S10 - 10F - Support Button Multimedia problem

    Hello

    I have Toshiba Tecra S10-10th with Win Vista SP2.
    I have problem with Toshiba button Support.
    After a clean install of Vista, everything works fine. Now two buttons next to the button toshiba walk / stop don't work. When I uninstalled 'toshiba value added package', buttons was answered but open "windows Mobility Center.

    When I installed Toshiba value added Pachage once again, the buttons are no longer...

    Could someone help me pls?

    THX

    Hello

    This strange s
    Usually the installation of VAP should help you get the buttons working again.
    Value added package contains tools and utilities that are necessary for the functionality of the multimedia buttons

    Please install the VAP, and then configure the keys still using the utility button Toshiba located in Toshiba Assist-> optimize

    There you have to click on the button, and then you set some for some exe file button.
    Single exe files are in C:\Programs\Toshiba\TBS

    Welcome them

  • Formatting text in "function of two button dialog box."

    With monitors high resolution, the text in the Panel that displays the function of two dialog button is often small and difficult to read (at least for these old eyes).  Is it possible to format this text?

    Roy

    You can make your own.

    Make a simple Subvi with two buttons and a text indicator. Make windows style 'dialogue' appearance and add some logic (for example an event structure) to flip the button which was pressed.

  • Using two buttons market timer / stop, need help please.

    Hey everybody.

    I am stil working on my project, and now I'm trying to implement a timer using two buttons market / stop. Everything I do now is when you press start the stopwatch starts and when you press stop I want the timer to stop and display the time.

    Whats happening is when I press start, the timer starts, but when stop is pressed the timer displays a value of say 12 seconds, a second more later I press stop again a value of 14secs arise and it stops at 14.  Now, whenever I press on start it will start at 14 and repeat this process.

    So I think that somewhere, I did not put my right timer.

    Could someone say somethings that I should change in my code.

    They are declared at the top:

    static public boolean status=false;
    static public int count=0;
    static public Timer timer;
    

    Here is my code:

    ButtonField start = new ButtonField("Start",ButtonField.USE_ALL_WIDTH|                          ButtonField.FIELD_HCENTER|ButtonField.USE_ALL_HEIGHT);                          start.setChangeListener(new Listener1());add(start);
    
    ButtonField stop = new ButtonField("Stop",ButtonField.USE_ALL_WIDTH|                            ButtonField.FIELD_HCENTER|ButtonField.USE_ALL_HEIGHT);                            stop.setChangeListener(new Listener2());                          add(stop);          
    
                public class Listener2 implements FieldChangeListener            {            public void fieldChanged(Field field, int context)             {            ButtonField btn = (ButtonField) field;            Status.show("Timer is at" + Integer.toString(count));            status = false;            timer.cancel();            }            }
    
                public class Listener1 implements FieldChangeListener            {            public void fieldChanged(Field field, int context)             {            ButtonField btn = (ButtonField) field;            Status.show("Timer started");            status = true;                try                {                                                timer = new Timer();                                        timer.scheduleAtFixedRate(new StartEvent(),1,1000);                }                catch(Exception e)                {                //do nothing                }            }
    
        private class StartEvent extends TimerTask    {    public void run()       {        if(status = true)              {              count++;                        }        else            timer.cancel();//        count=0;    }    }    }
    

    any help is appreciated

    Thank you guys

    Probably best to follow just a matter of a Thread.  So next time, you can start a new Thread with a new question.  However, you should also search the forum before asking questions, that your two supplementary questions have been answered in other posts on this forum.

    Concerning your problem to press the stop and get another moment, I think that you must have application logic that disables the stop button once pressed, until you press the Start button.  For example, you could do by assigning to the time of departure - 1 in the Stop button, and then, when you press the Stop button, he can check the start time and displays a message saying "Timer not started" If the start time is - 1.  There are a number of other ways to do this, I described this method because it is easy to explain.  It is not really how I'd do.

    The best way to set the buttons next, is to add then to a HorizontalFieldManager, then add the HorizontalFieldManager to your screen.

    To stop the button displays the menu, you must set it with the style CONSUME_CLICK, for example:

    ButtonField stopButton = new ButtonField ("Stop", ButtonField.CONSUME_CLICK);

  • Button formatting problem

    I'm having the button formatting problems in the footer of a muse (A Virtual Colorado fly fishing Field Guide) site and wonder if anyone can give some insight into what goes wrong.

    There are two buttons.  The 'Business' button text is formatted as bold Helvetica 14 points.  The 'Links' button is the same formatting, but has also 10 points 'Space before' in order to center the text in the button.  When I go to the home page of the site, Business button shows the text at the top of the key and the links in the Center as planned.  If I navigate to any another page the text of the button Business has been moved to the Center and the text of links to the bottom of the button and the button links has stretched vertically.

    Why would the buttons have this behavior?

    Just rebuilt the button.  Rather than start with a text box, used the State of the widget library button.  That seems to fix the problem.

  • 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 to position the two buttons at the top of the div inside a container div element?

    Hello!

    Good news...

    I created my very first thumbnail slider for my site that actually works!

    Bad news...

    The buttons that allow to scroll the div element, which is encapsulated in a container of Center, are are more placed on top of the div.

    Here's the html code:

    < div id = "centerContainer" >

    < div id = "aemcSlider" >

    < ul >

    < li >

    "< a class ="aemcPkgBut"href =" "target =" "alt ="AEMC Packaging"title ="AEMC Packaging"> < / has >

    < /li >

    < li >

    "< a class ="aemcGroundFlexBut"href =" "target =" "alt ="GroundFlexAd"title ="GroundFlex Ad"> < / a >

    < /li >

    < li >

    "< a class ="aemcClampBut"href =" "target =" "alt ="Clamp-On Announces"title ="Clamp-On Announces"> < / has >

    < /li >

    < li >

    "< a class ="aemcMetrixBut"href =" "target =" "alt ="Metrix Announces"title ="Metrix Announces"> < / has >

    < /li >

    < /ul >

    < / div >

    < div id = "leftBut" >

    "< a class ="arrowLeft"href =" "target =" "alt ="Left"title ="Left"> < /a >

    < / div >

    < div id = "rightBut" >

    "< a class ="arrowRight"href =" "target =" "alt ="Right"title ="Right"> < /a >

    < / div >

    < / div >

    Here's the CSS:

    Key container:

    #centerContainer

    {width: 800px; margin: 0 auto; background-color: #0e210e; position: relative}

    Div element:

    #aemcSlider

    {

    text-align: center;

    list-style: none;

    Width: 450px;

    height: 114px;

    margin: 0 auto;

    padding-top: 0px;

    padding-right: 0px;

    padding-bottom: 0px;

    padding-left: 0px;

    top: 67px;

    position: relative;

    overflow: hidden;

    }

    #aemcSlider a {margin right:-12px ;}}

    Left and right buttons:

    a.arrowLeft

    {

    Width: 29px;

    height: 96px;

    float: left;

    position: absolute;

    margin: 0 auto;

    display: block;

    background-image: url (.. / Images/arrowLeft.png);

    background-repeat: no-repeat;

    left: 311px;

    top: 91px;

    opacity: 0;

    }

    a.arrowLeft:hover

    {

    background-image: url (.. / Images/arrowLeft.png);

    opacity: 0.5;

    }

    a.arrowRight

    {

    Width: 29px;

    height: 96px;

    position: absolute;

    float: right;

    margin: 0 auto;

    display: block;

    background-image: url (.. / Images/arrowRight.png);

    background-repeat: no-repeat;

    opacity: 0;

    left: 720px;

    top: 92px;

    }

    a.arrowRight:hover

    {

    background-image: url (.. / Images/arrowRight.png);

    opacity: 0.5;

    }

    Here are the things I did to solve problems:

    If I set the div as a container for absolute, the left button disappears.

    I get the same effect when I change the relative position.

    I tried to change the position of relative to the two buttons.

    I also tried to position the buttons outside the div hand and no go.

    How can I position the relative div under these controller button?

    Any help would be appreciated muchly.

    ~ THE

    I don't see a slider.  The code of your slide seems to have a style inline with the width: 0px which is not normal.    Width should be about 400 px.

    I suspect that your arrows need a much z-index superior to appear on the top layers of cursor.  But that's just a guess because I don't see a slider.

    Nancy O.

  • Button link problems .swf

    Hello. I use Adobe Flash CS6. I have problems performing separate links 2-2 buttons. I succumbed. I made 2 different buttons and thought I did 2 separate links. But, when you click on the two buttons, they link to the same page. I want them to go to separate pages... Any suggestions? Here is a link to the file... Perhaps someone can pin point the problem?

    There is nothing terrible about the code, just a few things are missing.

    The problem with what you have now is you basically add two event listeners to the chronology of the main stage, so when you click on anything you trigger the two functions, but only one of them can win (probably the last executed) in the end.

    Click the button for the first set of code that show you and in the properties panel, assign it an instance name where it says ""... Let's say you name it 'page4Btn' then change your first line of code to be... ""

    page4Btn.addEventListener (MouseEvent.CLICK, fl_ClickToGoToWebPage_4);

    Then repeat for the other button, using a different instance for the button name.

  • Button navigation/problem

    Help! I'm at my wits end.

    I take an introductory class in Flash and working on a project for this class. Everything was going well until I started working on my navigation. I used the flat tube green buttons common library on the homepage and all the rest of the site used a dark color button I duplicated and colored from the Green flat tube button.

    My problem:

    I have an actionscript layer that should work throughout the entire timeline but is not. Originally, I had a keyframe for the frame that contained the green buttons and the other which stretched the length of the entire timeline, containing all the code for the buttons. I put scrapped that and tried to combine code with what was to the keyframe of the work who controlled the green buttons on the homepage. I had used snippets of code first, but also tried to remove all that and just do it by hand, but that doesn't seem to make a difference.

    I don't know what the problem is: the ActionScript? The buttons? Some random glitch? I would tend to think that it's something weird, I do with the script, but I wrote it how it seems to work on pages that work properly. And I do not think that it is just dark buttons because I also tried to do a button 'next' a clipart image, who also works hard.

    Any ideas? Suggestions? The assignment should soon and I am at a loss what to try next. I will be happy to clarify anything if something is confusing the way I said.

    ((Oh, également: après avoir regardé un peu sur le forum, mon sonne un peu comme celui-ci: http://forums.adobe.com/message/3113656#3113656 ))

    Not exactly the same, but the buttons have a similar problem. When I first noticed this problem, I have hade three keyframes with actionscript, 1 which apply to the first image, the second applied to the second and the third image was script that applied to buttons for the rest of the document. With this in mind...

    OK my site on order on the timeline goes on and on: homepage, homepage (w / the green buttons), on (dark buttons) page, history page (dark buttons), etc. The buttons work on the on the page - I go to click on the green button on the home page, go to the about page and the home page (via the black button) no problem. If I say history page and try to get back to the homepage (via the black button) it will not work. If I'm going to the page of the homepage first, then go to the history, I could go back to the home page. It's really weird!

    I have now grouped the second and third frame of actionscript and not even a navigation of the on the page works, but I thought that the thing which I explained above looked like the problem of the other person so I wanted to mention.))

    Thank you!! I pasted the code of the button below. The last two buttons are those that do not work and the rest of the script applies to keys that are functioning normally.

    import flash.events.MouseEvent;

    Stop();

    about_btn.addEventListener (MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrameThree);

    function fl_ClickToGoToAndStopAtFrameThree(event:MouseEvent):void

    {

    gotoAndStop (3);

    }

    / * Click to supervise and stop

    By clicking on the instance for the specified symbol moves the playback cursor to the frame specified in the timeline panel and stop the movie.

    Can be used in the main timeline, or on timelines of film clip.

    Directions for use:

    1. replace the number 5 in the code below with the image number you want the playback head to when the user clicks the symbol instance.

    */

    history_btn.addEventListener (MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrameFour);

    function fl_ClickToGoToAndStopAtFrameFour(event:MouseEvent):void

    {

    gotoAndStop (4);

    }

    / * Click to supervise and stop

    By clicking on the instance for the specified symbol moves the playback cursor to the frame specified in the timeline panel and stop the movie.

    Can be used in the main timeline, or on timelines of film clip.

    Directions for use:

    1. replace the number 5 in the code below with the image number you want the playback head to when the user clicks the symbol instance.

    */

    basics_btn.addEventListener (MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrameSix);

    function fl_ClickToGoToAndStopAtFrameSix(event:MouseEvent):void

    {

    gotoAndStop (5);

    }

    / * Click to supervise and stop

    By clicking on the instance for the specified symbol moves the playback cursor to the frame specified in the timeline panel and stop the movie.

    Can be used in the main timeline, or on timelines of film clip.

    Directions for use:

    1. replace the number 5 in the code below with the image number you want the playback head to when the user clicks the symbol instance.

    */

    shoes_btn.addEventListener (MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrameSeven);

    function fl_ClickToGoToAndStopAtFrameSeven(event:MouseEvent):void

    {

    gotoAndStop (6);

    }

    / * Click to supervise and stop

    By clicking on the instance for the specified symbol moves the playback cursor to the frame specified in the timeline panel and stop the movie.

    Can be used in the main timeline, or on timelines of film clip.

    Directions for use:

    1. replace the number 5 in the code below with the image number you want the playback head to when the user clicks the symbol instance.

    */

    benefits_btn.addEventListener (MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrameEight);

    function fl_ClickToGoToAndStopAtFrameEight(event:MouseEvent):void

    {

    gotoAndStop (7);

    }

    / * Click to supervise and stop

    By clicking on the instance for the specified symbol moves the playback cursor to the frame specified in the timeline panel and stop the movie.

    Can be used in the main timeline, or on timelines of film clip.

    Directions for use:

    1. replace the number 5 in the code below with the image number you want the playback head to when the user clicks the symbol instance.

    */

    pictures_btn.addEventListener (MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrameNine);

    function fl_ClickToGoToAndStopAtFrameNine(event:MouseEvent):void

    {

    gotoAndStop (8);

    }

    / * Click to supervise and stop

    By clicking on the instance for the specified symbol moves the playback cursor to the frame specified in the timeline panel and stop the movie.

    Can be used in the main timeline, or on timelines of film clip.

    Directions for use:

    1. replace the number 5 in the code below with the image number you want the playback head to when the user clicks the symbol instance.

    */

    resources_btn.addEventListener (MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrameTen);

    function fl_ClickToGoToAndStopAtFrameTen(event:MouseEvent):void

    {

    gotoAndStop (9);

    }

    homeDark_btn.addEventListener (MouseEvent.CLICK, ClickAndPlay_One);

    function ClickAndPlay_One(event:MouseEvent):void

    {

    gotoAndStop (2);

    }

    celtic_btn.addEventListener (MouseEvent.CLICK, JumpAndPlay_One);

    function JumpAndPlay_One(event:MouseEvent):void

    {

    gotoAndStop (75)

    }

    You mentioned have code on different frameworks and how the framework and the back worked, but the story goes about page you could not go back.  Looks like your code was on the subject of chassis you skipped by going directly to the plot of the story.  If you ignored this framework you skipped assigning listeners to the buttons.

    An alternative approach to consider is to have all of your buttons from 1 chassis and control their visibility rather than assigning the code so that they work when you move around chronology

  • How can I have two buttons for 'new tab' in version 4?

    In version 3.x, there is a removable button on the toolbar for 'new tab' plus a button '+' at the end of the address of the open tab I could click to create a new tab.
    In version 4, I can have the removable button, but I do not see how to add the button at the end of the address of the open tab. I can move the single button at the end of the address window, but I can't have two buttons.
    Is it still possible?

    You must drag the button new tab (+) of the tabs to another toolbar toolbar to make the second button to appear.

    "Firefox > Options > toolbars" or "view > toolbars > customize.

  • I have an iMac (2015).  When I open Garageband, there are only two buttons on the control bar, play and stop.  No record button, rewind or ff.  Where are they and how can I make it appear?

    I have an iMac (2015). When I open Garageband, there are only two buttons on the control bar, play and stop. No record button, rewind or ff. Where are they and how can I make it appear?

    Try to enlarge the GarageBand window by dragging the corners of resizing.

    If she looks like this, your window is small:

    You can also try to click the double arrow at the end of the toolbar to reveal more options.

  • Satellite A350D-201 - pad touch and two buttons doen't work

    After updating the BIOS from version 1.6 to 1.8 the two buttons and the touchpad does not work.
    USB mouse works. Pointing device-enable (bios).

    I decided to reinstall Win7, in a time of installation the sensor does not work!
    Disassembled the laptop, I found nothing.

    Help!

    Have you installed the touchpad driver after the installation of Win 7?

    If so, you should also check if the touchpad has not been disabled using FN + F9 keys
    Also recommend that you check the setting in Control Panel-> mouse-> Advanced tab
    Here, you have to go into the advanced settings.
    For all I know, you could turn on and off several options of touchpad and touchpad functionality.

  • dialog two buttons

    Hello. currently im doing a project to detect road marking using multiple special geometric criteria. My idea was when the user has two choices, the program prompts the user to choose which way to go. in my program, I used a marking 'go left or right' and I plan to use two button dialog box. However, it only appears once at the beginning of the program and no longer appears. is it something wrong with the loop or in my program? or if you guys can share an idea of how is the best prompt the user to make choices.

    I here enclose the program along with the models. any help is very appreciated. Thank you

    your code should be something like this

  • Two button dialogue - fire once

    I have an application where I need to get a lot of responses from the user through two button dialog boxes. I need to feel the change of State of a locked DI and when he goes UP, display a dialog of two buttons for the user to interact. As this happens inside a while loop 100ms, I need to remove the dialog box after the user selection is made. Otherwise the pop up will happen several times as the DI is locked in a HIGH State.

    While I was able to get the feature with a registry change (see attachment to LV2009), I was wondering if there was a better way to do this kind of "once-only-messages?

    Thank you

    It is not a good idea to change the status of the digital input which is "read only".

    The final VI with the required change is as below:

Maybe you are looking for

  • IMac Mid11

    I've updated the operating system that you are prompted by Apple, because I bought my iMac in 2011. I downloaded as many of the Apple Store, such as antivirus and other software, (which I thought were compatible, because they were in the Apple Store)

  • Is it possible to change the default location where Firefox stores its profiles and browsing history

    Normally the profiles and browsing history stores in %APPDATA%\Mozilla\Firefox Now, I want to change the location somewhere ("like in the office"), even during installation or after the installation of Firefox. Can someone help me... Thanks in advanc

  • EliteBook 8470p: EliteBook 8470p GPU

    Hey guys! I have a question about the 8470p with the core i5 3380 Mr. P EliteBook 8470 all come with a dedicated gpu? I have yet to find someone online with a p 8470 without a dedicated gpu. If I have one that does not appear in Device Manager and I

  • devices and drivers

    How to automatically remove the 0x6d9.

  • All the messages that I opened in Windows Mail disappears completely.

    Windows Mail problem All the messages that I opened in Windows Mail disappears completely.  I can't find in in box, deleted, spam or any where else. Unopened messages remain in a box.