Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Modifica template menu

  1. #1

    Modifica template menu

    Salve, ho di nuovo un problema legato a un template menu.

    Questo è il codice AS

    codice:
    //import classes and packages
     import mx.transitions.easing.*;
     import gs.TweenMax;
    
     //create function to add buttons on menu
     function addButtons() { 
    pushOverY = 0;
     for (i=0; i<totalButtons; i++) { 
    menu.attachMovie("rectangle","rectangle",-1,{_x:0, _y:rY});
    btn = menu.attachMovie("button", "btn"+i, i, {_x:0, _y:pushOverY, id:i});
     btn.initialY = btn._y;
     btn.textMC.t.autoSize = "left";
     btn.textMC.t.text = obj.buttons[i].attributes.title;
     btn.textMC.t.textColor = iC; 
    pushOverY += 42; 
    
    //set events for this button
    setBtnEvents(btn);
    
     //add submenu items 
    pushOverX = 0; 
    btn.totalSubItems = obj.buttons[i].childNodes.length;
     for (j=0; j<btn.totalSubItems; j++) {
     subItem = btn.subMenu.attachMovie("subItem", "subItem"+j, j, {_x:pushOverX, _y:0, id:j});
     subItem.t.autoSize = "left"; subItem.t.text = obj.buttons[i].childNodes[j].attributes.title; 
    subItem.t.textColor = siC; 
    pushOverX += subItem._width+10; } }
     Mouse.addListener(mouseListener); 
    
    } 
    //create function for buttons events
     function setBtnEvents(btn:MovieClip) { 
    
    btn.back.onRollOver = function() { 
    overBtn = this._parent;
     if(this != pressedBtn){ 
    if(pressedBtn != undefined){ 
    tweenBtn(pressedBtn,100,iC,42,.8); 
    } 
    tweenBtn(this,160,iROC,90,.8);
     tweenRectangle(this._parent.initialY,.8); 
    } }; 
    
    btn.back.onRollOut = function() {
     if(this != pressedBtn){ 
    if(pressedBtn != undefined){ 
    tweenBtn(pressedBtn,160,iROC,90,.8); 
    tweenRectangle(pressedBtn._parent.initialY,.8); }
    else{
     tweenRectangle(rY,.8); }
     tweenBtn(this,100,iC,42,.8); } };
    
     btn.back.onPress = function() {
     pressedBtn = this;
     //if is not pressed over subMenu then select the first subitem if(!pressedBtn._parent.subMenu.hitTest(_xmouse,_ymouse)){
     var cl:Color = new Color(pressedSubItem); 
    cl.setRGB(siC);
     pressedSubItem = pressedBtn._parent.subMenu["subItem"+0];
     var cl:Color = new Color(pressedSubItem); cl.setRGB(siROC); //ADD HERE CUSTOM FUNCTION } } }
    
     //create tweens with TweenMax
     function tweenBtn(mc:MovieClip,textScale:Number,textTint:Number,backHeight:Number,sec:Number){ 
    mc.lastHeight = mc._height; 
    TweenMax.to(mc._parent.textMC,sec,{_xscale:textScale, _yscale:textScale, tint:textTint, ease:Strong.easeOut});
     TweenMax.to(mc,sec,{_height:backHeight, ease:Strong.easeOut, onUpdate:moveButtons, onUpdateParams:[mc]}); 
    }
     function tweenRectangle(newY:Number,sec:Number){
     TweenMax.to(menu.rectangle,sec,{_y:newY, ease:Strong.easeOut}); }
    
     function moveButtons(btn:MovieClip) {
     btn.currentHeight = btn._height;
     for (i=btn._parent.id+1; i<totalButtons; i++) { 
    menu["btn"+i]._y += btn.currentHeight-btn.lastHeight; } 
    btn.lastHeight = btn._height; } 
    
    var rY = 355; //rectangle initial y 
    var iC:Number = new Number();//item color
    var iROC:Number = new Number();//iem rollover color 
    var siC:Number = new Number();//subitem color var siROC:Number = new Number();//subitem rollover color 
    
    var totalButtons:Number = new Number(); 
    var overBtn:MovieClip = new MovieClip(); var 
    
    pressedBtn:MovieClip = undefined; var 
    pressedSubItem:MovieClip = new MovieClip(); 
    
    var mouseListener:Object = new Object(); 
    
    //create subItems events
     mouseListener.onMouseMove = function() {
     overSubItems = 0;
     for (j=0; j<overBtn.totalSubItems; j++) {
     s = overBtn.subMenu["subItem"+j]; 
    if (s.hitTest(_xmouse, _ymouse)) { 
    var cl:Color = new Color(s); 
    cl.setRGB(siROC); 
    overSubItems++; } else {
     var cl:Color = new Color(s); 
    cl.setRGB(siC); 
    } }
     if (overSubItems == 0) { 
    var cl:Color = new Color(pressedSubItem); 
    cl.setRGB(siROC); } }; 
    
    mouseListener.onMouseDown = function() { 
    for (j=0; j<overBtn.totalSubItems; j++) { 
    s = overBtn.subMenu["subItem"+j]; 
    if (s.hitTest(_xmouse, _ymouse)) { 
    pressedSubItem = s; 
    //ADD HERE CUSTOM FUNCTION } } };
    
     //object that contains data from xml
     var obj:Object = new Object(); 
    
    //create new xml object var xml:XML = new XML(); 
    xml.ignoreWhite = true; 
    
    //after the xml is loaded, load variables and parse the date to obj 
    xml.onLoad = function(succes) {
     if (succes) { 
    //get colors values from xml
     iC = Number(this.firstChild.attributes.itemColor);
     iROC = Number(this.firstChild.attributes.itemRollOverColor);
     siC = Number(this.firstChild.attributes.subitemColor);
     siROC = Number(this.firstChild.attributes.subitemRollOverColor);
    
     obj.buttons = this.firstChild.childNodes; 
    totalButtons = obj.buttons.length;
    
     //function call addButtons();
     } else 
    { trace("xml could not load"); } }; 
    
    //the path to the xml file 
    xml.load("menu.xml");
    
     urlMC.onPress = function(){ 
    getURL ("http://www.nogrids.com", "_blank"); 
    }
    Sapete dirmi dove è possibile andare a modificare il codice per editare le voci del menu ed eventualmente la dimensione del font?

    Grazie in anticipo.

  2. #2
    Nessuno?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.