A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [CS3] Button not behaving

  1. #1
    Junior Member
    Join Date
    May 2008

    [CS3] Button not behaving

    I'm new to actionscript so please help me if you can.

    I've got a main time line with a movie clip called "main" on it. On "main" I have several buttons and each need to set a variable called "destination" to a different value. Then in "main" I aso have another movie clip called "leavinghome".

    I've set a variable called "location" on the first frame of "main" and set it equal to 0. This one works perfectly with the code below so when you press the first button, it goes to the frame called "leavinghome".

    At the end of the "leavinghome" movieclip timeline, I want the last frame to direct you to a frame called "atRC" back on the timeline of "main".

    Here's my code for the first button on "main":

    on (release) {
    var destination = 1;
    if (location == 0) {
    if (location == 1) {
    gotoAndPlay ("leavingrc");
    if (location == 2) {
    gotoAndPlay ("leavingcontactus");
    if (location == 3) {
    gotoAndPlay ("leavingstudentgrowth");
    if (location == 4) {
    gotoAndPlay ("leavinggallery");
    if (location == 5) {
    gotoAndPlay ("leavingevents");


    and here's my code for the last frame of "leavinghome":

    if (destination == 1){
    _root.main.gotoAndStop ("atRC");

    It's playing the "leavinghome" moveclip, but then just repeating it instead of going to the previous level and playing the frame "atRC".
    If I take out the "if destination == 1" part, it will work right, but I need it to only work if the variable destination equals 1.

    Any ideas?

  2. #2
    Junior Member
    Join Date
    May 2008
    Nevermind, I figured it out...lol. I needed to declare the variable on the "main" timeline so it was used for the whole timeline and not just a local variable in the button. Then refrenced it in the button and in the other movieclip as _root.destination ==

    Thanks anyways,


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center