Flash5 [RESOLVED] Multiple checkboxes must be selected before button is activated
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] Multiple checkboxes must be selected before button is activated

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    2

    resolved [RESOLVED] Multiple checkboxes must be selected before button is activated

    I am using the default 'advanced presentation' template to create a presentation. I've gotten the presentation to run perfectly, adjusted the size to my PNG files... but my client wants 4 checkboxes on the last page to be selected before the user can hit a 'next' button. the button redirects them to a URL.

    I've tried to search on several different solutions and the most obvious seems to be to 'validate' the 4 fields (called 'complete1, complete2, complete3, complete4) and generate an alert when the button is pushed. I also tried to create listeners and arrays that took note of when all the checkboxes are selected but I've had no luck. I have not come close to 'disabling' the button or generating an alert ... at least I don't think I have. Every time I plug in some code in the script frame or attached to the button it just cycles through the screens effectively breaking what did work.

    Here is the script used in the default player:

    PHP Code:
    import fl.transitions.*;

    // USER CONFIG SETTINGS
    var buttonsOn:Boolean true// true, false
    var pageNumberOn:Boolean true// true, false
    var transitionOn:Boolean true// true, false
    var transitionType:String "Fade"// Blinds, Fade, Fly, Iris, Photo, PixelDissolve, Rotate, Squeeze, Wipe, Zoom, Random
    // END USER CONFIG SETTINGS

    // EVENTS
    stage.addEventListener(KeyboardEvent.KEY_DOWNfl_changeSlideKeyboard);
    prev_btn.addEventListener(MouseEvent.CLICKfl_prevSlideButton);
    next_btn.addEventListener(MouseEvent.CLICKfl_nextSlideButton);
    function 
    fl_changeSlideKeyboard(evt:KeyboardEvent):void
    {
        if(
    evt.keyCode == 37// LEFT
        
    {
            
    fl_prevSlide();
        }
        else if (
    evt.keyCode == 39 || evt.keyCode == 32// RIGHT OR SPACE
        
    {
            
    fl_nextSlide();
        }
    }
    function 
    fl_prevSlideButton(evt:MouseEvent):void
    {
        
    fl_prevSlide();
    }
    function 
    fl_nextSlideButton(evt:MouseEvent):void
    {
        
    fl_nextSlide();
    }
    // END EVENTS

    // FUNCTIONS AND LOGIC
    function fl_prevSlide():void
    {
        if(
    slides_mc.currentFrame 1)
        {
            
    slides_mc.gotoAndStop(slides_mc.currentFrame-1);
            if(
    transitionOn == true)
            {
                
    fl_doTransition();
            }
            if(
    pageNumberOn == false)
            {
                
    slideNumber_txt.text "";
            } else {
                
    slideNumber_txt.text String(slides_mc.currentFrame "/" slides_mc.totalFrames);
            }
        }
    }
    function 
    fl_nextSlide():void
    {
        if(
    slides_mc.currentFrame slides_mc.totalFrames)
        {
            
    slides_mc.gotoAndStop(slides_mc.currentFrame+1);
            if(
    transitionOn == true)
            {
                
    fl_doTransition();
            }
            if(
    pageNumberOn == false)
            {
                
    slideNumber_txt.text "";
            } else {
                
    slideNumber_txt.text String(slides_mc.currentFrame "/" slides_mc.totalFrames);
            }
        }
    }
    function 
    fl_doTransition():void
    {
        if(
    transitionType == "Blinds")
        {
            
    TransitionManager.start(slides_mc, {type:Blindsdirection:Transition.INduration:0.25});
        } else if (
    transitionType == "Fade")
        {
            
    TransitionManager.start(slides_mc, {type:Fadedirection:Transition.INduration:0.25});
        } else if (
    transitionType == "Fly")
        {
            
    TransitionManager.start(slides_mc, {type:Flydirection:Transition.INduration:0.25});
        } else if (
    transitionType == "Iris")
        {
            
    TransitionManager.start(slides_mc, {type:Irisdirection:Transition.INduration:0.25});
        } else if (
    transitionType == "Photo")
        {
            
    TransitionManager.start(slides_mc, {type:Photodirection:Transition.INduration:0.25});
        } else if (
    transitionType == "PixelDissolve")
        {
            
    TransitionManager.start(slides_mc, {type:PixelDissolvedirection:Transition.INduration:0.25});
        } else if (
    transitionType == "Rotate")
        {
            
    TransitionManager.start(slides_mc, {type:Rotatedirection:Transition.INduration:0.25});
        } else if (
    transitionType == "Squeeze")
        {
            
    TransitionManager.start(slides_mc, {type:Squeezedirection:Transition.INduration:0.25});
        } else if (
    transitionType == "Wipe")
        {
            
    TransitionManager.start(slides_mc, {type:Wipedirection:Transition.INduration:0.25});
        } else if (
    transitionType == "Zoom")
        {
            
    TransitionManager.start(slides_mc, {type:Zoomdirection:Transition.INduration:0.25});
        } else if (
    transitionType == "Random")
        {
            var 
    randomNumber:Number Math.round(Math.random()*9) + 1;
            switch (
    randomNumber) {
                case 
    1:
                    
    TransitionManager.start(slides_mc, {type:Blindsdirection:Transition.INduration:0.25});
                    break;
                case 
    2:
                    
    TransitionManager.start(slides_mc, {type:Fadedirection:Transition.INduration:0.25});
                    break;
                case 
    3:
                    
    TransitionManager.start(slides_mc, {type:Flydirection:Transition.INduration:0.25});
                    break;
                case 
    4:
                    
    TransitionManager.start(slides_mc, {type:Irisdirection:Transition.INduration:0.25});
                    break;
                case 
    5:
                    
    TransitionManager.start(slides_mc, {type:Photodirection:Transition.INduration:0.25});
                    break;
                case 
    6:
                    
    TransitionManager.start(slides_mc, {type:PixelDissolvedirection:Transition.INduration:0.25});
                    break;
                case 
    7:
                    
    TransitionManager.start(slides_mc, {type:Rotatedirection:Transition.INduration:0.25});
                    break;
                case 
    8:
                    
    TransitionManager.start(slides_mc, {type:Squeezedirection:Transition.INduration:0.25});
                    break;
                case 
    9:
                    
    TransitionManager.start(slides_mc, {type:Wipedirection:Transition.INduration:0.25});
                    break;
                case 
    10:
                    
    TransitionManager.start(slides_mc, {type:Zoomdirection:Transition.INduration:0.25});
                    break;
            }
        } else
        {
            
    trace("error - transitionType not recognized");
        }
    }

    if(
    buttonsOn == false)
    {
        
    prev_btn.visible false;
        
    next_btn.visible false;
    }
    slides_mc.gotoAndStop(1);
    stage.scaleMode StageScaleMode.SHOW_ALL;
    // END FUNCTIONS AND LOGIC

    stop(); 
    This is the code used in the movie instance:

    PHP Code:
    /* Click to Go to Web Page
    Clicking on the specified symbol instance loads the URL in a new browser window.

    Instructions:
    1. Replace http://www.adobe.com with the desired URL address.
       Keep the quotation marks ("").
    */

    attest_symbol.addEventListener(MouseEvent.CLICKfl_ClickToGoToWebPage);

    function 
    fl_ClickToGoToWebPage(event:MouseEvent):void
    {
        
    navigateToURL(new URLRequest("http://www.adobe.com"), "_blank");

    I'm a Flash scrub so any guidance would be much appreciated. To be specific - I want to require the 4 checkboxes be selected before a user can use the 'Next Page' button.

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,517
    Code:
    function fl_nextSlide():void
    {
            if(slides_mc.currentFrame < slides_mc.totalFrames)
            {
                    slides_mc.gotoAndStop(slides_mc.currentFrame+1);
                    if(transitionOn == true)
                    {
                            fl_doTransition();
                    }
                    if (pageNumberOn == false)
                    {
                            slideNumber_txt.text = "";
                    } else {
                            slideNumber_txt.text = String(slides_mc.currentFrame + "/" + slides_mc.totalFrames);
                    }
                    if (slides_mc.currentFrame == slides_mc.totalFrames){
                                    doChecks();
                    }
            }
    }
    function doChecks():void{
                            next_btn.visible = false;
                            slides_mc.complete1.addEventListener(Event.CHANGE, doChange);
                            slides_mc.complete2.addEventListener(Event.CHANGE, doChange);
                            slides_mc.complete3.addEventListener(Event.CHANGE, doChange);
                            slides_mc.complete4.addEventListener(Event.CHANGE, doChange);
    }
    
    var complete1:Boolean = false;
    var complete2:Boolean = false;
    var complete3:Boolean = false;
    var complete4:Boolean = false;
    
    function doChange(event:Event):void{
            this[event.currentTarget.name] = true;
            if (complete1 && complete2 && complete3 && complete4){
                    next_btn.visible = true;
            }
    }

  3. #3
    Junior Member
    Join Date
    Feb 2013
    Posts
    2
    Thank you! I failed to mention some things about the presentation in my original post but was able to sort it out using your code. It's working perfectly. Again - thank you! (there was actually a button on the last slide called 'next_page' and the slides were all in a movie clip so I had to move some of my code around as well as the 'next_page' button to prevent errors in the code). Learned a lot!

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

Poll by Flashkit.com