Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2004
    Messaggi
    281

    non devo usare attachMovie() per i componenti

    Ciao, conosco pochissimo di action script.
    Io ho in libreria il componente "Menu a tendina".
    Se lo trascino con il mouse sullo stage funziona.
    Come devo fare a metterlo sullo stage usando il codice ?

    Ho provato cosi' ma non funziona.
    _root.attachMovie("Menu a tendina", "menu_1", 1);

  2. #2
    Utente di HTML.it
    Registrato dal
    Mar 2004
    Messaggi
    281
    Questo qui sotto e' il codice del "Menu a tendina"
    Codice PHP:
    #initclip 2
    MyMenuClass = function () {
        
    this.init();
    };
    MyMenuClass.prototype = new MovieClip();
    Object.registerClass("Menu"MyMenuClass);
    MyMenuClass.prototype.init = function() {
        
    this.buttonLabels = [];
        
    this.buttonFunctions = [];
        
    this.buttonArguments = [];
        
    this.buttonTargets = [];
        
    this._w this._width;
        
    this._h = (this._height<16) ? 16 this._height;
        
    this._xscale 100;
        
    this._yscale 100;
        
    this.xmlData = new XML();
        
    this.xmlData.ignoreWhite true;
        
    this.xmlData.load(this.xmlFile);
        
    this.xmlData._p this;
        
    this.xmlData.onLoad = function(ok) {
            if (
    ok) {
                
    this._p.readXML(this._p.xmlData);
                
    this._p.drawMenu();
                
    delete this._p.xmlData;
            }
        };
    };
    MyMenuClass.prototype.drawMenu = function() {
        
    this.createEmptyMovieClip("menuHitArea"0);
        
    this.menuHitArea._visible false;
        
    this.resetHitArea();
        
    this.hitArea this.menuHitArea;
        
    this.createEmptyMovieClip("menuBackground"this.buttonLabels.length+1);
        
    with (this.menuBackground) {
            
    beginFill(_parent.fillColor100);
            
    moveTo(00);
            
    lineStyle(1_parent.borderColor100);
            
    lineTo(_parent._w0);
            
    lineTo(_parent._w_parent._h);
            
    lineTo(0_parent._h);
            
    endFill();
        }
        var 
    format = new TextFormat("nitida_FFF Galaxy"8this.menuTextColortruenullnullnullnull"center");
        
    this.attachMovie("Label""menuLabel"this.buttonLabels.length+2);
        
    this.menuLabel._y = (this._h-18)/2;
        
    this.menuLabel.init();
        
    this.menuLabel.setMyLabelFormat(format);
        
    //this.menuLabel.setMyLabel(this.label);
        
    this.menuLabel.setMyLabel(titolomenu);
        
    this.onRollOver = function() {
            
    this.drawSubMenu();
        };
        
    this.onRollOut = function() {
            
    this.killSubMenu();
        };
        
    this.onDragOut = function() {
            
    this.killSubMenu();
        };
    };
    MyMenuClass.prototype.killSubMenu = function() {
        for (var 
    0i<this.buttonLabels.lengthi++) {
            
    this["Button"+i].removeMovieClip();
        }
        
    this.resetHitArea();
    };
    MyMenuClass.prototype.resetHitArea = function() {
        
    with (this.menuHitArea) {
            
    clear();
            
    beginFill(0x000000100);
            
    moveTo(00);
            
    lineStyle(00x000000100);
            
    lineTo(_parent._w0);
            
    lineTo(_parent._w_parent._h);
            
    lineTo(0_parent._h);
            
    endFill();
        }
    };
    MyMenuClass.prototype.resizeHitArea = function(pt0pt1pt2pt3pt4pt5) {
        
    with (this.menuHitArea) {
            
    beginFill(0x000000100);
            
    moveTo(pt0[0], pt0[1]);
            
    lineStyle(00x000000100);
            
    lineTo(pt1[0], pt1[1]);
            
    lineTo(pt2[0], pt2[1]);
            
    lineTo(pt3[0], pt3[1]);
            
    lineTo(pt4[0], pt4[1]);
            
    lineTo(pt5[0], pt5[1]);
            
    lineTo(pt0[0], pt0[1]);
            
    endFill();
        }
    };
    MyMenuClass.prototype.drawSubMenu = function() {
        switch (
    this.open) {
        case 
    "giù_centro" :
            var 
    x0 0;
            var 
    y0 0;
            var 
    x1 this._w;
            var 
    y1 0;
            var 
    x2 x1;
            var 
    y2 = (this.buttonLabels.length+1)*this.menuBackground._height-1;
            var 
    x3 0;
            var 
    y3 y2;
            var 
    x4 0y4 0x5 0y5 0;
            break;
        }
        
    this.resizeHitArea([x0y0], [x1y1], [x2y2], [x3y3], [x4y4], [x5y5]);
        for (var 
    0i<this.buttonLabels.lengthi++) {
            
    with (this.attachMovie("Button""Button"+ithis.buttonLabels.length-i)) {
                
    init(this.buttonTargets[i], this.buttonFunctions[i], this.buttonArguments[i]);
                
    _x 0;
                
    _y 0;
                
    setButtonLabel(this.buttonLabels[i]);
            }
        }
        
    this.menuAnimation();
    };
    MyMenuClass.prototype.menuAnimation = function() {
        var 
    gap = (this.menuBackground._height+this.menuBackground._height)/4;
        switch (
    this.open) {
        case 
    "giù_centro" :
            
    this.onEnterFrame = function() {
                for (var 
    0i<this.buttonLabels.lengthi++) {
                    
    this["Button"+i]._y = (this["Button"+i]._y<(this.menuBackground._height+(this.menuBackground._height)*i)) ? this["Button"+i]._y+gap this.menuBackground._height+(this.menuBackground._height)*i;
                    
    this["Button"+i].setActive((this["Button"+i]._y == this.menuBackground._height+(this.menuBackground._height)*i) ? true false);
                }
            };
            break;
        }
    };
    MyMenuClass.prototype.readXML = function(xml) {
        var 
    Nodes xml.childNodes[0].childNodes;
        
    titolomenu xml.childNodes[0].attributes.nome;
        for (var 
    0i<Nodes.lengthi++) {
            
    this.buttonLabels.push(Nodes[i].attributes.etichetta);
            
    this.buttonTargets.push(Nodes[i].attributes.target);
            
    this.buttonFunctions.push(Nodes[i].attributes.funzione);
            
    this.buttonArguments.push(Nodes[i].attributes.parametri.split(","));
        }
    };
    #endinitclip
    area_anteprima._visible false

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.