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.

Similar Messages

  • Goto next frame in a movieclip from main timeline button

    So what I have is a button (named Next) on the main timeline. I have a movie clip on that frame (on the main timeline) and the movie clip has 3 frames that I want to be able to cycle through using the "Next" button that is on the main timeline. How can I go about doing this?
    Thank you,

    Thanks kglad! Works like a charm. :-)
    I had already named the instance of the movieclip and button so I just needed to change the code to match and it's working great.
    One other issue I've come up with now is that when it goes to the 3rd frame of the movieclip and I click next, it doesn't do anything. shouldn't it go back to frame 1 of the movieclip?

  • Controlling movieclip from main timeline & Child

    Hi,
    This code is currently contained within my "mc_1" movieclip. I want to be able to have this code on my main timeline, however no matter what I try I constantly get errors, multiple different versions. I've tried adding mc_1 infront of everything, but that just gives an output error about a Sprite.
    Also, I'm currently using visible to control whether the back image to the textbox should show - What I'd really like to do is control it using a child, but they're movieclips not buttons, so when I try to addChild within the function it errors saying I'm trying to control a movieclip within a simplebutton function.
    import flash.events.MouseEvent;
    stop();
    mc_textbox.visible = false;
    for(var i:uint=1; i<8; i++){
        this["line"+String(i)].addEventListener(MouseEvent.ROLL_OVER, line_in, false, 0, true);
        this["line"+String(i)].addEventListener(MouseEvent.ROLL_OUT, line_out, false, 0, true);
    function line_in(e:MouseEvent):void // Defineing the function as line_in
        var lineTarget:SimpleButton = SimpleButton(e.currentTarget); // The variable is lineTarget
        switch(lineTarget) // Each case should swap the lineTarget
            case line1: // line 1 is the first button
            line_output.text = "1"; // This text should display
            mc_textbox.visible = true; // The textbox should display
            break; // If this is not the case, break and check next
            case line2:
            line_output.text = "2";
            mc_textbox.visible = true;
            break;
            case line3:
            line_output.text = "3";
            mc_textbox.visible = true;
            break;
            case line4:
            line_output.text = "4";
            mc_textbox.visible = true;
            break;
    /* This case has much more text than the rest, as such the textbox is enlarged for this case only
    and changed in position. The line_output dynamic text field is also moved on the Y axis for this.
    This is reset to default using the line_out function.
            case line5:
            line_output.text = "55";
            line_output.y = 427.65;
            mc_textbox.visible = true;
            mc_textbox.height = 100;
            mc_textbox.y = 417;
            break;
            case line6:
            line_output.text = "6";
            mc_textbox.visible = true;
            break;
            case line7:
            line_output.text = "7";
            mc_textbox.visible = true;
            break;
            default: // If none of the cases are true, this should display
            line_output.text = ""; // line_output should be blank
            mc_textbox.visible = false; // mc_textbox should be invisible by default
    function line_out(e:MouseEvent):void
            line_output.text = "";
            line_output.y = 474.65;
            mc_textbox.visible = false;
            mc_textbox.height = 61.95;
            mc_textbox.y = 454;

    I've resolved the timeline issue. Now my only issue is the Child not working.
    What I'm trying to do:
    addChild(mc_1.mc_textbox) to appear upon rollover of a button. On rolloff, for the child to be removed.
    Add mc_textbox inside mc_1 on rollover, at a specific XY and height. On rolloff, for the child to be removed.
    I have also been told that I should not have a dynamic textbox on the scene and should call that in using AS3 - If you have time, could you inform me how this would be done?
    Thanks alot for the help,
    ERROR:
    TypeError: Error #2007: Parameter child must be non-null.
        at flash.display::DisplayObjectContainer/addChild()
        at Main_new_fla::MainTimeline/line_in()
    TypeError: Error #2007: Parameter child must be non-null.
        at flash.display::DisplayObjectContainer/removeChild()
        at Main_new_fla::MainTimeline/line_out()
    import flash.events.MouseEvent;
    stop();
    for(var i:uint=1; i<8; i++){
        this.mc_1["line"+String(i)].addEventListener(MouseEvent.ROLL_OVER, line_in, false, 0, true);
        this.mc_1["line"+String(i)].addEventListener(MouseEvent.ROLL_OUT, line_out, false, 0, true);
    function line_in(e:MouseEvent):void // Defineing the function as line_in
        var lineTarget:SimpleButton = SimpleButton(e.currentTarget); // The variable is lineTarget
        switch(lineTarget) // Each case should swap the lineTarget
            case mc_1.line1: // line 1 is the first button
            mc_1.line_output.text = "1"; // This text should display
            addChild(mc_1.mc_textbox); // The textbox should display
            break; // If this is not the case, break and check next
            case mc_1.line2:
            mc_1.line_output.text = "2";
            addChild(mc_1.mc_textbox);
            break;
            case mc_1.line3:
            mc_1.line_output.text = "3";
            addChild(mc_1.mc_textbox);
            break;
            case mc_1.line4:
            mc_1.line_output.text = "4";
            addChild(mc_1.mc_textbox);
            break;
    /* This case has much more text than the rest, as such the textbox is enlarged for this case only
    and changed in position. The line_output dynamic text field is also moved on the Y axis for this.
    This is reset to default using the line_out function.
            case mc_1.line5:
            mc_1.line_output.text = "55";
            mc_1.line_output.y = 427.65;
            addChild(mc_1.mc_textbox);
            mc_1.mc_textbox.height = 100;
            mc_1.mc_textbox.y = 417;
            break;
            case mc_1.line6:
            mc_1.line_output.text = "6";
            addChild(mc_1.mc_textbox);
            break;
            case mc_1.line7:
            mc_1.line_output.text = "7";
            addChild(mc_1.mc_textbox);
            break;
            default: // If none of the cases are true, this should display
            mc_1.line_output.text = ""; // line_output should be blank
            addChild(mc_1.mc_textbox); // mc_textbox should be invisible by default
    // Removes any text that has been displayed from the Dynamic text box, also resetting the sizes to default.
    function line_out(e:MouseEvent):void
            mc_1.line_output.text = "";
            mc_1.line_output.y = 474.65;
            removeChild(mc_1.mc_textbox)
            mc_1.mc_textbox.height = 61.95;
            mc_1.mc_textbox.y = 454;

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

  • 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

  • How to target button in movieclip back to main timeline

    Hello!
    I have some submenu buttons in a movieclip on the mainline. My first level of navigation in on main timeline. The submenus are grouped in movieclips on the main timeline. I basically used the same code on the main navigation for the sub navigation except the code for the submenus is in that movie clip. My trace statement reads the button is clicked (which was a quantum leap for me) but I know I need some kind of _parent code in there so it knows to go to label back on main timeline. Can anyone help?? I feel like I am so close.
    Also is this an ok way to set this up? I couldn't figure out how to do it in one frame. Any help would be so appreciated. I didn't realize this basic framework was going to be so difficult.
    Here is link:
    http://www.sandraschmitt.com/coclico/index2.html
    Thanks!!
    Sandra
    Here is my code that is on the submenu movieclip:
    Code:
    stop();
    fall.addEventListener(MouseEvent.CLICK, clickSection);
    spring.addEventListener(MouseEvent.CLICK, clickSection);
    function clickSection(evtObj:MouseEvent){
         //trace shows what's happening... in the output window
         trace ("The "+evtObj.target.name+" button was clicked!")
         //go to the section clicked on...
         gotoAndStop(evtObj.target.name);

    One reason I'll never win any awards for my design outlook is because I often follow... if it works, use it.  There are many ways to approach a design and yours is just fine if you understand it.  If it was going to crash something, it would have happened by now.  Some people will go to the extreme of having absolutely no code in a file, some even no library content, writing it all into class files, and not out of necessity, but out of simply believing it's the better way, or a challenge to prove their abilities...  They can have it.  There is a practicality involved with design that allows one to make judgement calls, and if you judge that your design approach is practical for what you understand or for what meets the needs of the project, then you have every right to follow your own path.
    That said... in the event someone should inherit your work somewhere down the road, that's when your approach may fall victim to judgement... if someone cannot follow it or is having trouble putting all the pieces together, or finding them, then you become the fall-person for the whining that ensues.  But you're not likely to have to hear about it.  Still, someday, if you find yourself in a position where you inherit someone's design... and you start whining about how they did it, you'll come to appreciate the reasons for giving consideration to how you approach your designs.

  • How to control main timeline from buttons in a movieclip - job in jeopardy!

    I am trying to do a simple thing in theory. In my main timeline I have a series of images with frame labels for each. In a movieclip (with its own labels & script) below the images, I have two panels of butttons that flop back and forth (to save space). The idea is to simply have the main timeline play the frame specified by the corresponding button in the movieclip. I tried the parent.child thing but either im doing it wrong or that isnt the solution. If anyone can help me I will be saved from certain death. If you think any other part of my project may be to blame, Ill be happy to provide anything that can help. Thanks in advance.
    Here is my script:
    ActionScript Code:
    function on1click(evt:MouseEvent):void {
        gotoAndPlay("pic1");
    thumbPanel.pic1_btn.addEventListener(MouseEvent.CLICK, on1click);
    this is the error: 
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at gallery_fla::MainTimeline/frame1()

    The 1009 error indicates that one of the objects being targeted by your code is out of scope.  This could mean that the object....
    - is not in the display list
    - doesn't have an instance name (or the instance name is mispelled)
    - does not exist in the frame where that code is trying to talk to it
    - is animated into place but is not assigned instance names in every keyframe for it
    - is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).
    If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.

  • Help with button that goes back to main timeline from movieclip

    I have a movie created that is broken down into sections on the timeline (home about contact etc)
    Each section has a movieclip
    I want to be able to be in the about movieclip and click a button that will bring you back to the main timeline contact section
    Heres is the actionscript I am using to navigate the main timeline for each section
    stop();
    //handle events for buttons...
    index.addEventListener(MouseEvent.CLICK, clickSection);
    about.addEventListener(MouseEvent.CLICK, clickSection);
    wind.addEventListener(MouseEvent.CLICK, clickSection);
    turbines.addEventListener(MouseEvent.CLICK, clickSection);
    services.addEventListener(MouseEvent.CLICK, clickSection);
    invest.addEventListener(MouseEvent.CLICK, clickSection);
    contact.addEventListener(MouseEvent.CLICK, clickSection);
    function clickSection(evtObj:MouseEvent){
                    //go to the section clicked on...
                    gotoAndStop(evtObj.target.name);

    if that code is on the timeline of a movieclip whose parent is the main timeline, use:
    MovieClip(parent).gotoAndStop("frame label in main timeline");

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

  • Moving to a frame in Movieclip timeline from the main timeline

    I am in the learning process. Working with FlashCS5 and AS3.
    Please bear with me if the issue appears to be too simple for you. Placed a movieclip(mcassessJohn) on the main timeline and moved to the frame labelled "johnFeedback" in the movieclip timeline using the following actionscript code.
    mcassessJohn.addEventListener(MouseEvent.CLICK, onJohnClick);
    function onJohnClick(evt:MouseEvent):void {
       mcassessJohn.gotoAndPlay("johnFeedback");
    This works fine. However problem starts when I place a button "questionJohn" in the movieclip(mcassessJohn) time line at frame "johnFeedback" and try to move to another frame by clicking the button and using the following actionscript code;
    questionJohn.addEventListener(MouseEventClick,onClick);
    function onClick(evt:MouseEvent):void {
      gotoAnd Play("johnFeedback");
    Placed the above code in actions layer in the movieclip timeline at frame "johnFeedback". I had placed the button also in the movieclip timeline at Frame "johnFeedback in layer buttons. No compiler error.No runtime error. Just nothing happens when I click on the button "questionJohn".
    Would appreciate if you can let me know where I am going wrong.

    Thats because if u assign the listeners to a parent movieclip it will not pickup listener assigned to its child.
    A work around is put a invisible btn inside mcassessJohn movieclip on frame 1 and assign onJohnClick function to that.
    And one more thing, i think u r trying to perform same operation on both the btns
    http://www.darshanrane.com

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

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

  • 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

  • Problem with nested button controlling main timeline...

    I am new with as3, i like it, but I am suffering
    After I looked on google for trying to figure out my problem I attempt to post here...
    to make it simple, I have a loader that is loading some swf(a scrolling content), with some content, in those swf I am trying to put a "close" button and some other like  next/prev. But no way... normally I thought that the MovieClip(root) would make it but it's seems not to be enough.
    code of the swf:
    var btnclose1:btnclose = new btnclose();
    this.addChild(btnclose1);
    btnclose1.x = 770
    btnclose1.y = 55;
    btnclose.addEventListener(MouseEvent.CLICK, closearchi)
    function closearchi (e:MouseEvent):void {
    MovieClip(root).gotoAndStop(1);
    Thanks by advance...

    Hi Ned,
    Actually, I just saw than the problem come from the timeline itself, but I don't see what to do...
    on the frame 1 of the main timeline, it is loading an empty swf into my container"box":
    var myLoader:Loader = new Loader();
    var myURL:URLRequest = new URLRequest("empty.swf");
    myLoader.load(myURL);
    box.addChild(myLoader);
    on frame 2 I have the first content and so on:
    function loadarchi():void
    var myURL:URLRequest = new URLRequest("archi.swf");
    myLoader.load(myURL);
    loadarchi();
    I did a simple button on the main just for testing purpose, telling him to go to frame 1, it doesn't unlod the content ! there is the problem!
    what is wrong with that? it shoul load the empty swf instead of archi...
    thanks again

Maybe you are looking for

  • Pdf won't open

    Since I moved from Windows XP to Windows 7, I have the following problem. When I want to open a pdf-file from oa website (any website), I get one of these messages: that the file can't be opened because the folder won't allow changes, OR the associat

  • Given final block not properly not padded.....when given wrong password....

    hi..........sir when i am executing the following code..with wrong password....i am getting the BadPaddingException:Given final block not properly padded............ plz help me to solve this one with the solution. I am doing my final project .....i

  • Setting up Photoshop Elements 13 to use Shutterfly

    How do I set up Photoshop Elements 13 so I can print photos through Shutterfly. I have a Shutterfly account but can't find any place in Organizer or Editor to provide by Shutterfly UserName and password. Would seem to be obvious but it isn't, not in

  • BA error in FBCJ postings

    Dear Experts, I am doing Fbcj Postings, while doing split postings BA is asking mandatory Field for Petty Cash GL. I am getting the error F5808 The value for field "Bus. Area" in the interface to Financial Accounting is an initial value but you are r

  • Can Adobe fix payments please?

    I had my card cancelled due to the security breach and have been trying to update my payment information for a while now. I cannot update payments. It either does not load or when it does says there was a server error whilst adding the new card. I re