Editing buttons in flash templates

Posted by admin in Flash, Tutorials

This is a quick solution for those who wanted to assign some buttons to go to web pages or URLs in existing main menu of flashmo.com templates. Button action scripts are usually located on first frame of actions layer.

First, you need to use the separator | between button label and URL. e.g. “Services|service.html”, “Company|http://www.flashmo.com” for buttons which are pointing to other web pages.

Actionscript:
  1. var menu_label:Array = new Array(“Home”, “Services|service.html”, “Testimonials”,
  2. “Company|http://www.flashmo.com”, “Contact”);

Second, add a few lines of codes for splitting button label and URL.

Actionscript:
  1. var each_substring:String = menu_label[i].split(“|”);
  2. menu_item_group[“menu_item”+i].item_label = each_substring[0];
  3. menu_item_group[“menu_item”+i].item_url = each_substring[1];

Third, add if else statement to check the URL exists or not in button onRelease action.

Actionscript:
  1. if( this._parent.item_url != undefined )
  2. getURL(this._parent.item_url, “_parent”);
  3. else
  4. _root.change_page(this._parent.item_no);

Here is the complete source codes.

Actionscript:
  1. menu_item_group.menu_item._visible = false;
  2. var menu_label:Array = new Array(“Home”, “Services|service.html”, “Testimonials”,
  3. “Company|http://www.flashmo.com”, “Contact”);
  4. var total:Number = menu_label.length;
  5. var distance_x:Number = 124;
  6. var i:Number = 0;
  7.  
  8. for( ; i <total; i++ )
  9. {
  10. menu_item_group.menu_item.duplicateMovieClip(“menu_item”+i, i);
  11. menu_item_group[“menu_item”+i].over = true;
  12.  
  13. var each_substring:String = menu_label[i].split(“|”);
  14. menu_item_group[“menu_item”+i].item_label = each_substring[0];
  15. menu_item_group[“menu_item”+i].item_url = each_substring[1];
  16. menu_item_group[“menu_item”+i].item_no = i;
  17. menu_item_group[“menu_item”+i]._x = i * distance_x;
  18. }
  19. function change_page(no):Void
  20. {
  21. for( i = 0; i <total; i++ )
  22. {
  23. menu_item_group[“menu_item”+i].flashmo_button._visible = true;
  24. menu_item_group[“menu_item”+i].over = true;
  25. menu_item_group[“menu_item”+i].flashmo_button.onRollOver = function()
  26. {
  27. this._parent.over = false;
  28. }
  29. menu_item_group[“menu_item”+i].flashmo_button.onRollOut =
  30. menu_item_group[“menu_item”+i].flashmo_button.onDragOut = function()
  31. {
  32. this._parent.over = true;
  33. }
  34. menu_item_group[“menu_item”+i].flashmo_button.onRelease = function()
  35. {
  36. if( this._parent.item_url != undefined )
  37. getURL(this._parent.item_url, “_parent”);
  38. else
  39. _root.change_page(this._parent.item_no);
  40. }
  41. menu_item_group[“menu_item”+i].onEnterFrame = function()
  42. {
  43. if( this.over == true ) this.prevFrame();
  44. else this.nextFrame();
  45. }
  46. }
  47. delete menu_item_group[“menu_item”+no].flashmo_button.onRollOut;
  48. menu_item_group[“menu_item”+no].flashmo_button._visible = false;
  49. menu_item_group[“menu_item”+no].over = false;
  50. _root.page = no + 1;
  51. _root.play();
  52. }
  53. change_page(0); // the default page on load

Edit the timeline in menu item movie clip for rollover effect for modifying the button effect.
Edit menu item label movie clip for embedding characters in your language font. See the example below:

Embedding Font in Flash