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

    [MX] prototype & onEnterFrame

    ho questo prototype:

    codice:
    MovieClip.prototype.slowSetProperty = function(prop, newVal, b) {
    	var bb, prevVal;
    	bb = (b == undefined) ? 5 : b;
    	prevVal = this[prop];
    	this.onEnterFrame = function() {
    		this[prop] += (newVal-this[prop])/bb;
    		if (Math.abs(this[prop]-prevVal)<.01) {
    			this[prop] = newVal;
    			delete this.onEnterFrame;
    		} else {
    			prevVal = this[prop];
    		}
    	};
    };
    che uso così:

    codice:
    mioClip.slowSetProperty("_x", 100);
    e fin qui tutto bene...

    ma se voglio fare:
    codice:
    mioClip.slowSetProperty("_x", 100);
    mioClip.slowSetProperty("_xScale", 200);
    non posso farlo...
    funziona solo la seconda chiamata che naturalmente cancella onEnterFrame della prima.

    Come risolvo?
    [Il mio sito V2]
    ___________________
    I.m.The.Magic.Man

  2. #2
    Utente di HTML.it L'avatar di negatyve
    Registrato dal
    Feb 2001
    Messaggi
    9,479
    codice:
    MovieClip.prototype.slowSetProperty = function(prop, newVal, b)
    {
    
    	this[prop + "_bb"] = (b == undefined) ? 5 : b;
    	this[prop + "_newVal"] = newVal;
    	clearInterval(this[prop + "_interval"])
    	this[prop + "_interval"] = setInterval(this, "slowChangeProperty", 20, prop);
    };
    MovieClip.prototype.slowChangeProperty = function(prop)
    {
    	this[prop] += (this[prop + "_newVal"] - this[prop]) / this[prop + "_bb"];
    	if (Math.abs(this[prop] - this[prop + "_newVal"]) < .01) {
    		this[prop] = this[prop + "_newVal"];
    		clearInterval(this[prop + "_interval"]);
    	}
    };
    mioClip.slowSetProperty("_x", 100);
    mioClip.slowSetProperty("_xScale", 200);

  3. #3
    grassie!

    visto che non mi piace stare con le mani in mano ho trovato un'altra soluzine che "sembra" funzionare:

    codice:
    MovieClip.prototype.myGetNextHighestDepth = function() {
    	var hd = -1;
    	for (var x in this) {
    		if (typeof this[x] == "movieclip") {
    			hd = (this[x].getDepth()>hd) ? this[x].getDepth() : hd;
    		}
    	}
    	return hd+1;
    };
    codice:
    MovieClip.prototype.slowSetProperty = function(prop, newVal, b) {
    	var bb, prevVal;
    	bb = (b == undefined) ? 5 : b;
    	prevVal = this[prop];
    	if(this["slowSPController"+prop]!=undefined){
    	this["slowSPController"+prop].removeMovieClip();
    	}
    	this.createEmptyMovieClip("slowSPController"+prop, this.myGetNextHighestDepth());
    	this["slowSPController"+prop].onEnterFrame = function() {
    		this._parent[prop] += (newVal-this._parent[prop])/bb;
    		if (Math.abs(this._parent[prop]-prevVal)<.01) {
    			this._parent[prop] = newVal;
    			this.removeMovieClip();
    		} else {
    			prevVal = this._parent[prop];
    		}
    	};
    };
    [Il mio sito V2]
    ___________________
    I.m.The.Magic.Man

  4. #4
    Utente di HTML.it L'avatar di negatyve
    Registrato dal
    Feb 2001
    Messaggi
    9,479
    ehehe, due soluzioni al prezzo di una.. :)

  5. #5

    Cosa non si trova in giro ...

    Scusate se tiro UP questo tread, ma è davvero interessantissimo il discorso dei prototype che non girano sull' onEnterFrame ...

    Ovvero, create al momento dell' utilizzo della chiamata, un clip per lavorare sul suo onEnterFrame, ma poi il clip viene eliminato.

    Non sapete che cosa mi avete tolto con la scoperta di questo prototype.
    Davvero diverso lavoro!!


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.