A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: btn.onRelease and 'if, else' help please

  1. #1
    Junior Member
    Join Date
    Jan 2009
    Posts
    3

    btn.onRelease and 'if, else' help please

    Hi all,

    I know this is simple, but I don't know how to do it.

    I'm trying to make a horizontal menu. There are 4 menu items right now. I'm trying to figure out how to click on button one, so that button one (after clicking) slides to the left, and the other buttons slide to the right, showing the menu in between.

    easy.

    but then when I click on button two, I want it to close the menu for button one (everything going back to the original state), then open menu for button 2 by having buttons 1 and 2 slide to the left, and button 3 and 4 slide to the right, showing the menu in between 2 and 3.

    The buttons are all in a movie clip. When that movie clip opens, the buttons fade in with stop action at 19.

    This pic shows the frames for the menus sliding open and closed.


    Here is the code I have for button one

    PHP Code:
    one_btn.onRelease = function() {
        if(
    currentframe=="19"){
            
    gotoAndPlay("one");
        }else if(
    currentframe=="50"){
            
    gotoAndPlay(56);
        }else if(
    currentframe=="70"){
            
    gotoAndPlay(76);
        }else if(
    currentframe=="90"){
            
    gotoAndPlay(96);
        }

    On frames 40, 60, 80, and 100, I want to have a script that tells flash which button was pressed, then jump to the correct frame.. Know what I mean?

    Can you please tell me what I'm doing wrong. And also, if there is an easier way to do this, can you please tell me how? or direct me to a tutorial.

    Thanks in advance

  2. #2
    Space Midget Wrangler
    Join Date
    Sep 2002
    Posts
    129
    You may be better off doing this with code than with timeline. I'm not certain if its easier, but it is less work intensive and more efficient.
    A little pain never hurt anyone

  3. #3
    Junior Member
    Join Date
    Jan 2009
    Posts
    3
    Thanks. I'm a fresh born newbie. I actually don't know what kind of code to put there, but I'll keep looking.

  4. #4
    Space Midget Wrangler
    Join Date
    Sep 2002
    Posts
    129
    A good place to start is with placing your nav buttons on the stage. For example to get four in a row. Here is an example of how I would start this. Boxo in this case is a reference to a movieclip in the library that is used to build the navigation.

    PHP Code:
    var movLev:MovieClip this;
    var 
    maxBoxes:Number 4;
    function 
    initBoxes(){
        
    trace("initBoxes has been reached")
        for(var 
    i:Number 0;i<=maxBoxes;i++){
            var 
    testClip _level0.attachMovie("boxo","boxo"+i,_level0.getNextHighestDepth());
            
    trace("testClip: "+testClip);
            
    testClip._x 50*i;
            
    testClip.homePoint testClip._x;
            
    testClip.orderVal i;
            
    setActions(testClip);
            
    testClip.onRelease clickAction;
        }
    }
    function 
    clickAction():Void{
        
    trace("this.orderVal: "+this.orderVal);
        
    resetPositions();
        if(
    this.orderVal<maxBoxes){
            var 
    minVal:Number this.orderVal+1;
            for(var 
    i:Number=minVal;i<=maxBoxes;i++){
                
    movLev["boxo"+i]._x =movLev["boxo"+i].homePoint+50
            }
        }
    }
    function 
    resetPositions(){
        for(var 
    i:Number=0;i<=maxBoxes;i++){
            
    movLev["boxo"+i]._x =movLev["boxo"+i].homePoint
        }    
    }
    initBoxes(); 
    There is a still more work that would need to be done to make what you're talking about, but this is a good jump off point.

    Best Regards,

    Plasnid
    Attached Files Attached Files
    Last edited by plasnid; 01-27-2009 at 09:28 PM.
    A little pain never hurt anyone

  5. #5
    Junior Member
    Join Date
    Jan 2009
    Posts
    3
    Thanks Plasnid. I'll try that. and thx for the fla file.

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