begin process at 2012 05 27 15:48:25
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Flash / Flash MX

 > 

Scripts

 > 

ActionScript

 > 

Prototype de size


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Prototype de size

jeudi 15 novembre 2007 à 12:20:02 | Prototype de size

caviar

    Saluté ...
j'ai un petit problème de prototype pour gérer la taille ...
voici le code que j'ai

//---------------------------------------------------
MovieClip.prototype.size = function(wdth, hght, acc) {
    // loader._visible = 1;
    trace('yo'+this._width);
    w = (wdth-this._width)/acc;
    h = (hght-this._height)/acc;
    if (Math.abs(w)<.1 && Math.abs(h)<.1) {
        delete this.onEnterFrame; //pk ça s'arrete pas ?
    } else {
        this._width += w;
        this._height += h;
       
    }
};
this.onEnterFrame = function() {
    c.size(154.2, 450, 4);
};


bon le truc c'est que la ligne delete this.onEnterFrame; //pk ça s'arrete pas ? ne semble jamais s'exécuter puisque mon trace continue sans cesse...

ensuite j'aimerai bien pouvoir spécifier une seule des deux valeurs wdth ou hght, et que l'autre se calcule proportionnellement par rapport à la taille de départ du clip (et du ration l/h en fait ...)

bref j'ai besoin d'un peu d'aide d'un matheux sur ce coup je crois ...
thxx !
@++
vendredi 16 novembre 2007 à 09:03:28 | Re : Prototype de size

goldenboy68

tu déclares ton "onEnterFrame" à l'extérieur du MovieClip avec "this" et tu veux le supprimer à l'intérieur avec "this" aussi...y'a forcément un problème, le "this" renvoie certainement pas la même chose dans les 2 cas (tu peux vérifier avec un trace(this); . faudra éventuellement jouer avec this._parent ou en désespoir avec _root .

Pour ton problème de redimensionnement :
        ratioImage = cible._width/cible._height;
        if (ratioImage>(limiteImageW/limiteImageH)) {
            cible._width = limiteImageW;
            cible._height = cible._width/ratioImage;
        } else {
            cible._height = limiteImageH;
            cible._width = cible._height*ratioImage;
        }
=> à modifier en fonction de ce que tu veux vraiment.

@+! Samy
vendredi 16 novembre 2007 à 09:29:45 | Re : Prototype de size

caviar

Réponse acceptée !
    hop ... voila un proto pour ceux que ça intéresse

/*****ZOOM TAILLE ******/
function zoomClip(objet, X, Y, speed) {
    trace('zoom');
    if (!zoomClip_array) {
        zoomClip_array = [[], []];
    }
    var found = false;
    for (i=0; i<=zoomClip_array[0].length; i++) {
        if (zoomClip_array[0][i] == objet) {
            found = true;
            if (zoomClip_array[1][i] != objet._zoom) {
                clearInterval(zoomClip_array[1][i]);
                zoomClip_array[1][i] = objet._zoom;
            }
            if ((Math.ceil(objet._width)<(Math.ceil(X-1))) || (Math.ceil(objet._width)>(Math.ceil(X+1)))) {
                objet._width += (X-objet._width)/speed;
            } else {
                objet._width = X;
            }
            if ((Math.ceil(objet._height)<(Math.ceil(Y-1))) || (Math.ceil(objet._height)>(Math.ceil(Y+1)))) {
                objet._height += (Y-objet._height)/speed;
            } else {
                objet._height = Y;
            }
            if ((objet._width == X) && (objet._height == Y)) {
                clearInterval(objet._zoom);
            }
        }
    }
    if (found == false) {
        var long = zoomClip_array[0].length;
        zoomClip_array[0][long] = objet;
        zoomClip_array[1][long] = objet._zoom;
    }
}
MovieClip.prototype.zoom = function(targetX, targetY, speed) {
        //trace(targetY+'   '+this._width+'  scale='+this._xscale);
    //c'est ici qu'on recalcule les proportions si une n'est pas donnée
    tailleOriginX = (this._width/this._xscale)*100;
    tailleOriginY = (this._height/this._yscale)*100;
    ratio = tailleOriginX/tailleOriginY
    //trace ('ratio='+ratio);
    //trace('tailleOriginX ='+tailleOriginX+'tailleOriginY ='+tailleOriginY);
    if (targetX == '') {
        targetX = targetY/ratio;
    }
    if (targetY == '') {
        targetY = targetX/ratio;
    }
    clearInterval(this._zoom);
    this._zoom = setInterval(zoomClip, 40, this, targetX, targetY, speed);
};

peut s'utiliser comme ça

monclip.zoom (400,'',20);
le param vide sera automatiquement calculé au ratio ;)
@+


Cette discussion est classée dans : size, prototype, acc, wdth, hght


Répondre à ce message

Sujets en rapport avec ce message

hittest & prototype [ par mymylanouille ] hello everybody:)wala, j'essai d'construire un p'tit jeu.. mais j'ai 2 gros problemes..déjà les prototypes, j'n'y comprend rien:/utilisation.. et util Arg .....besoin d aide comment faire un zoom en Actionscript??? [ par yoyotris ] Salut tout le monde j aimerai avec le code qui permet de faire un zoom sur un clip ou une image , mais pas avec des masque! Je voudrai en action scrip comment faire un zoom en Action script? [ par yoyotris ] Comment fait on un zoom en Action Script >>>> merci de votre reponse... LiQuIdE IcE hitTest et AS [ par flashman007 ] hugo the best now and foreverVoila j'aimerais savoir si on peut faire fonctionner un hitTest avec des dessins créés en ActionScript et comment?merci a clip en AS [ par flashman007 ] hugo the best now and foreverje me posais cette question: est-il possible de creer un clip en ActionScript afin de le rendre aléatoire ?? decompilateur [ par flashman007 ] voila je voudrais savoir ou trouver un decompilateur de swf gratuit qui n'est NI asv NI ganda-flashmerci a tous , guyshugo the best now and forever decompilateur [ par flashman007 ] je voulais savoir ou trouver (a telecharger :)) un decompilateur de .swf->.fla autre ke asv et ganda-machinmirci hugo the best now and forever</font i composant flash mx [ par flashman007 ] voila j'aimerais modifier (ou créer?) un composant afin d'utiliser le paramètre "perspective".Malheureusement je n'y connais absolument rien aux compo scrollbar [ par flashman007 ] ben voila il m'arrive un truc con : j'arrive ^pas a reduire la taille d'une scrollbar!!Mais comment k'ca se fait????hugo the best now and forever Playlist [ par flashman007 ] je voudrais faire un lecteur en flash qui lit les fichier .m3u (playlist)comment pourrais-je faire???merci a toushugo the best now and forever


Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,889 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales