Got an iPhone or iPad? We have a brand new Pastebin App for both devices, and it's totally free! Click here to download the new Pastebin App for iOS.
Guest

Untitled

By: a guest on Feb 12th, 2012  |  syntax: None  |  size: 2.80 KB  |  hits: 36  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. import fl.motion.Color;
  2. import flash.geom.ColorTransform;
  3.  
  4. *  //Begin set up of the URLs//
  5. *  import flash.events.MouseEvent;
  6.  
  7. *  //btn1//
  8. *  var url_btn1:URLRequest = new URLRequest("http:www.flashden.net");
  9. *  btn1.addEventListener(MouseEvent.CLICK, btn1Click);
  10. *  function btn1Click(event:MouseEvent):void{navigateToURL(url_btn1);}
  11.  
  12. *  //btn2//
  13. *  var url_btn2:URLRequest = new URLRequest("http:www.google.com");
  14. *  btn2.addEventListener(MouseEvent.CLICK, btn2Click);
  15. *  function btn2Click(event:MouseEvent):void{navigateToURL(url_btn2);}
  16.  
  17. *  //btn3//
  18. *  var url_btn3:URLRequest = new URLRequest("http:www.youtube.com");
  19. *  btn3.addEventListener(MouseEvent.CLICK, btn3Click);
  20. *  function btn3Click(event:MouseEvent):void{navigateToURL(url_btn3);}
  21.  
  22. *  //btn4//
  23. *  var url_btn4:URLRequest = new URLRequest("http:www.yahoo.com");
  24. *  btn4.addEventListener(MouseEvent.CLICK, btn4Click);
  25. *  function btn4Click(event:MouseEvent):void{navigateToURL(url_btn4);}
  26.  
  27. *  //End set up of the URLs//
  28.  
  29. var btnClicked:String = "";
  30. var l:Label;
  31.  
  32. var labelArray:Array = ["", "Home", "Download", "About us", "Contact"];
  33. var objArray:Array = new Array();
  34.  
  35. btn1.addEventListener(MouseEvent.ROLL_OVER, manageOver);
  36. btn1.addEventListener(MouseEvent.ROLL_OUT, manageOut);
  37. btn1.addEventListener(MouseEvent.CLICK, manageClick);
  38.  
  39. btn2.addEventListener(MouseEvent.ROLL_OVER, manageOver);
  40. btn2.addEventListener(MouseEvent.ROLL_OUT, manageOut);
  41. btn2.addEventListener(MouseEvent.CLICK, manageClick);
  42.  
  43. btn3.addEventListener(MouseEvent.ROLL_OVER, manageOver);
  44. btn3.addEventListener(MouseEvent.ROLL_OUT, manageOut);
  45. btn3.addEventListener(MouseEvent.CLICK, manageClick);
  46.  
  47. btn4.addEventListener(MouseEvent.ROLL_OVER, manageOver);
  48. btn4.addEventListener(MouseEvent.ROLL_OUT, manageOut);
  49. btn4.addEventListener(MouseEvent.CLICK, manageClick);
  50.  
  51. init();
  52.  
  53. function init():void
  54. {
  55.         btnClicked = "btn1";
  56.        
  57.         var mc:MovieClip;
  58.         var j:int;
  59.         for(var i:int = 1; i<5; i++)
  60.         {
  61.                 mc = this["btn"+i];
  62.                 mc.id = i;
  63.                
  64.                 l = new Label(labelArray[i]);
  65.                 l.name = "label";
  66.                 l.x = Math.round(((mc.width*1.6) - l.width)/2);
  67.                 l.y = Math.round(mc.content.y+mc.content.height+l.height+5);
  68.                 l.alpha = 0;
  69.                
  70.                 mc.addChild(l);
  71.                
  72.                 objArray[i] = l;
  73.         }
  74.        
  75.         Label(objArray[btn1.id]).alpha = 100;
  76. }
  77.  
  78. function resetButtons():void
  79. {
  80.         var len:int = objArray.length; 
  81.        
  82.         for(var i:int = 1; i<len; i++)
  83.         {
  84.                 Label(objArray[i]).setAlphaOut();
  85.         }
  86. }
  87.  
  88. function manageOver(pEvt:MouseEvent):void
  89. {
  90.         resetButtons();
  91.                
  92.         Label(objArray[pEvt.target.id]).setAlphaIn();
  93. }
  94.  
  95. function manageOut(pEvt:MouseEvent):void
  96. {
  97.         resetButtons();
  98.        
  99.         if(btnClicked != "")
  100.         {
  101.                 var mc:MovieClip = getChildByName(btnClicked) as MovieClip;
  102.                 Label(objArray[mc.id]).setAlphaIn();
  103.         }
  104. }
  105.  
  106. function manageClick(pEvt:MouseEvent):void
  107. {
  108.         btnClicked = pEvt.target.name;
  109. }