SEARCH

Friday, April 10, 2009

Editing buttons in flash templates

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. for( ; i )
  8. {
  9. menu_item_group.menu_item.duplicateMovieClip(“menu_item”+i, i);
  10. menu_item_group[“menu_item”+i].over = true;
  11. var each_substring:String = menu_label[i].split(“|”);
  12. menu_item_group[“menu_item”+i].item_label = each_substring[0];
  13. menu_item_group[“menu_item”+i].item_url = each_substring[1];
  14. menu_item_group[“menu_item”+i].item_no = i;
  15. menu_item_group[“menu_item”+i]._x = i * distance_x;
  16. }
  17. function change_page(no):Void
  18. {
  19. for( i = 0; i )
  20. {
  21. menu_item_group[“menu_item”+i].flashmo_button._visible = true;
  22. menu_item_group[“menu_item”+i].over = true;
  23. menu_item_group[“menu_item”+i].flashmo_button.onRollOver = function()
  24. {
  25. this._parent.over = false;
  26. }
  27. menu_item_group[“menu_item”+i].flashmo_button.onRollOut =
  28. menu_item_group[“menu_item”+i].flashmo_button.onDragOut = function()
  29. {
  30. this._parent.over = true;
  31. }
  32. menu_item_group[“menu_item”+i].flashmo_button.onRelease = function()
  33. {
  34. if( this._parent.item_url != undefined )
  35. getURL(this._parent.item_url, “_parent”);
  36. else
  37. _root.change_page(this._parent.item_no);
  38. }
  39. menu_item_group[“menu_item”+i].onEnterFrame = function()
  40. {
  41. if( this.over == true ) this.prevFrame();
  42. else this.nextFrame();
  43. }
  44. }
  45. delete menu_item_group[“menu_item”+no].flashmo_button.onRollOut;
  46. menu_item_group[“menu_item”+no].flashmo_button._visible = false;
  47. menu_item_group[“menu_item”+no].over = false;
  48. _root.page = no + 1;
  49. _root.play();
  50. }
  51. 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

No comments:

Post a Comment