A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: How to active my buttons when mc is opacity 100

Threaded View

  1. #1
    Member
    Join Date
    Jun 2009
    Posts
    40

    How to active my buttons when mc is opacity 100

    I have buttons inside/on window01/mc that are still active/clickable when the opacity is 0, I basically have a area on my website that if you click it opens the window corresponding to the button. how do I stop this? I only want the buttons to work when window01 is opacity 100. I'm not a pro at AS so please if you reply, walk me through it a bit or edit my code.

    http://frozen-gecko.net/quicky.htm

    just click in the blank black area below the nav bar and the window will appear. The normal way to get to this window is click products than the buttons.

    Code:
    import gs.TweenLite; 
    
    
    btn06.addEventListener(MouseEvent.CLICK,f2);
    function f2(e:Event){
    navigateToURL(new URLRequest("http://www.jmoneyaudio.com/"), "_self");
    
    }
    //first we're making sure none of your content windows are
    //being displayed when the movie launches
    window01.alpha=window02.alpha=window03.alpha=window04.alpha=window05.alpha=pwindow01.alpha=pwindow02.alpha=pwindow03.alpha=0;
    
    //this doesn't change: just listening for mouse clicks
    addEventListener(MouseEvent.CLICK,onClick,false,0,true);
    
    //this changes a bit. Rather than dealing with the visible
    //property of the windows, we'll be tweening alpha properties
    var isTweening:Boolean=false;
    function resetBool():void {
        isTweening=false;
    }
    function onClick(e:MouseEvent):void {
        if (!isTweening) {
            isTweening=true;
            switch (e.target) {
                case btn01 :
                    closeWindows();
                    TweenLite.to(window01,1,{alpha:1,overwrite:false,onComplete:resetBool});//this is a call to
                    //the TweenLite class you set up earlier: The first parameter is the
                    //display object you're targeting (window0x), the second param is
                    //length of time the tween will take to complete in whole seconds
                    //(1 second), then all properties for the display object are listed in
                    //the third param within {}, in this case we're changing the alpha
                    //from 0 to 1 and we don't want this tween call to interrupt/overwrite
                    //any previous tween calls
                    break;
                case btn02 :
                    closeWindows();
                    TweenLite.to(window02,1,{alpha:1,overwrite:false,onComplete:resetBool});
                    break;
                case btn03 :
                    closeWindows();
                    TweenLite.to(window03,1,{alpha:1,overwrite:false,onComplete:resetBool});
                    break;
                case btn04 :
                    closeWindows();
                    TweenLite.to(window04,1,{alpha:1,overwrite:false,onComplete:resetBool});
                    break;
    			case btn05 :
                    closeWindows();
                    TweenLite.to(window05,1,{alpha:1,overwrite:false,onComplete:resetBool});
                    break;
    				
    			case window01.pbtn01 :
                    closeWindows();
                    TweenLite.to(pwindow01,1,{alpha:1,overwrite:false,onComplete:resetBool});
                    break;
    				
    			case window01.pbtn02 :
                    closeWindows();
                    TweenLite.to(pwindow02,1,{alpha:1,overwrite:false,onComplete:resetBool});
                    break;
    				
    			case window01.pbtn03 :
                    closeWindows();
                    TweenLite.to(pwindow03,1,{alpha:1,overwrite:false,onComplete:resetBool});
                    break;
    
                default :
                    return;
            }
        }
    } 
    
    function closeWindows():void{
    //for each of these ifs we're looking for the object that is currently
    //being displayed (we know this because it's alpha will be equal to 1)
    //and then tweening its alpha property down to 0 over 1 second
    if(window01.alpha==1) TweenLite.to(window01,1,{alpha:0});
    else if(window02.alpha==1) TweenLite.to(window02,1,{alpha:0});
    else if(window03.alpha==1) TweenLite.to(window03,1,{alpha:0});
    else if(window04.alpha==1) TweenLite.to(window04,1,{alpha:0});
    else if(window05.alpha==1) TweenLite.to(window05,1,{alpha:0});
    else if(pwindow01.alpha==1) TweenLite.to(pwindow01,1,{alpha:0});
    else if(pwindow02.alpha==1) TweenLite.to(pwindow02,1,{alpha:0});
    else if(pwindow03.alpha==1) TweenLite.to(pwindow03,1,{alpha:0});
    } 
    
    
    
    //BTN STUFF!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    
    btn01.alpha=.60; 
    btn02.alpha=.60; 
    btn03.alpha=.60; 
    btn04.alpha=.60; 
    btn05.alpha=.60; 	
    btn06.alpha=.60;
    window01.pbtn01.alpha=.60;
    window01.pbtn02.alpha=.60; 
    window01.pbtn03.alpha=.60;
    
    
    btn01.addEventListener(MouseEvent.MOUSE_OVER,onBtnOver,false,0,true);
    btn01.addEventListener(MouseEvent.MOUSE_OUT,onBtnOut,false,0,true);
    
    btn02.addEventListener(MouseEvent.MOUSE_OVER,onBtnOver,false,0,true);
    btn02.addEventListener(MouseEvent.MOUSE_OUT,onBtnOut,false,0,true);
    
    btn03.addEventListener(MouseEvent.MOUSE_OVER,onBtnOver,false,0,true);
    btn03.addEventListener(MouseEvent.MOUSE_OUT,onBtnOut,false,0,true);
    
    btn04.addEventListener(MouseEvent.MOUSE_OVER,onBtnOver,false,0,true);
    btn04.addEventListener(MouseEvent.MOUSE_OUT,onBtnOut,false,0,true);
    
    
    btn05.addEventListener(MouseEvent.MOUSE_OVER,onBtnOver,false,0,true);
    btn05.addEventListener(MouseEvent.MOUSE_OUT,onBtnOut,false,0,true);
    
    btn06.addEventListener(MouseEvent.MOUSE_OVER,onBtnOver,false,0,true);
    btn06.addEventListener(MouseEvent.MOUSE_OUT,onBtnOut,false,0,true);
    
    window01.pbtn01.addEventListener(MouseEvent.MOUSE_OVER,onBtnOver,false,0,true);
    window01.pbtn01.addEventListener(MouseEvent.MOUSE_OUT,onBtnOut,false,0,true);
    
    window01.pbtn02.addEventListener(MouseEvent.MOUSE_OVER,onBtnOver,false,0,true);
    window01.pbtn02.addEventListener(MouseEvent.MOUSE_OUT,onBtnOut,false,0,true);
    
    window01.pbtn03.addEventListener(MouseEvent.MOUSE_OVER,onBtnOver,false,0,true);
    window01.pbtn03.addEventListener(MouseEvent.MOUSE_OUT,onBtnOut,false,0,true);
    
    
    function onBtnOver(e:MouseEvent):void{
    TweenLite.to(e.target, 0.8, {alpha:1});
    }
    function onBtnOut(e:MouseEvent):void{
    TweenLite.to(e.target, 0.8, {alpha:0.6});
    }
    Last edited by FrozenGecko; 07-26-2009 at 12:55 AM.

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