Button not in main timeline

Hello All,
I am fairly new to flash and would greatly appreciate some
help with this... I have many buttons that I need to attach event
handlers to but they are embedded within layers of movie clips, and
if I write the handler code in the main timeline's 1st frame they
are nowhere to be found because they are no yet displayed. If I
write the handler code in the movie clip that a button is contained
in, and my action is to gotoAndPlay a frame of a different movie
clip, that movie clip also not be found. My guess is that I need to
write the code within the movie clip that the button is contained
in and somehow call up the mainstage and then reference the movie
clip that is to be played by the buttonClick event through its
respective path... something like (in words):
"look to stage" then...
function buttonClick(speakevent:MouseEvent):void {
portal_mc.logomov_mc.gotoAndPlay(63)
speak_btn.addEventListener(MouseEvent.CLICK, buttonClick);
can anybody tell me how to point back to the stage? or some
other way of doing this? surely it is possible. any comments would
be much appreciated.
thanks, sander.

kglad wrote:
i'm assuming your buttons are movieclip buttons.  if "nextlevelbutton" is not the linkage id of a movieclip, your code makes no sense.  if it is a movieclip over and down states wouldn't work unless you had code elsewhere.
scoresign.attachMovie("nextlevelbutton", "nextlevelbutton", scoresign.getNextHighestDepth(), {_x:126, _y:300});
scoresign.attachMovie("mainmenubutton", "mainmenubutton", scoresign.getNextHighestDepth(), {_x:35, _y:300});
scoresign.nextlevelbutton.onRelease=function(){gotoAndStop("first scene");
scoresign.mainmenubutton.onRelease=function(){
// do whatever

Similar Messages

  • Forcing a symbol within a symbol to play out when a button on the main timeline is clicked?

    I have a buttons that play to symbols on the timeline. Once another button is clicked on the timeline the symbol will playout then start playing the next symbol. This is the code used on the onClick event on the introduction button.
    var current = sym.getVariable("current");
       if (current != "") {
          sym.getSymbol(current).play("out");
          sym.getSymbol("intro").play("in");
       else {
          sym.getSymbol("intro").play("shortIn");
       sym.setVariable("current", "intro");
    The problem I'm having is with the technology symbol. I have buttons within this symbol that link to other symbols. I would like these symbols to playout like the other buttons, but the content of the symbol stays on the stage and does not play out when I select a button on the Stage. Here is the code I have on the click event on the button within the symbol.
    var current2 = sym.getVariable("current2");
       if (current2 != "") {
          sym.getSymbol(current2).play("out");
          sym.getSymbol("optical1").play("in");
       else {
          sym.getSymbol("optical1").play("shortIn");
       sym.setVariable("current2", "optical1");
    Any help would be greatly appreciated. Thank you very much!

    Thank you very much for responding so quickly! When I do this all of the nested timelines play from the out label on their timeline. I want the one that is currently being viewed to be the only one that plays out, not all of the symbols within the symbol. Here is the code I'm using on the buttons on the main timeline:
    var current = sym.getVariable("current");
       if (current != "") {
          sym.getSymbol(current).play("out");
          sym.getSymbol("spec").play("in");
       else {
          sym.getSymbol("spec").play("shortIn");
       sym.setVariable("current", "spec");
       var techSym1 = sym.getSymbol("tech").getSymbol("techSym1")
             if (current = "techSym1") {
                sym.getComposition().getStage().getSymbol("tech").getSymbol("techSym1").play("out");
       var techSym2 = sym.getSymbol("tech").getSymbol("techSym2")
             if (current = "techSym2") {
                sym.getComposition().getStage().getSymbol("tech").getSymbol("techSym2").play("out");
       var techSym3 = sym.getSymbol("tech").getSymbol("techSym3")
             if (current = "techSym3") {
                sym.getComposition().getStage().getSymbol("tech").getSymbol("techSym3").play("out");
       var techSym4 = sym.getSymbol("tech").getSymbol("techSym4")
             if (current = "techSym4") {
                sym.getComposition().getStage().getSymbol("tech").getSymbol("techSym4").play("out");
       var techSym5 = sym.getSymbol("tech").getSymbol("techSym5")
             if (current = "techSym5") {
                sym.getComposition().getStage().getSymbol("tech").getSymbol("techSym5").play("out");
       var techSym6 = sym.getSymbol("tech").getSymbol("techSym6")
             if (current = "techSym6") {
                sym.getComposition().getStage().getSymbol("tech").getSymbol("techSym6").play("out");
    If just techSym1 is being shown on the screen I don't want techSym2 and all the others to be shown going out at all, just techSym1.
    Thank you,
    Kristin

  • Button Refer to Main Timeline

    Okay so I am unfortunatly new to AS3, so I apologize if there
    is a very obvious answer to this question.
    Okay Say I have a movie Clip on my main timeline and with in
    that movie clip is a button. That button has a CLICK event that I
    want o go back and refer to a "frame" on the main time line. How
    would I go about doing that?
    Here is what I thought I should do
    import flash.events.MouseEvent;
    WebSitesBtn.addEventListener(MouseEvent.CLICK,WebDesignBtnClick);
    function WebDesignBtnClick(event:MouseEvent):void{
    _parent:gotoAndStop("Web Design");
    "Web Design" is the Frame Label which I want to refer too
    Any ideas on what I am missing or how I can properly refer to
    the main time line?
    Thanks

    use parent, instead of _parent, if that code is in your
    movieclip.

  • External swf button to move main timeline

    Hi,
    i made a main(parent) page that loads an swf which has a button(a1) which on click i need it to move the timeline of the parent
    i wrote this code to the external swf and tryed many commands such as Object(root).gotoAndStop(1);
    a1.buttonMode = true;
    a1.addEventListener (MouseEvent.MOUSE_UP,a1a);
    function a1a(event:MouseEvent):void {
    what do i need to write inside to make it work?
    Thanks in advance

    try this:
    a1.buttonMode = true;
    a1.addEventListener (MouseEvent.MOUSE_UP,a1a);
    function a1a(event:MouseEvent):void {
    trace(a1.parent.parent.parent);
    trace(a1.parent.parent);
    //  find the right timeline , maybe with more parent.parent.... and then:
    MovieClip(a1.parent.parent.parent).gotoAndtop(10);

  • Button on main timeline control movieclip

    Hello,
    I have a stop on my main timeline. At the stop I have a movieclip play. In the movieclip I will have a video play. After the video plays I have a button for the user to continue play until the end of the movieclip. Once the movieclip is done I want to resume back to a specific frame in my main timeline.
    I can't figure out how to make this work. Anyone have any ideas?
    Thanks in advance,
    Paul

    Ned,
    Thanks for the reply and the help.
    I actually got everything to work the way I need it to. I simply had my button in the movieclip continue play then at the end of the last frame, applied a little voodoo and I was all smiles after I tested my Movie. Here's what I did...
    x_btn in movieclip (not on main timeline) -
         x_btn.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler10);
         function mouseDownHandler10(event:MouseEvent):void {
                  gotoAndPlay(41);
    last frame in movie clip -
         MovieClip(root).gotoAndStop(130);
    Paul

  • Controlling multiple external swfs from main timeline

    Hi, I've been trying to combine the features of two tutorials I found, one that deals with controlling external swf's from the main timeline and the other that explains how to load and unload multiple external swf's.  I'd like to be able to load and unload multiple external swf's, and control these swf's buttons from the main timeline. 
    I asked this same question on the forum of the site where I found these tutorials, and receive only one reply saying that "it should'nt be hard to do." but they did not elaborate any further.  This left me think that I was missing something very obvious and I've spent too much time now trying to work what it is now.  I understand pretty much how both pieces of code work, but just can't work out how to combine them.
    If someone could explain it to me, I'd much appreciate it.
    Tutorial One code - controlling an external swf from the main timeline.
    var ldr:Loader = new Loader();
    var urlReq:URLRequest = new URLRequest("swfs/balls.swf");
    ldr.load(urlReq);
    function loadHandler (event:Event) {
    var myClip:MovieClip = event.target.content;
    addChild(myClip);
    function myClipOver(event:MouseEvent):void {
    myClip.myBlueBalls.stop();
    function myClipOut(event:MouseEvent):void {
    myClip.myBlueBalls.play();
    // set listeners
    myClip.addEventListener(MouseEvent.ROLL_OVER, myClipOver);
    myClip.addEventListener(MouseEvent.ROLL_OUT, myClipOut);
    // listener
    ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loadHandler);
    Tutorial Two code - loading and unloading multiple external swfs.
    var Xpos:Number = 110;
    var Ypos:Number = 180;
    var swf:MovieClip;
    var loader:Loader = new Loader();
    var defaultSWF:URLRequest = new URLRequest("swfs/eyesClosed.swf");
    loader.load(defaultSWF);
    loader.x = Xpos;
    loader.y = Ypos;
    addChild(loader);
    // Btns Universal function
    function btnClick(event:MouseEvent):void {
    removeChild(loader);
    var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");
    loader.load(newSWFRequest);
    loader.x = Xpos;
        loader.y = Ypos;
    addChild(loader);
    // Btn listeners
    eyesClosed.addEventListener(MouseEvent.CLICK, btnClick);
    stingray.addEventListener(MouseEvent.CLICK, btnClick);
    demon.addEventListener(MouseEvent.CLICK, btnClick);
    strongman.addEventListener(MouseEvent.CLICK, btnClick);

    I will not be able to help you with whatever relaxatraja provided though it is purported by relaxatraja to be clearly explaining what I was explaining (???).
    Your loadHandler function appears a bit confused.  For the code you show I don't see you assigning any event listeners for the events that will be dispatched in the loaded file.  As I showed earlier, your loadHandler function should be assigning a listener for the event that will be dispatched (modified slightly below). and if you have three different events being dispatched in the loaded file, then you'll do better to have three different listeners.  I show only one below for one of the events you dispatch...
    function loadHandler (event:Event) {
      // assign a listener for the loaded file's goExit function's event
       MovieClip(event.currentTarget.content).addEventListener("close", event1Handler);
    // I can't make sense of what you have here
        removeChild(myClip); // why ?? - it hasn't been added yet as far as I can see - error 2007?
        var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf"); // the event.target is the Loader
        ldr.load(newSWFRequest); // this will load over the file you just finished loading??
        ldr.x = Xpos;
        ldr.y = Ypos;
        addChild(myClip);  // why?? it has nothing in it
    function event1Handler(e:Event):void {
        // do whatever is involved with what the "close" event is supposed to do
        trace("goExit function executed");
    As far as what you have in the loaded file, you appear to be trying to pass the files names as if they were parameters.  The file naming should be done at the receiving side for the event handler function for the event listener.  While you could create a custom event that include parameters that you can pass, that's another level of coding that is better left for a future experience.
    Study the following - understand it before you try to use it.
    Below is a link to some files I made for another posting that demonstrates what I have been explaining.  The neurope file is the main file.  Publish the netherlands file so that you have an swf to load for it, and then run the neurope file.  The file that gets loaded (netherlands) only has a button in it that when clicked dispatches an event for which the main file (neurope) has assigned a listener.  The main file displays a message when the button gets clicked in the loaded file.
    http://www.nedwebs.com/Flash/neurope.zip

  • Controlling loaded swf from main timeline

    Hello,
    I'm working on loading external swf files for ios. I am able to load the swf files and set them to visible or invisible in different frames. I am having trouble controlling the loaded swf files from the main timeline. Specifically, I would like to have a button on the main timeline, that when clicked will move a loaded swf to frame 1.
    Here is a code that loads one swf file:
    var myLoader1:Loader;
    var loaderContext1:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
    if(myLoader1 == null)
              myLoader1 = new Loader();
              addChild(myLoader1);
    myLoader1.load(new URLRequest("folder/file1.swf"),loaderContext1);
    myLoader1.visible = true;
    backbutton.addEventListener(MouseEvent.MOUSE_DOWN, backbutton1);
    function backbutton1(myEvent:MouseEvent):void {???????????? myLoader1.gotoAndStop(1);}  (this line does not work)
    (Once I load file1.swf, within the file1.swf I click a forward button to move to different frames. My question is: how do I code the 'backbutton' on the main timeline so that it causes the loaded file1.swf to go to frame 1?)
    Thank you for your help.

    sure.
    if the movieclip on the loaded swf's main timeline has reference mc, you would use:
    MovieClip(myLoader.content).mc.gotoAndStop(1);
    p.s.  you might find the following helpful,  http://kb2.adobe.com/community/publishing/918/cpsid_91887.html

  • Loaded swf with button , not communicating to main timeline

    my main stage/timeline has a UILoader "UILoaderOne" and
    another one "UIloaderTwo".
    i have some buttons on the main stage which pull up some
    images into the UILoaderOne.
    these work fine and look like this.
    //BEGIN BUTTONCODE\\
    //button to load image into loader "loaderOne" x01_btn and
    x01_ldr, thumb image is "x01.jpg and main image is p01.jpg\\
    //crop thumb image to size 50px tall by whatever wide and
    resize loaderButton if needed, main image will resize
    proportionatly\\
    x01_btn.addEventListener(MouseEvent.CLICK, onClick);
    function onClick(event:MouseEvent):void
    //import fl.containers.UILoader;
    import fl.controls.Label;
    import fl.controls.ProgressBar;
    var url:String = "assets/01.jpg";
    //var myUILoader:UILoader //= new UILoader();
    myUILoader.unload();
    myUILoader.autoLoad = false;
    myUILoader.source = url;
    //myUILoader.move(10, 10);
    myUILoader.scaleContent = true;
    myUILoader.load();
    var myProgressBar:ProgressBar = new ProgressBar();
    myProgressBar.source = myUILoader;
    myProgressBar.setSize(100, 10);
    myProgressBar.move(myUILoader.x+340, myUILoader.y+250)
    myProgressBar.addEventListener(ProgressEvent.PROGRESS,
    progressHandler);
    myProgressBar.addEventListener(Event.COMPLETE,
    completeHandler);
    addChild(myProgressBar)
    var myLabel:Label = new Label();
    myLabel.text = ". . . . . X . . . . . ";
    myLabel.autoSize = TextFieldAutoSize.LEFT;
    myLabel.move(myProgressBar.x, myProgressBar.y +
    myProgressBar.height);
    addChild(myLabel);
    function progressHandler(event:ProgressEvent):void {
    //trace("progress:", event.bytesLoaded, event.bytesTotal,
    int(event.currentTarget.percentComplete) + "%");
    //myLabel.text = event.bytesLoaded + " of " +
    event.bytesTotal + " bytes loaded.";
    myLabel.text = ("progress:", event.bytesLoaded,
    event.bytesTotal, int(event.currentTarget.percentComplete) + "%")
    //myLabel.text =
    Math.round((event.bytesLoaded/event.bytesTotal)*100) +"%";
    function completeHandler(event:Event):void {
    trace("complete:");
    myProgressBar.removeEventListener(ProgressEvent.PROGRESS,
    progressHandler);
    myProgressBar.removeEventListener(Event.COMPLETE,
    completeHandler);
    removeChild(myProgressBar);
    removeChild(myLabel);
    //addChild(myUILoader);
    //trace("typeMe");
    //end BUTTONCODE\\
    //end BUTTONCODE\\
    the second Loader "UILoaderTwo" auto loads another swf file
    with the INTENT to load from buttons, images into the ULLoader
    "UILoaderOne" which is on the main timeline.
    this part is failing
    the error i get in Output window is
    TypeError: Error #1009: Cannot access a property or method of
    a null object reference.
    at sOne_fla::MainTimeline/onClickz()
    the swf that loads is sOne.swf
    and it has code of this
    z01_btn.addEventListener(MouseEvent.CLICK, onClickz);
    function onClickz(event:MouseEvent):void
    import fl.containers.UILoader;
    import fl.controls.Label;
    import fl.controls.ProgressBar;
    var url:String = "assets/xx.jpg";
    var myUILoader:UILoader //= new UILoader();
    myUILoader.unload();
    myUILoader.autoLoad = false;
    myUILoader.source = url;
    //myUILoader.move(10, 10);
    myUILoader.scaleContent = true;
    myUILoader.load();
    var myProgressBar:ProgressBar = new ProgressBar();
    myProgressBar.source = myUILoader;
    myProgressBar.setSize(100, 10);
    myProgressBar.move(myUILoader.x+340, myUILoader.y+250)
    myProgressBar.addEventListener(ProgressEvent.PROGRESS,
    progressHandler);
    myProgressBar.addEventListener(Event.COMPLETE,
    completeHandler);
    addChild(myProgressBar)
    var myLabel:Label = new Label();
    myLabel.text = ". . . . . X . . . . . ";
    myLabel.autoSize = TextFieldAutoSize.LEFT;
    myLabel.move(myProgressBar.x, myProgressBar.y +
    myProgressBar.height);
    addChild(myLabel);
    function progressHandler(event:ProgressEvent):void {
    //trace("progress:", event.bytesLoaded, event.bytesTotal,
    int(event.currentTarget.percentComplete) + "%");
    //myLabel.text = event.bytesLoaded + " of " +
    event.bytesTotal + " bytes loaded.";
    myLabel.text = ("progress:", event.bytesLoaded,
    event.bytesTotal, int(event.currentTarget.percentComplete) + "%")
    //myLabel.text =
    Math.round((event.bytesLoaded/event.bytesTotal)*100) +"%";
    function completeHandler(event:Event):void {
    trace("complete:");
    myProgressBar.removeEventListener(ProgressEvent.PROGRESS,
    progressHandler);
    myProgressBar.removeEventListener(Event.COMPLETE,
    completeHandler);
    removeChild(myProgressBar);
    removeChild(myLabel);
    //addChild(myUILoader);
    //trace("typeMe");
    //end BUTTONCODE\\
    //end BUTTONCODE\\

    well, I'm such a novice to begin with.
    the loader is actually placed on stage manually, and instance
    named manually so a lot of that code is may not be needed,
    i do a lot of trial and error technique
    it is all personal stuff
    one guess i have is to set up a listner as to when the sOne
    is loaded, and then get a way to communicate to each other?
    how?

  • In actionscript 3.0 how do i make a nested movie clip button go to a frame on the main timeline

    I am making a website based in flash actionscript 3.0 i have a button nested in its own movie clip, because I have the button expanding to be able to read it i have figured out the only way to do this is by creating it as a movie clipa nd inside the movie clip creating it as a button
    I added an event listener to the blog button by saying,
    blog.addEventListener(MouseEvent.ROLL_OVER,gotoblog);
    function gotoblog(evtobj:MouseEvent){
         gotoAndStop(2)
    this part of the code works it goes to the 2nd frame of the timeline it is in and stops wich is a blown up version of the origanal symbol
    i added on frame 2 a second command
    blog.addEventListener(MouseEvent.CLICK.gotoblogpage);
    function gotoblogpage(evtobj:MouseEvent){
    gotoAndStop("blogframe")
    trace("the blog button was clicked")
    i have named the symbol blog and have name the frame of where the blog page is going to be "blogframe" this line of code at the bottom is where i run into trouble the output window in Flash is saying "The blog button was clicked" just like i want it to. no errors are accouring why than is the playhead not going to frame "blogframe"? if the button is working when i click it the code is right i belive the problem here is it does not want the playhead to go to the frame i want it to. So i gues my question is, how can i make a button withing a movie clip interact with the main timeline?

    I have a similar problem if could please help me i'd really apreciate it!!
    So i have a looping animation of some thumbnails, the hierarchy goes like this
    Scene1(main timeline) -> imgBar(MC)->imgBarB(MC within the imgBar MC)
    My buttons symbols are in the last MC "imgBarB" where i have this code:
    ss1.addEventListener(MouseEvent.CLICK, OneButtonClicked);
      function OneButtonClicked(event:MouseEvent):void{
      MovieClip(root).gotoAndStop("ssbox1");
    I want to control the Btns in my "imgBarB" MC to play a labeled frame(named "ssbox1") on another MC on the main timeline,this other MC goes like this:
    Scene1(main timeline)->ssbox_mc(MC where my labeled frame is)

  • How to add button inside move clip and call it from main timeline?

    Hi,
    On the main timeline I  have a movie clip called clock_mc and playBtn
    playBtn is  placed in the center of clock_mc
    When you press playBtn clock_mc starts playing
    playBtn.addEventListener(MouseEvent.CLICK, playClock);
    function playClock(event:MouseEvent):void
        if (event.target == playBtn)
            clock_mc.play();
            playBtn.visible = false;
            trace ("play button was clicked");
    This is working fine for me.
    But I want to add replayBtn to the last frame of clock_mc and set up the function on main Timeline.
    Another words when the clock_mc rich last frame you see replayBtn.
    code example:
    replayBtn.addEventListener(MouseEvent.CLICK, playClock);
        if (event.target == replayBtn)
            clock_mc.play();
            replayBtn.visible = false;
            trace ("replay button was clicked");
    I've tryed to placed the replayBtn on the stage on the main timeline and I've set it up to replayBtn.visible = false;
    And then I add replayBtn.visible = true; to last AS frame of clock_mc but it wont work
    Even when I put the button physically to the last frame of clock_mc it will not work either.
    Please help

    I've solved the problem:-)
    I've set replayBtn.visible = false; on first frame of clock_mc
    and  replayBtn.visible = true; at the last frame
    and than as you sugested I'v add:
    clock_mc.replayBtn.addEventListener(MouseEvent.CLICK, replayClock);
    function replayClock(event:MouseEvent):void
            clock_mc.play();
            trace ("replay button was clicked");
    I couldn't see replayBtn at the firs stage because I have clockTween assosiated with clock:
    clockTween = new Tween(clock_mc, "x", Regular.easeOut, -469,438, .5, true);
    and I had replyBtn in the wrong place so when clock_mc was coming up on the stage replayBtn was on the left side of the stage :/
    Now I have to solve only one thing.
    Maybe you would have any suggestions please.
    I've set up stop(); in a first frame of clock_mc
    that when you see clock_mc sliding in it has to wait for playBtn to be clicked
    because I have two tween:
            clockTween = new Tween(clock_mc, "x", Regular.easeOut, -469,438, .5, true);
            playTween = new Tween(playBtn, "x", Regular.easeOut, -720,514, .5, true);
            playBtn.visible = true;
    so when you click on playBtn:
    function playClock(event:MouseEvent):void
        if (event.target == playBtn)
            clock_mc.play();
            playBtn.visible = false;
            trace ("play button was clicked");
    everythink is working fine except when I clik on replayBtn it play for I sec because there is stop(); on the first frame of clock_mc

  • Can't get button in sub movie to link back to main timeline

    Hi All.....
    First, thank you for helping me! I am pulling my hair out. I
    know there is an easy answer to this question, but I can't figure
    it out.
    I have my main timeline (Scene 1) and then on frame 5, I have
    a movie that plays for about 70 frames (within itself). On the main
    timeline it is only 3 frames long, and I have an action at the top
    layer to stop at the first frame.
    At the end of the 70 frame movie, I have a "next" button; the
    action is in normal mode;
    on (press) {
    gotoAndPlay("Scene 1", 11);
    I am ultimately telling this button to go back to the main
    timeline (scene 1) and continue on with the next movie.
    When I publish, the movie goes through just fine, gets to the
    next button, I press it and it goes to the 11th frame of the that
    same movie, instead of the 11th frame of the main timeline (scene
    1).
    Help! I appreciate it...let me know if I left anything
    out...........
    Aubry

    aubrycan wrote:
    > Ahh!
    > Thank you! It worked!
    >
    > You have saved me. :-)
    better yet label the frame you like to target and target that
    label
    _root.gotoAndPlay("labelNameHere");
    There is no scenes in SWF file upon export. So if you have 10
    frame in scene 1
    and 10 in scene 2, the frame 10 in scene two become frame
    number 20.
    The action sugested by FamousSeamus is not really correct
    even tho it might work,
    but as soon as you try to target frames across multiple
    scenes, you can't refer to them
    by their numbers unless it's one long scene only.
    Best Regards
    Urami
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • Attempt to move main timeline from inside a movie clip breaks menu buttons.

    I am attempting to have the main timeline move from a stopped position over a movie clip to frame 1, where my start menu is.
    The code I'm using does move the timeline but in doing so it somehow breaks the 4 buttons I have in frame 1.
    My code in the movie clip:
    stop()
    function replayMovie(event:MouseEvent):void
    MovieClip(parent).gotoAndStop(1);
    Menu.addEventListener(MouseEvent.CLICK, replayMovie);
    My code in frame 1 of the main timeline:
    stop();
    function bo(event:MouseEvent):void
    gotoAndPlay(21)
    SoundMixer.stopAll()
    espesp.addEventListener(MouseEvent.CLICK, bo);
    function ho(event:MouseEvent):void
    gotoAndPlay(31)
    SoundMixer.stopAll()
    espeng.addEventListener(MouseEvent.CLICK, ho);
    function yo(event:MouseEvent):void
    gotoAndPlay(41)
    SoundMixer.stopAll()
    engesp.addEventListener(MouseEvent.CLICK, yo);
    function go(event:MouseEvent):void
    gotoAndPlay(51)
    SoundMixer.stopAll()
    engeng.addEventListener(MouseEvent.CLICK, go);
    The error output when I use my Menu button at the end of the movie clip.
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at SSubjunctiveProjNewgrounds_fla::MainTimeline/frame1()
    at flash.display::MovieClip/gotoAndStop()
    at SSubjunctiveProjNewgrounds_fla::Esp_5/replayMovie()
    Any help would be greatly appreciated.

    For the sake of space, I'll leave out all the package declarations and class declarations and just talk about the functions.
    First, the Game class, it has two functions.  The first one is the constructor function and it launches at the beginning of the game:  First the Game function:
    public function Game():void
    //Game code goes here
    }//Game
    We want to listen for someone to click the mouse on the MenuPage, so lets create a new MenuPage and add a listener to the button contiained within it.
    public function Game():void
    menuPage = new MenuPage;
    menuPage.startButton.addEventListener(MouseEvent.CLICK, startGame);
    addChild(menuPage);
    }//Game
    You will notice that before I declared a variable var menuPage:MenuPage, but that's all I did was declare it.  I didn't really make a new instance of it, I just set aside space for it.  In the first line within the Game function, I'm actually turning that variable into a new instance of a MenuPage.
    We don't have a picture of this imaginary menuPage instance, but lets' assume that in our MenuPage MovieClip in the library, we created a SimpleButton called startButton.  Here, I'm adding an EventListener that patiently waits for someone to click that button.  Once we receive that event, Flash is told to call the startGame function.
    As you get better at this, you'll get into custom events, and the eventListener for the button will exist in the MenuPage class file, or even in another class file that you create just for the button.  Something like StartButton.as  But for now, we can do it as above.
    Now the startGame function:
              public function startGame(evt:MouseEvent):void
    //Remove the start Page
    //Add the zombie
    //Add the gun
    }//startGame
    And we'll replace those comments with real code.  It follows along with what we just did above.
    public function startGame(evt:MouseEvent):void
    zombie = new Zombie;
    addChild(zombie);
    gun = new Gun;
    addChild(gun);
    And we also want to clean up some by removing the menuPage, and throwing out the eventListener.
    public function startGame(evt:MouseEvent):void
    zombie = new Zombie;
    addChild(zombie);
    gun = new Gun;
    addChild(gun);
    menuPage.startButton.removeEventListener(MouseEvent.Click,startGame);
    removeChild(menuPage);
    }//startGame
    Now our Game class is complete.
    The Zombie Class
    public function zombieWalk(evt:Event):void
    this.addEventListener(Event.ENTER_FRAME,zombieWalk);
    this.x = this.x + 10;
    }//zombieWalk
    Notice we've added a function to the Zombie Class.
    The first function adds an EventListener to the zombie.  We can use the word this and actionScript knows we're talking about the zombie that the class is written for.  This listener fires off every frame.  If our FLA file is set to 12fps, then 12 times every second it will call on the zombieWalk function.
    The zombie walk function moves the zombie 10 pixels to the right every time the function is called.
    On a more advanced level, you'll want to add animation in the MovieClip to move the zombie legs.  You'll also want to use Timer events to space out how often the funtion fires and not ENTER_FRAME events.  And you'll want to use a static constant to establish how far the zombie moves.  We have it now set to 10 pixels, but that can get irritating if we want to change that value later.  But again, baby steps.
    And finally, the Gun class
    public function Gun():void
    this.addEventListener(MouseEvent.CLICK, fireGun);
    }//function
    public function fireGun(evt:MouseEvent):void
    this.gotoAndPlay(2);
    }//fireGun
    First we add an EventListener for when someone clicks on the gun.  Once this happens, the listener calls on the fireGun function.
    The fireGun function takes advantage of the frames within the Gun MovieClip.  Say we have three frames in the Gun MovieClip.  The first is just a picture of the gun.  The second is the gun with a flash coming out of the nozzle.  And the third is the gun at rest again.  The line this.gotoAndPlay(2) sends the gun to the second frame with the flash graphic.
    For this to work, each frame in the Gun MovieClip has to have some stop and play commands.
    But.. you said no code on our timeline!! Liar!
    I know.  This is the exception.  You will need basic stop() commands and gotoAndPlay commands to loop animations.  Any MovieClip that has more than one frame will need something to control it.
    So our Gun MovieCLip has the following:
    Frame 1: stop();
    Frame 2: no actionScript... and I mean nothing, not even the words, "no actionScript"
    Frame 3: gotoAndStop(1);
    This will loop the gun to the beginning and wait for the next time the user clicks the gun.
    Advanced features of the Gun class might include a Bullet.as sub-class that creates a bullet MovieClip to fly across the screen.  Sound to play when the shooting takes place.  Object collision detection to see if the bullet hits the target.  And a means by which a custom event will tell the Game.as class that a zombie has been hit and it should be removed from the stage.
    As you go down the rabbit hole of ActionScript 3, you will find yourself at a point where it's just a matter of getting the syntax right for all the built in functions and classes.  Arrays, Loaders, casting variable types.. all that stuff will come.
    I hope this has been helfpul.  It's been on my to-do list for a long time.  When I first started out, no one could provide me with basic answers for how all these classes and whatnot worked.  After teaching myself AS3 for 2 years and reading a gabillion books, I think I've gotten to a point where I'm pretty comfortable with it all.

  • Button in movieclip to main timeline

    I have a button(A) that opens a movie clip which contains a
    button (B). I want button B to go to and play a frame on the main
    timeline, NOT a frame in the movieclip. Is this possible?
    If not, what I am aiming for is a menu of buttons, that are
    rollovers from which another menu pops up with buttons you can
    click.
    Help!
    Thanks

    Hi, Sorry I am new to ActionScript.
    This is what I wrote:
    this.menu_orange1.addEventListener(MouseEvent.CLICK,clickListener2);
    function clickListener2(event:MouseEvent):void {
    _root.gotoAndPlay("test");
    and the error message says:
    1120: Access of undefined property _root.

  • Targeting main timeline from a button symbol

    I have been using Edge since it's inception. However I have not been using it over the last year as I have not had any contract work for HTML5 animation but I just got a contract to re create animations originally done in Flash. My Edge basics are pretty fresh but I have a hard time doing the following.
    I have a 2 state button up  down which was converted into a symbol with a mouseover to change the state. Now I need to have an onclick event play the main timeline which I cannot seem to grasp.
    Any help coding this?
    Thx
    RD

    Hi, RD-
    Try using sym.getParentSymbol() (if you're only one level down) or sym.getComposition().getStage() to get the main timeline, then call play().
    Hope that helps,
    -Elaine

  • How to _root in as3 (buttons in movie clip referencing to main timeline)

    Hi, I created buttons within a movie clip that i placed in the main timeline.I am  a novice to as3. I just wanted the button to go to the frame label of the main timeline. i used to do this with _root in the old flash. how do i do this?
    thumb02_btn.addEventListener(MouseEvent.CLICK, buttonClicked);
    function buttonClicked(event:MouseEvent):void
        gotoAndPlay("slide2");

    Thanks for the quick reply!
    somehow i must be doing something wrong though. It's not working...
    I added a stop to the "slide02" labeled section of the main timeline.
    and I also added a stop to the beginning and end of the movieclip. Am I doing something wrong? attached is my file....thanks!!
    stop();
    thumb02_btn.addEventListener(MouseEvent.CLICK, buttonClicked);
    function buttonClicked(event:MouseEvent):void
        MovieClip(this.root).gotoAndPlay("slide2");
    stop();

Maybe you are looking for

  • Connecting MBA to our small business server 2003

    Hi guys, I just got a new 13inch MBA. I would like to use this at work for my exchange server email etc. How do I put the MBA onto our .local domain and we use a VPN for remote connectivity? This is my first MacBook so I'm finding my feet with the wh

  • Can I set public permissions for the Training Catalog?

    We want to have all users be able to get into the Training Catalog and self enroll. We have over 7,000 employees with no distribution list for all people. How do I set permissions for all employees to see the training catalog and self enroll?

  • Query not showing data correctly

    Hi All i have one query on FILG cube in which FIscal period and one amount field is in columns when i see in display data i have seen that there is a data for the period 001/2009, 002/2009 and 006/2009 but when i run the query it only display the dat

  • Made a tool to reduce iWeb site size

    Hi! I created a small tool to reduce the size of iWeb sites. The manual can be found here: http://software.bitwaves.de/modules.php?name=Forums&file=viewforum&f=6 The tool can be downloaded here: http://software.bitwaves.de/modules.php?name=Downloads&

  • Cannot play national lottery, it won't process my ticket,although it will in Avant Browser

    I cannot play my online national lottery games, firefox seems to be blocking my payslip/ticket payment. I can navigate the website and go to my account etc,but when I try to purchase a ticket online it won't let me even though I have more than enough