A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Can I nest a actionscript code inside another???

  1. #1
    Junior Member
    Join Date
    Nov 2003
    Location
    College Station, Tx
    Posts
    3

    Can I nest a actionscript code inside another???

    Howdy,

    I am relatively new to actionscrip. I know just enough to be dangerous.

    I have a movieclip that is an interactive "timeline" (a graphical timeline, not timeline in flash workspace). You click and drag a sliding button across the timeline and have a slide pop in and another pop out based on where on the "timeline" you drag the sliding button. (see pix)

    For the slider, I have a variable called "dragging" It evaluates at true when being dragged.

    The buttons are on the same _level.* as the sliding handle. So, I want the buttons to do their thing (slide each slide in) only if the slider is being dragged. The "timelinestate" variable is so it knows which slide to slide out depending on which slide I was on last. (hence the redefinition of timelinestatus at the end.) The output window gives me errors I've posted afer the code.

    if (dragging) {
    if (timelinestate == 3) {
    on (rollOver) {
    _root.Scan_System.Content.Content_Bio.Timeline.Tim eline_Pix.Bio_Pix3_Slide.gotoAndPlay("Slide_Out");
    _root.Scan_System.Content.Content_Bio.Timeline.Tim eline_Pix.Bio_Pix4_Slide.gotoAndPlay("Slide_In");
    }
    }
    if (timelinestate == 5) {
    on (rollOver) {
    _root.Scan_System.Content.Content_Bio.Timeline.Tim eline_Pix.Bio_Pix5_Slide.gotoAndPlay("Slide_Out");
    _root.Scan_System.Content.Content_Bio.Timeline.Tim eline_Pix.Bio_Pix4_Slide.gotoAndPlay("Slide_In");
    }
    }
    }
    timelinestate = 4;

    //Error messgage that appears//:

    Symbol=TimeLine, Layer=Buttons, Frame=1: Line 1: Statement must appear within on handler
    if (dragging) {

    Symbol=TimeLine, Layer=Buttons, Frame=1: Line 15: Statement must appear within on handler
    timelinestate = 4;

    Any help would be greatly appreciated >;-}

    Tom
    Attached Images Attached Images
    Tom Bittikoffer
    bittikoffer1@hotmail.com

  2. #2
    pablo cruisin' hanratty21's Avatar
    Join Date
    Mar 2002
    Location
    on the lam
    Posts
    2,275
    Check your code syntax - it looks like you are not closing your brackets properly {}. Eash one of these { must have one of these }

    If you count yours, they are out of whack a little. That's why the player doesn't think that your statements are within the condition handler.

    RH
    "Why does it hurt when I pee?" -- F. Zappa |

  3. #3
    Junior Member
    Join Date
    Nov 2003
    Location
    College Station, Tx
    Posts
    3

    Still having issues with nested code inside of if statement.

    I think I have all my brackets there. I just have everything else under the if(dragging) {
    \\all the other code is here.\\
    }

    Note that I finish all the code off with a final } that corrosponds to the if(dragging). Everything after the if(dragging) will happen if dragging is true, including the next if statement and the button action.

    The last statement regarding the timelinestatus will happen after the if(dragging) is evaluated and taken care of.

    Is my use of if(dragging) valid?

    Tom
    Tom Bittikoffer
    bittikoffer1@hotmail.com

  4. #4
    Junior Member
    Join Date
    Nov 2003
    Location
    College Station, Tx
    Posts
    3

    oops

    I realized that since the action was on a button instance, the only thing that can be an action is a "on(someMouseEvent)" action and all my brackets have to enclose actions that pertain only to that mouse action.

    My real problem is that I have two buttons on top of each other. One that drags a meter is over buttons that if dragged over, will do something.

    I'll post a new query.

    Thanks to all who helped.
    Tom Bittikoffer
    bittikoffer1@hotmail.com

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