Tout ce qui concerne le logiciel E-anim |
| | |
Auteur | Message |
---|
Invité Invité
| Sujet: Fudge - AS2 framework Jeu 05 Nov 2009, 02:34 | |
| Bonjour bonjour, Je suis très heureux aujourd'hui d'annoncer un autre projet. Fudge. Fudge regroupe tout des frameworks dans tout sortes de langages. Tout ce qui peut aider quelqu'un et à faire des taches plus rapidement. Donc, la partie qui devrais vous intéresser, c'est la partie que j'ai commencé. Un framework en actionscript 2. Sa consiste en un selecteur de movieclips. Il peut être parfois long de répéter plein de fois les root et les intructions presque indentique plusieurs fois. Donc, ce que je propose, c'est de remplacer, par exemple, ça: - Code:
-
_root.rond0._x = 0; _root.rond1._x = 50; _root.rond2._x = 25; _root.rond3._x = 78; _root.rond4._x = 102;
par ça - Code:
-
F("rond0,rond1,rond2,rond3,rond4").x("0,50,25,78,102");
ou même par ça (vu que c'est une suite de movieclip) - Code:
-
F("rond[0-4]").x("0,50,25,78,102");
Je finalise et je vous donne le script au cours de la semaine . |
| | | Beldjilali Programmeur
Nombre de messages : 3016 Date d'inscription : 24/06/2007
| | | | Invité Invité
| Sujet: Re: Fudge - AS2 framework Dim 08 Nov 2009, 22:33 | |
| Je suis face à un probleme qui me frustre totalement et dont je ne comprend rien .. Regardez.. - Code:
-
var Fudge = function(s){ var sp = s.split(","); var spt = s.split(";"); var clipsNames = new Array(); if(sp.length==1&&spt.length==1){ clipsNames = sp; }else{ for(var i=0; i<sp.length; i++){ var scut = sp[i].split("["); if(scut.length==1){ clipsNames.push(sp[i]); }else{ var ns = scut[1].slice(0, scut[1].length-1); var n = ns.split(";"); for(var j=0; j<n.length; j++){ clipsNames.push(scut[0]+n[j]+""); } } } } this.clipsNames = clipsNames; return clipsNames;
}; Fudge.prototype.hey = function(){ // Fonction juste pour tester. return this.clipsNames+" HEYHEY"; };
var F = function(s){ return new Fudge(s); };
var B = new Fudge("clip[1;8;2;5]"); _root.m_text = B.hey();//Tout va bien et tout marche bien .. Mais ce n'est pas la syntaxe que je veux...
var A = F("clip[1;8;2;5]"); _root.m_text = A.hey();//SA RENVOIE UNDEFINED ..RRRRRRRRR [BAVE SUR LE COIN DE LA BOUCHE] .. Mais la syntaxe est bonne Je suis TOTALEMENT désespéré par toute la rage que me cause ce problème .. Avez-vous une idée qui pourrait m'aider ? Car la variable A et la variable B sont supposé être identique .. |
| | | the virus Co-administrateur
Nombre de messages : 3475 Age : 31 Date d'inscription : 31/12/2005
| | | | Invité Invité
| Sujet: Re: Fudge - AS2 framework Mar 10 Nov 2009, 00:06 | |
| - the virus a écrit:
- enléve les new je pence
Je peut pas enlever les new si je veux utiliser les prototype.. Mais pourtant .. A = new Fudge .. B = F qui retourne new Fudge .. donc B = new Fudge Ya rien a comprendre .. |
| | | the virus Co-administrateur
Nombre de messages : 3475 Age : 31 Date d'inscription : 31/12/2005
| | | | Invité Invité
| | | | the virus Co-administrateur
Nombre de messages : 3475 Age : 31 Date d'inscription : 31/12/2005
| | | | Invité Invité
| | | | the virus Co-administrateur
Nombre de messages : 3475 Age : 31 Date d'inscription : 31/12/2005
| | | | Invité Invité
| | | | Invité Invité
| Sujet: Re: Fudge - AS2 framework Ven 27 Nov 2009, 18:36 | |
| Bon bon bon, j'ai réussi à réglé tout mes problèmes et VOILA .. Tout fonctione. Pour l'instant, il y a seulement des fonctions assé basique mais tout devrais se complexifié .. Voici ce qu'on peut faire en gros: - Selection de movieclip simple et rapide: F("mc[1;2;3]") = _root.mc1, _root.mc2 et _root.mc3
- Possibilité de filtré la seletion: ajouté des movieclips, enlevé les movieclips qui n'existe pas, etc.
- Gestion de tout les attributs des movieclips: _x, _y, _alpha, etc.
- Gestion de tout les événement : F("mc1").e("onPress",function(){//...})
- Possibilité d'animation avec les equations d'easing de Robert Penner
- Quelques fonctions mathématique sont incluses
Voilà le code pour l'instant: - Spoiler:
- Code:
-
var Fudge = { sa:[],size:function(){return this.sa.length;},init:function(s,r){ if(typeof(s)=="movieclip"){ this.sa = [s._name]; return this; }else{ var sp = s.split(","); var spt = s.split(";"); var clipsNames = new Array(); if(sp.length==1&&spt.length==1){ clipsNames = sp; }else{ for(var i=0; i<sp.length; i++){ var scut = sp[i].split("["); if(scut.length==1){ clipsNames.push(sp[i]); }else{ var ns = scut[1].slice(0, scut[1].length-1); var n = ns.split(";"); for(var j=0; j<n.length; j++){ clipsNames.push(scut[0]+n[j]+""); } } } } if(r==true||r==null){ this.s = clipsNames.toString(); this.sa = clipsNames; return this; }else{ return clipsNames; } } },
//Base Functions each:function(callback){ for(var i=0; i<this.sa.length; i++){ callback.call(this.sa[i]); } }, //Easing Functions easing:{ easeInQuad: function (t, b, c, d) { return c*(t/=d)*t + b; }, easeOutQuad: function (t, b, c, d) { return -c *(t/=d)*(t-2) + b; },easeInOutQuad: function (t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t + b; return -c/2 * ((--t)*(t-2) - 1) + b; }, easeInCubic: function (t, b, c, d) { return c*(t/=d)*t*t + b; }, easeOutCubic: function (t, b, c, d) { return c*((t=t/d-1)*t*t + 1) + b; }, easeInOutCubic: function (t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t + b; return c/2*((t-=2)*t*t + 2) + b; }, easeInQuart: function (t, b, c, d) { return c*(t/=d)*t*t*t + b; },easeOutQuart: function (t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b; }, easeInOutQuart: function (t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t*t + b; return -c/2 * ((t-=2)*t*t*t - 2) + b; }, easeInQuint: function (t, b, c, d) { return c*(t/=d)*t*t*t*t + b; }, easeOutQuint: function (t, b, c, d) { return c*((t=t/d-1)*t*t*t*t + 1) + b; }, easeInOutQuint: function (t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; return c/2*((t-=2)*t*t*t*t + 2) + b; }, easeInSine: function (t, b, c, d) { return -c * Math.cos(t/d * (Math.PI/2)) + c + b; }, easeOutSine: function (t, b, c, d) { return c * Math.sin(t/d * (Math.PI/2)) + b; }, easeInOutSine: function (t, b, c, d) { return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; }, easeInExpo: function (t, b, c, d) { return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; }, easeOutExpo: function (t, b, c, d) { return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; }, easeInOutExpo: function (t, b, c, d) { if (t==0) return b; if (t==d) return b+c; if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; }, easeInCirc: function (t, b, c, d) { return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; }, easeOutCirc: function (t, b, c, d) { return c * Math.sqrt(1 - (t=t/d-1)*t) + b; }, easeInOutCirc: function (t, b, c, d) { if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; },easeInBack: function (t, b, c, d, s) { if (s == undefined) s = 1.70158; return c*(t/=d)*t*((s+1)*t - s) + b; }, easeOutBack: function (t, b, c, d, s) { if (s == undefined) s = 1.70158; return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; }, easeInOutBack: function (t, b, c, d, s) { if (s == undefined) s = 1.70158; if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; },easeInBounce: function (t, b, c, d) { return c - this.easeOutBounce (d-t, 0, c, d) + b; }, easeOutBounce: function (t, b, c, d) { if ((t/=d) < (1/2.75)) { return c*(7.5625*t*t) + b; } else if (t < (2/2.75)) { return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; } else if (t < (2.5/2.75)) { return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; } else { return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; } }, easeInOutBounce: function (t, b, c, d) { if (t < d/2) return this.easeInBounce (t*2, 0, c, d) * .5 + b; return this.easeOutBounce (t*2-d, 0, c, d) * .5 + c*.5 + b; },linear:function(t,b,c,d){ return c*t/d+b; }
}, //Filtering Functions odd: function(){ var n = []; for(var i=1; i<this.sa.length; i+=2){ n.push(this.sa[i]); } this.sa = n; return this; },even: function(){ var n = []; for(var i=0; i<this.sa.length; i+=2){ n.push(this.sa[i]); } this.sa = n; return this; },add: function(s){ var c = this.init(s,false); for(var i=0; i<c.length; i++){ this.sa.push(c[i]); } return this; },test: function(){ var n = []; for(var i=0; i<this.sa.length; i++){ if(_root[this.sa[i]]){ n.push(this.sa[i]); } } this.sa = n; return this; }, //Animation Function animInit:function(obj,prop,v,d,ease,callback){ var time = 0; var duration = d; var begin = obj[prop]; var end = v; var change = end-begin; var num:Number; var easing = this.easing; var t = this; num = setInterval(function(){ obj[prop] = easing[ease](time,begin,change,duration)||easing.easeInOutQuad(time,begin,change,duration); if(time>=duration){ clearInterval(num); callback.call(t.sa.toString()); } time++; },10); },anim:function(prop,v,duration,ease,callback){ for(var i=0; i<this.sa.length; i++){ this.animInit(_root[this.sa[i]],prop,v,duration,ease,callback); } return this; },
//Property Functions p:function(key,value){ //F("gr[1;2;3;4]").p("_x",[10,26,10,26]); if(value){ if(typeof(value)=="array"){ for(var i=0; i<this.sa.length; i++){ _root[this.sa[i]][key] = value[i]; } }else{ for(var i=0; i<this.sa.length; i++){ _root[this.sa[i]][key] = value; } } return this; }else{ var n = []; for(var i=0; i<this.sa.length; i++){ n.push(_root[this.sa[i]][key]); } return n; } },x:function(value){ return this.p("_x",value); },y:function(value){ return this.p("_y",value); },width:function(value){ return this.p("_width",value); },height:function(value){ return this.p("_height",value); },alpha:function(value){ return this.p("_alpha",value); },rotation:function(value){ return this.p("_rotation",value); },text:function(value){ return this.p("text",value); },xscale:function(value){ return this.p("_xscale",value); },yscale:function(value){ return this.p("_yscale",value); },
//Event Functions e: function(w,callback){ for(var i=0; i<this.sa.length; i++){ _root[this.sa[i]][w] = callback; } return this; },rollover: function(cn,co){ for(var i=0; i<this.sa.length; i++){ _root[this.sa[i]]["onRollOut"] = cn; _root[this.sa[i]]["onRollOver"] = co; _root[this.sa[i]]["onRelease"] = co; } return this; },math:{ isOdd:function(n){ return (n%2); },isOdd:function(n){ return (n%2==0); },distance:function(x1,y1,x2,y2){ return Math.sqrt(Math.pow((x2-x1),2) + Math.pow((y2-y1),2)); } } }; var F = function(s){ return Fudge.init(s); }; for(var fn in Fudge){ F[fn] = Fudge[fn]; }
Ou la version sans commentaires et retour à la ligne - Spoiler:
- Code:
-
var Fudge={sa:[],size:function(){return this.sa.length;},init:function(s,r){if(typeof(s)=="movieclip"){this.sa=[s._name];return this;}else{var sp=s.split(",");var spt=s.split(";");var clipsNames=new Array();if(sp.length==1&&spt.length==1){clipsNames=sp;}else{for(var i=0;i<sp.length;i++){var scut=sp[i].split("[");if(scut.length==1){clipsNames.push(sp[i]);}else{var ns=scut[1].slice(0,scut[1].length-1);var n=ns.split(";");for(var j=0;j<n.length;j++){clipsNames.push(scut[0]+n[j]+"");}}}}if(r==true||r==null){this.s=clipsNames.toString();this.sa=clipsNames;return this;}else{return clipsNames;}}},each:function(callback){for(var i=0;i<this.sa.length;i++){callback.call(this.sa[i]);}},easing:{easeInQuad:function(t,b,c,d){return c*(t/=d)*t+b;},easeOutQuad:function(t,b,c,d){return-c*(t/=d)*(t-2)+b;},easeInOutQuad:function(t,b,c,d){if((t/=d/2)<1)return c/2*t*t+b;return-c/2*((--t)*(t-2)-1)+b;},easeInCubic:function(t,b,c,d){return c*(t/=d)*t*t+b;},easeOutCubic:function(t,b,c,d){return c*((t=t/d-1)*t*t+1)+b;},easeInOutCubic:function(t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t+b;return c/2*((t-=2)*t*t+2)+b;},easeInQuart:function(t,b,c,d){return c*(t/=d)*t*t*t+b;},easeOutQuart:function(t,b,c,d){return-c*((t=t/d-1)*t*t*t-1)+b;},easeInOutQuart:function(t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t+b;return-c/2*((t-=2)*t*t*t-2)+b;},easeInQuint:function(t,b,c,d){return c*(t/=d)*t*t*t*t+b;},easeOutQuint:function(t,b,c,d){return c*((t=t/d-1)*t*t*t*t+1)+b;},easeInOutQuint:function(t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t*t+b;return c/2*((t-=2)*t*t*t*t+2)+b;},easeInSine:function(t,b,c,d){return-c*Math.cos(t/d*(Math.PI/2))+c+b;},easeOutSine:function(t,b,c,d){return c*Math.sin(t/d*(Math.PI/2))+b;},easeInOutSine:function(t,b,c,d){return-c/2*(Math.cos(Math.PI*t/d)-1)+b;},easeInExpo:function(t,b,c,d){return(t==0)?b:c*Math.pow(2,10*(t/d-1))+b;},easeOutExpo:function(t,b,c,d){return(t==d)?b+c:c*(-Math.pow(2,-10*t/d)+1)+b;},easeInOutExpo:function(t,b,c,d){if(t==0)return b;if(t==d)return b+c;if((t/=d/2)<1)return c/2*Math.pow(2,10*(t-1))+b;return c/2*(-Math.pow(2,-10*--t)+2)+b;},easeInCirc:function(t,b,c,d){return-c*(Math.sqrt(1-(t/=d)*t)-1)+b;},easeOutCirc:function(t,b,c,d){return c*Math.sqrt(1-(t=t/d-1)*t)+b;},easeInOutCirc:function(t,b,c,d){if((t/=d/2)<1)return-c/2*(Math.sqrt(1-t*t)-1)+b;return c/2*(Math.sqrt(1-(t-=2)*t)+1)+b;},easeInBack:function(t,b,c,d,s){if(s==undefined)s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b;},easeOutBack:function(t,b,c,d,s){if(s==undefined)s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b;},easeInOutBack:function(t,b,c,d,s){if(s==undefined)s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b;},easeInBounce:function(t,b,c,d){return c-this.easeOutBounce(d-t,0,c,d)+b;},easeOutBounce:function(t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b;}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b;}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b;}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b;}},easeInOutBounce:function(t,b,c,d){if(t<d/2)return this.easeInBounce(t*2,0,c,d)*.5+b;return this.easeOutBounce(t*2-d,0,c,d)*.5+c*.5+b;},linear:function(t,b,c,d){return c*t/d+b;}},odd:function(){var n=[];for(var i=1;i<this.sa.length;i+=2){n.push(this.sa[i]);}this.sa=n;return this;},even:function(){var n=[];for(var i=0;i<this.sa.length;i+=2){n.push(this.sa[i]);}this.sa=n;return this;},add:function(s){var c=this.init(s,false);for(var i=0;i<c.length;i++){this.sa.push(c[i]);}return this;},test:function(){var n=[];for(var i=0;i<this.sa.length;i++){if(_root[this.sa[i]]){n.push(this.sa[i]);}}this.sa=n;return this;},animInit:function(obj,prop,v,d,ease,callback){var time=0;var duration=d;var begin=obj[prop];var end=v;var change=end-begin;var num:Number;var easing=this.easing;var t=this;num=setInterval(function(){obj[prop]=easing[ease](time,begin,change,duration)||easing.easeInOutQuad(time,begin,change,duration);if(time>=duration){clearInterval(num);callback.call(t.sa.toString());}time++;},10);},anim:function(prop,v,duration,ease,callback){for(var i=0;i<this.sa.length;i++){this.animInit(_root[this.sa[i]],prop,v,duration,ease,callback);}return this;},p:function(key,value){if(value){if(typeof(value)=="array"){for(var i=0;i<this.sa.length;i++){_root[this.sa[i]][key]=value[i];}}else{for(var i=0;i<this.sa.length;i++){_root[this.sa[i]][key]=value;}}return this;}else{var n=[];for(var i=0;i<this.sa.length;i++){n.push(_root[this.sa[i]][key]);}return n;}},x:function(value){return this.p("_x",value);},y:function(value){return this.p("_y",value);},width:function(value){return this.p("_width",value);},height:function(value){return this.p("_height",value);},alpha:function(value){return this.p("_alpha",value);},rotation:function(value){return this.p("_rotation",value);},text:function(value){return this.p("text",value);},xscale:function(value){return this.p("_xscale",value);},yscale:function(value){return this.p("_yscale",value);},e:function(w,callback){for(var i=0;i<this.sa.length;i++){_root[this.sa[i]][w]=callback;}return this;},rollover:function(cn,co){for(var i=0;i<this.sa.length;i++){_root[this.sa[i]]["onRollOut"]=cn;_root[this.sa[i]]["onRollOver"]=co;_root[this.sa[i]]["onRelease"]=co;}return this;},math:{isOdd:function(n){return(n%2);},isOdd:function(n){return(n%2==0);},distance:function(x1,y1,x2,y2){return Math.sqrt(Math.pow((x2-x1),2)+Math.pow((y2-y1),2));}}};var F=function(s){return Fudge.init(s);};for(var fn in Fudge){F[fn]=Fudge[fn];}
|
| | | Invité Invité
| Sujet: Re: Fudge - AS2 framework Ven 27 Nov 2009, 18:46 | |
| On on l'utilise de cette manière: - Code:
-
F("mc2").x(40); //est égale à _root.mc2._x = 40; - Code:
-
F("mc[1;2;3]").x(40); //est égale à _root.mc1._x = 40; _root.mc2._x = 40; _root.mc3._x = 40;
- Code:
-
F("mc[1;2]").x([30,40]).y(10); //est égale à _root.mc1._x = 30; _root.mc2._x = 40; _root.mc1._y = 10; _root.mc2._y = 10;
- Code:
-
//Les animations s'utilise comme sa: F("mc1").anim("_x",50,20,"easeOutBounce",function(){//animation terminé!}); // (prop,value,durée,easing,callback) //L'easing par défault est easeInOutQuad
- Code:
-
//Les événements F("mc1,groupe2").e("onPress",function(){ this; //this = le movieclip actuelle F(this).x(0); });
|
| | | bonhomme Programmeur
Nombre de messages : 1147 Age : 28 Localisation : Belgique Date d'inscription : 24/09/2009
| | | | chris_c Accro
Nombre de messages : 8403 Age : 53 Date d'inscription : 18/11/2007
| | | | Contenu sponsorisé
| | | | |
| Permission de ce forum: | Vous ne pouvez pas répondre aux sujets dans ce forum
| |
| |
| |
|