A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Function Call Issue

  1. #1
    Junior Member
    Join Date
    Mar 2021
    Posts
    2

    Post Function Call Issue

    Thank you all in advance.

    vs. CS4:

    In my project, I have 2 function calls on the main (_root) timeline at frame 1 that I want to advance or retard the playhead within an externally loaded Movie Clip on the (also on the _root timeline) by the use of 2 buttons: Back and Next. These buttons reside within a Movie Clip called mcMovieBase at frame 473 and the functions are called here. The Back button is not recognized and does not call the function. The Next button, however does. I have checked spelling, coding, and references but cannot find an error till I think my head will explode and cannot find my error. Why does one work and the other fail. Help, please.

    These are the function calls and they reside on the _root timeline.
    __________________________________________________ ___________________
    Main Timeline (_root)

    Next Button

    // ---Define the control variable

    var rvarCUSelBtnFrm = 1; / variable for tracking and executing the Back/Next buttons in Canon pages.

    // ---Define the function to advance the frame of the external .swf

    function eorNextButton() { // Define the function
    _root.mcMovieBase.mcbEnterpriseFrameNextBtn.btnEnt erpriseFrameNextBtnA.onRelease = function() { //Set the button press
    if (_root.rvarCUSelBtnFrm>7) { // Test if the control variable is greater than the number of frames
    _root.mcMovieBase.mcbEnterpriseFrameNextBtn.gotoAn dStop("inactive"); //If so, advance the playhead of the "Next" button timeline to the "inactive" frame label
    } else if (_root.rvarCUSelBtnFrm<8) { //If the control variable is less than the number of frames
    _root.rvarCUSelBtnFrm = _root.rvarCUSelBtnFrm+1; //Add 1 to the control variable
    _root.container.mcMovieBaseEnterpriseOfficer.nextF rame(); //Advance the playhead to the next frame of the external .swf
    if (_root.rvarCUSelBtnFrm>1) { // Test if the control variable is greater than 1
    _root.mcMovieBase.mcbEnterpriseFrameBackBtn.gotoAn dStop("active"); // If so, move the playhead of the "Back" button timeline to the "active" frame label
    }
    }
    }


    Back Button

    // ---Define the function to retard the frame of the external .swf

    function eorBackButton() { // Define the function
    _root.mcMovieBase.mcbEnterpriseFrameBackBtn.btnEnt erpriseFrameBackBtnA.onRelease = function() { //Set the button press
    if (_root.rvarCUSelBtnFrm<2) { // Test if the control value is less than 2
    _root.mcMovieBase.mcbEnterpriseFrameBackBtn.gotoAn dStop("inactive"); //if so, move the playhead of the "Back button to the "inactive" timeline frame label
    } else if (_root.rvarCUSelBtnFrm>1) { // Test if the control value is greater than 1
    _root.rvarCUSelBtnFrm = _root.rvarCUSelBtnFrm-1; // If so, subtract 1 from the control variable
    _root.container.mcMovieBaseEnterpriseOfficer.nextF rame(); // Retard the playhead to the previous frame of the external .swf
    if (_root.rvarCUSelBtnFrm<8) { // Test if the control variable is less than the number of frames in the external .swf
    _root.mcMovieBase.mcbEnterpriseFrameNextBtn.gotoAn dStop("active"); // If so, move the playhead of the "Next" button timeline to the "active" frame label
    }
    }
    }
    }
    __________________________________________________ ________________________


    The function calls are on frame 473 of the mcMovieBase Timeline.

    __________________________________________________ ________________________
    Frame 473 (mcMovieBase Timeline

    _root.mcMovieBase.mcbEnterpriseBackBtn.gotoAndStop ("inactive");
    _root.mcMovieBase.mcbEnterpriseNextBtn.gotoAndStop ("active");

    _root.eorBackButton();
    _root.eorNextButton();
    __________________________________________________ ________________________

    The structure looks like this:

    _root: Graphic Timeline (mcMovieBase), Actions (Variables, function calls, etc), Labels (Frame labels). Additionally, the external .swf container is dynamically created here (_level0) with
    createEmptyMovieClip())
    --> mcMovieBase: Multiple frames (including the frame with the Next and Back Buttons)

    The buttons are designed thus:

    mcbEnterpriseBackBtn --> btnEnterpriseBackBtnI mcbEnterpriseNextBtn --> btnEnterpriseNextBtnI
    --> btnEnterpriseBackBtnA --> btnEnterpriseNextBtnA
    --> btnEnterpriseBackBtnS --> btnEnterpriseNextBtnS

    mcb = multi-cell button
    btn = button
    I = inactive state (unselectable)
    A = active state (available for selection)
    S = selected state (button selected & unavailable for selection)

    Additional note: If I apply this coding directly to the button instances (btnEnterpriseBackBtnA) using on(release){ both buttons work correctly. I am genuinely stumped for an answer. Hopefully one you you folks can see what I am apparently blind to. Thanks in advance!!!

  2. #2
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,823
    2 things. 1) you can wrap your code using a [code] tag. Or at least use the quote button. 2) Could you post the fla? That would help with identifying things.
    .

  3. #3
    Junior Member
    Join Date
    Mar 2021
    Posts
    2

    Post Response: Function Call Issue

    Quote Originally Posted by swak View Post
    2 things. 1) you can wrap your code using a [code] tag. Or at least use the quote button. 2) Could you post the fla? That would help with identifying things.
    Thanks for responding. I figured out the issue. As for posting the fla, the file is extremely large. The issue was apparently with the the btnEnterpriseBackI. If the playhead is moved to this frame, it will not be recognized. However, by keeping the playhead on the btnEnterpriseFrameBackBtnA (active state) both buttons call their functions and work properly.

    Code:
    // ---Define the control variable
    
    var rvarCUSelBtnFrm = 1; / variable for tracking and executing the Back/Next buttons in Canon pages.
    
    // ---Define the function to advance the frame of the external .swf
    
    function eorNextButton() { // Define the function
    _root.mcMovieBase.mcbEnterpriseFrameNextBtn.btnEnt erpriseFrameNextBtnA.onRelease = function() { //Set the button press
    if (_root.rvarCUSelBtnFrm>7) { // Test if the control variable is greater than the number of frames
    _root.mcMovieBase.mcbEnterpriseFrameNextBtn.gotoAn dStop("inactive"); //If so, advance the playhead of the "Next" button timeline to the "inactive" frame label
    } else if (_root.rvarCUSelBtnFrm<8) { //If the control variable is less than the number of frames
    _root.rvarCUSelBtnFrm = _root.rvarCUSelBtnFrm+1; //Add 1 to the control variable
    _root.container.mcMovieBaseEnterpriseOfficer.nextF rame(); //Advance the playhead to the next frame of the external .swf
    if (_root.rvarCUSelBtnFrm>1) { // Test if the control variable is greater than 1
    _root.mcMovieBase.mcbEnterpriseFrameBackBtn.gotoAn dStop("active"); // If so, move the playhead of the "Back" button timeline to the "active" frame label
    }
    }
    }
    
    // ---Define the function to retard the frame of the external .swf
    
    function eorBackButton() { // Define the function
    _root.mcMovieBase.mcbEnterpriseFrameBackBtn.btnEnt erpriseFrameBackBtnA.onRelease = function() { //Set the button press
    if (_root.rvarCUSelBtnFrm<2) { // Test if the control value is less than 2
    _root.mcMovieBase.mcbEnterpriseFrameBackBtn.gotoAn dStop("inactive"); //if so, move the playhead of the "Back button to the "inactive" timeline frame label
    } else if (_root.rvarCUSelBtnFrm>1) { // Test if the control value is greater than 1
    _root.rvarCUSelBtnFrm = _root.rvarCUSelBtnFrm-1; // If so, subtract 1 from the control variable
    _root.container.mcMovieBaseEnterpriseOfficer.nextF rame(); // Retard the playhead to the previous frame of the external .swf
    if (_root.rvarCUSelBtnFrm<8) { // Test if the control variable is less than the number of frames in the external .swf
    _root.mcMovieBase.mcbEnterpriseFrameNextBtn.gotoAn dStop("active"); // If so, move the playhead of the "Next" button timeline to the "active" frame label
    }
    }
    }
    }

  4. #4
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,823
    I don't have much experience with multi-frame code like this. One thing you could try is to group all the code into one layer that has one keyframe that extends across everything. Some other ideas, try debugging and following the path of everything.
    .

  5. #5
    Senior Member
    Join Date
    May 2016
    Posts
    231
    Do you want the control buttons for an external swf ?

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