A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: re: moving buttons

  1. #1
    Junior Member
    Join Date
    Apr 2005
    Location
    leeds
    Posts
    5

    re: moving buttons

    hi im kinda new to flash (i know about the basics but not that very good in coding) so was looking for some help
    i have a freelance project that requires

    the centre page to have 5 words floating about
    but when u put the mouse over them , the other words
    disappear leaving the main word with a definition

    at the moment im think of making a movie with buttons contained it
    but not sure

  2. #2
    Senior Member
    Join Date
    Mar 2005
    Posts
    206
    I just code, so I don't know how to do this without actionscript.


    What I would do is dynamically generate the buttons, which would be movie clips that have a dynamic textfield. Give each button an event handler that detects a mouse rollover, and when that happens, all the other buttons disappear, etc.

    I'll give you some code to start with:

    create a movieclip with the name "tbutton" and put a dynamic textfield in it with the name "myText"

    Then put this code into the first frame of your fla:

    Code:
    for(var i=0; i < 5; i++)
    	{
    		cbtn = attachMovie("tbutton", "tbutton" + i,  i);
    		
    		
    		cbtn._x = (put some random position here)
    		cbtn._y = (put some random position here)
    
    
    		cbtn.onRollOut = btnRollOut;
    		cbtn.onRollOver = btnRollOver;
    		cbtn.stop();
    		cbtn.active = false;
    		cbtn.myText._visible = true;
    
    	
    		cbtn.onRollOver = function(){
    					cbtn.active = true;
    					for(var i = 0; i < 5; i++){
      						if(!this["tbutton"+i].active) {
    						 	cbtn.myText._visible = false;
    						}
    					}
    
    
    }
    
    //now you have to individuall assign each button its text value:
    
    this["tbutton"+0"].myText.text = "word0";
    this["tbutton"+1"].myText.text = "word1";
    this["tbutton"+2"].myText.text = "word2";
    this["tbutton"+3"].myText.text = "word3";
    this["tbutton"+4"].myText.text = "word4";

    This just gets the words to disappear.

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