Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Problema azioni XML-FLASH

    Ciao a tutti ed auguri di buone feste...vengo al mio problema.
    Ho trovato un menu che con qualche modifica si adatta perfettamente al mio scopo.
    Unico problema è che non riesco a capire come ogni singola voce del menu invi le azioni allo script.
    A me servirebbe che al click su ogni voce possa passare un valore di testo, preso dall'xml (precisamente la variabile dati) per poi caricare da un txt esterno dei dati all'interno di un mc target (e questo non è un problema).

    Riassumendo quello che non capisco e come assegnare il valore ad ogni voce del menu e gestire l'evento onRelease correttamente.

    se serve metto on line anche il menu.

    Speriamo che qualcuno sia rimasto a casa anche durante le feste.


    codice:
    this._lockroot = true;
    
    itemClass.prototype = new MovieClip();
    Object.registerClass("item",itemClass);
    
    function itemClass(){
    	this.open = false;
    	itemOpen = undefined;
    	}
    
    itemClass.prototype.init = function(i){
    	this.mc = _root.menu.attachMovie("item","item"+i,10*i);
    }
    
    itemClass.prototype.onEnterFrame = function(){
    	
    	if(this.quel() <= itemToOpen){
    		this.seek = this.park;
    	}else if(this.quel() > itemToOpen){
    		this.seek = this.park + distance;
    	}else{
    		
    	}
    	this.goEase(this.seek,4);
    }
    
    itemClass.prototype.onRelease = function(){
    	
    	if(this.open){
    		itemToOpen = undefined;
    		itemToClose = this.quel();	
    	}else{
    		itemToOpen = this.quel();
    		itemToClose = undefined;
    	}
    	distance = this.distance ;
    }
    
    itemClass.prototype.quel = function(){
    	return Number(this._name.slice(4));
    }
    
    itemClass.prototype.goEase = function(target,speed){
    	this._y = this._y + (target - this._y)/speed;
    	if(Math.abs(this._y-target) < 0.8)this._y = target;
    }
    
    maxitem = "item5"; // numero menu primo livello
    
    menuClass.prototype = new MovieClip();
    function menuClass(){
    		this = _root.attachMovie("menu","menu",0);
    		this._visible = false;
    		this._data = new XML();
    		this._data._parent = this; 
    		this._data.ignoreWhite = true;;
    		this._data.load("menu.xml");
    		this._data.onLoad = parseMenu;		
    		this.init();
    }
    
    Object.registerClass("menu",menuClass);
    
    parseMenu = function(){
    	nbChilds = this.firstChild.childNodes.length;
    	//for(var i=0;i<nbChilds+1;i++){
    	for(var i in this.firstChild.childNodes){
    		temp = new itemClass();
    		temp.init(i);
    		itemMc = temp.mc;
    		itemMc._y = 20*i;
    		itemMc.park = 20*i;
    		itemMc.label = this.firstChild.childNodes[i].attributes.label;
    		
    		for(var j=0;j<this.firstChild.childNodes[i].childNodes.length;j++){
    			itemMc.attachMovie("sub","sub"+j,10*j);
    			itemMc["sub"+j]._y = 20 + 20*j;
    			itemMc["sub"+j].toto = this.firstChild.childNodes[i].childNodes[j].attributes.label;
    			//itemMc["subb"+j] = this.firstChild.childNodes[i].childNodes[j].attributes.data;
    			}
    		itemMc.distance = j*20;
    	}
    	var temp = new itemClass();
    	temp.init(this.firstChild.childNodes.length);
    	var itemMc = temp.mc;
    	itemMc._y = 20*this.firstChild.childNodes.length;
    	itemMc.park = 20*this.firstChild.childNodes.length;
    	
    	this._parent._visible = true;
    }
    
    menuClass.prototype.init = function(){
    	this.attachMovie("mask","mask",300);
    	with(this.mask){
    		_y = -1
    		_height = _root.menu[maxitem]._y;
    		_width = 171;
    	}
    	
    	this.createEmptyMovieClip("topEdge",203);
    	with(this.topEdge){
    		lineStyle( 0.25, 0x999999, 100 );
    		moveTo( 0,0);
    		lineTo(170,0);
    		lineStyle( 0.25, 0x66CCFF, 100 );
    		moveTo( 1,1);
    		lineTo(169,1);
    	}
    	this.setMask(this.mask)
    }
    menuClass.prototype.onEnterFrame = function(){
    	
    	this.mask._height = this[maxitem]._y+2;
    	
    	this.createEmptyMovieClip("leftEdge",200);
    	with(this.leftEdge){
    		lineStyle( 0.25, 0x999999, 100 );
    		moveTo( 0, 0 );
    		lineTo( 0,this[maxitem]._y );
    		lineStyle( 0.25, 0x66CCFF, 100 );
    		moveTo( 1,0);
    		lineTo( 1,this[maxitem]._y );
    	}
    	
    	this.createEmptyMovieClip("rightEdge",201);
    	with(this.rightEdge){
    		lineStyle( 0.25, 0x999999, 100 );
    		moveTo( 170, 0 );
    		lineTo( 170,this[maxitem]._y );
    		lineStyle( 0.25, 0x66CCFF, 100 );
    		moveTo( 171,1 );
    		lineTo( 171,this[maxitem]._y );
    	}
    	
    	this.createEmptyMovieClip("bottomEdge",202);
    	with(this.bottomEdge){
    		lineStyle( 0.25, 0x999999, 100 );
    		moveTo( 0,this[maxitem]._y );
    		lineTo( 170, this[maxitem]._y);
    		lineStyle( 0.25, 0x66CCFF, 100 );
    		moveTo( 0,this[maxitem]._y+1 );
    		lineTo( 170,this[maxitem]._y+1 );
    	}
    }
    
    myMenu = new menuClass();
    struttura xml
    codice:
    <menu>
    	<menuItem label="HOME" dati="">
    	</menuItem>
    	<menuItem label="Flash">
    		<sub label="Test" dati="login.swf"/>
    		<sub label="Movie" dati="test.swf"/>
    		<sub label="Portfolio" dati=""/>
    		<sub label="Portfolio2" dati=""/>
    		<sub label="Portfolio" dati=""/>
    	</menuItem>
    	<menuItem label="Art">
    		<sub label="Photos" dati="photos.swf"/>
    		<sub label="Artistes" dati="" />
    	</menuItem>	
    	<menuItem label="Contact">
    		<sub label="Mail" dati=""/>
    	</menuItem>
    	<menuItem label="More">
    		<sub label="Photos" dati="photos.swf"/>
    		<sub label="Artistes" dati="" />
    	</menuItem>	
    </menu>
    ...Non ci sono domande stupide, ma stupidi che non fanno domande...

    [Moderatore nel forum di mRcNEtwORK]
    [curgae.com]

  2. #2

    up

    davvero nessuno riesce a darmi qualche indicazione?
    ...Non ci sono domande stupide, ma stupidi che non fanno domande...

    [Moderatore nel forum di mRcNEtwORK]
    [curgae.com]

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.