Solved

** Simple IF Statement** URGENT **

Posted on 2004-04-22
11
225 Views
Last Modified: 2010-04-03
Ok,

This should be some easy points.  All I need is a simple IF STATEMENT.  

I have 3 links in my navigation all aligned on the left.  When the user clicks a link, that link will slide to the right. ...then the page will load... And then when/if the user clicks another link, the link clicked before will slide back as the recently clicked link will slide right.  I hope this makes sense.

Thanks

Mtb007
0
Comment
Question by:mtb007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 3
11 Comments
 
LVL 22

Expert Comment

by:rascalpants
ID: 10892626
you can always do this the easy way...

btnFunction=function(btn){
 
 if(btn == 1){
    _root.button1._x = 50;
    _root.button2._x = 5;
    _root.button3._x = 5;
  } else if(btn == 2){
    _root.button1._x = 5;
    _root.button2._x = 50;
    _root.button3._x = 5;
  } else if(btn == 3){
    _root.button1._x = 5;
    _root.button2._x = 5;
    _root.button3._x = 50;
  }

};


button1.onRelease=function(){
  btnFunction(1);
};
button2.onRelease=function(){
  btnFunction(2);
};
button3.onRelease=function(){
  btnFunction(3);
};


just put all of the above code on the first frame of your movie, and give your 3 buttons instance names "button1", "button2", "button3"


there are hundreds of ways to do this, but this seems to work fine...

rp
0
 
LVL 1

Author Comment

by:mtb007
ID: 10892750
Thats perfect except for I need it to actually slide right and left. not just jump.
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 10893359
this code might need a little tweaking, but it will get you on your way:

lastBtn = "";

btnFunction=function(btn){
  onEnterFrame=function(){
    if(_root["button" + btn]._x < 50){
      _root["button" + btn]._x = _root["button" + btn]._x + 5;
      _root["button" +_root.lastBtn]._x = _root["button" +_root.lastBtn]._x - 5;
    } else {
      _root.lastBtn = btn;
      endLoop();
    }
  }
}

endLoop=function(){
  onEnterFrame = null;
};

button1.onRelease=function(){
  btnFunction(1);
};
button2.onRelease=function(){
  btnFunction(2);
};
button3.onRelease=function(){
  btnFunction(3);
};



rp
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 1

Author Comment

by:mtb007
ID: 10893418
Ok, one last Q.  Is there are way that you can ease it in and out?  Specifically at the end, so it slows down?
0
 
LVL 1

Author Comment

by:mtb007
ID: 10893441
Also, if you click them fast it goes all over the place.
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 10893630
the ease in and out is trig, and I think as a beginner, you should try not to use anything like that...  even I have trouble with that stuff sometimes...  not the best at complex math...


yah, some tinkering needs to be done to the code to keep it all aligned when you click during the loop...

have to brain storm that one...

rp
0
 
LVL 22

Accepted Solution

by:
rascalpants earned 250 total points
ID: 10893895
this will prevent the user from breaking the interface...

lastBtn = 0;
disable = "no";

btnFunction=function(btn){
      _root.disable = "yes";
      onEnterFrame=function(){
            if(_root["button" + btn]._x < 50){
                  _root["button" + btn]._x = _root["button" + btn]._x + 5;
                  _root["button" +_root.lastBtn]._x = _root["button" +_root.lastBtn]._x - 5;
            } else {
                  _root.lastBtn = btn;
                  endLoop();
            }
      }
}

endLoop=function(){
      onEnterFrame = null;
      _root.disable = "no";
};


button1.onRelease=function(){
      if(_root.disable == "no"){
            btnFunction(1);
      }
};
button2.onRelease=function(){
      if(_root.disable == "no"){
            btnFunction(2);
      }
};
button3.onRelease=function(){
      if(_root.disable == "no"){
            btnFunction(3);
      }
};


rp
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 10893974
here is my example:

http://www.kcnewmedia.com  <-- delete these spaces -->  /dev/sliding_menus/

I changed the x position to 100 and change the increment to 25 in both parts of the code, and it runs faster...

rp
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 10893991
I am not sure what you are doing with these things, but you can turn the buttons into movieclips, and create all sorts of navigation functionality and customization.


rp
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 10918436
Jason,

what is the status of this question...

rp
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 10918488
I guess you liked what I did above...

glad to help...


rp
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question