A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: functions and frames

  1. #1

    functions and frames

    Hi there,

    I've been working recently on trying to put all of my Actionscript into the first frame of my movie, but have come into some problems.

    If i use:

    myMC.myBTN.onRelease = function(){
    trace("on release");
    }

    The code works fine if myBTN is on the very first frame of myMC, but if myBTN is on the second frame of myMC the code doesn't work even if myMC is on the second frame.

    Is there an Actionscript way to solve this, or do I just need to created my movies differently?

    Thanks,

    dougc

  2. #2
    How should I know!? Biff Tanon's Avatar
    Join Date
    Jun 2001
    Posts
    748
    If you put this function on frame one:
    code:

    function hello() {
    trace("hello");
    }


    Then on your button, but this action.
    code:

    on (release) {
    hello();
    }


    That should work.
    Last edited by Biff Tanon; 09-17-2004 at 06:43 PM.
    [something cool goes here]

  3. #3
    thanks biff.

    that seems like a good way to do it, but isn't there a way to do it without having to put any actions on the button itself?

    thanks,

    dougc

  4. #4
    How should I know!? Biff Tanon's Avatar
    Join Date
    Jun 2001
    Posts
    748
    You need something to call the function.
    I misread your first question, you would need
    code:

    on(release) {
    _root.hello();
    }


    You could attach the call to a frame too I suppose. What are you trying to do?
    [something cool goes here]

  5. #5
    I think you're right with where you're going with it.

    I was keeping all of the different sections of my site in one movie clip that was seperated by different frame labels. Each of those sections are going to have their own buttons. I wanted to be able control all of the buttons from the main timeline, but with your way, I will still be able to do that, I would just need a little bit of code in the buttons themselves.

    Thanks,

    dougc

  6. #6
    Registered User
    Join Date
    Feb 2003
    Location
    Istanbul ,Turkey
    Posts
    59
    _root.myButton.onRollOver = function() {
    trace("button action");
    };

    Just put this on the first frame, leave the buttons alone and clean..
    Instead of the trace example in there put ur actions...


    _root.myButton.onRollOver = function() {
    myMC.gotoAndStop("label");
    myMC.myotherNested.gotoAndPray("a_prayer")
    trace("do other stuff");
    };

    _root.myOtherButton.onPress = function() {
    myMC.gotoAndStop("label2");
    myMC.myotherNested.gotoAndPray("another_prayer")
    trace("do other stuff II");
    };
    Last edited by gotoAndPray; 09-17-2004 at 06:33 PM.

  7. #7
    How should I know!? Biff Tanon's Avatar
    Join Date
    Jun 2001
    Posts
    748
    I think I am still confused, but I hope I helped ya out a little
    [something cool goes here]

  8. #8
    gotoAndPray,

    That would work fine if my button was on the main timeline, but it's on the second frame of a movie clip. It's OK, i'm using Biff's method and it's working just fine. Unless someone else knows of another technique?

    Thanks,

    dougc

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