|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
REDIMENSIONNER ET TOURNER UN CLIP A L'AIDE DES FLECHES
Information sur la source
Description
soit un clip sur la scene que l'on peut deplacer avec la souris. On peut egalement avec les fleches du clavier le faire tourner et le redimensionner.
Source
- import flash.geom.Transform;
- import flash.geom.Matrix;
-
-
- plasrou_mc.onPress = function() {
- this.startDrag(false);
- };
- plasrou_mc.onRelease = function() {
- this.stopDrag();
- };
- var num:Number = new Number();
- var numleft = -5;
- var numright = 5;
- var nume = 1;
- var compta:Number = 0;
- var comptb:Number = 0;
- var comptc:Number = 0;
- var comptd:Number = 0;
-
- var mouseListener:Object = new Object();
- mouseListener.onMouseUp = function():Void {
- if (plasrou_mc.hitTest(_xmouse, _ymouse)) {
-
- var posxrect = plasrou_mc._x;
- var posyrect = plasrou_mc._y;
-
- var keyListener:Object = new Object();
- keyListener.onKeyDown = function() {
- var tourneMatrix:Matrix = new Matrix();
- var translateMatrix:Matrix = new Matrix();
- var neo:Transform = new Transform(plasrou_mc);
- var echelleMatrix:Matrix = new Matrix();
-
- if (Key.isDown(Key.LEFT)) {
- compta = 1;
- if ((compta != comptc) && (compta != comptd)) {
- numleft = numleft-5;
- num = numleft+numright;
- tourneMatrix.rotate(num*Math.PI/180);
- translateMatrix.translate(posxrect,posyrect);
- tourneMatrix.concat(translateMatrix);
- dadaMatrix = tourneMatrix.clone();
- } else {
- numleft = numleft-5;
- num = numleft+numright;
- tourneMatrix.rotate(num*Math.PI/180);
- translateMatrix.translate(posxrect,posyrect);
- tourneMatrix.concat(translateMatrix);
- dadaMatrix = tourneMatrix.clone();
- tourneMatrix.concat(dodoMatrix);
- tourneMatrix.tx = posxrect;
- tourneMatrix.ty = posyrect;
- }
- neo.matrix = tourneMatrix;
-
- } else if (Key.isDown(Key.RIGHT)) {
- comptb = 1;
- if ((comptb != comptc) && (comptb != comptd)) {
- numright = numright+5;
- num = numright+numleft;
- tourneMatrix.rotate(num*Math.PI/180);
- translateMatrix.translate(posxrect,posyrect);
- tourneMatrix.concat(translateMatrix);
- dadaMatrix = tourneMatrix.clone();
- } else {
- numright = numright+5;
- num = numright+numleft;
- tourneMatrix.rotate(num*Math.PI/180);
- translateMatrix.translate(posxrect,posyrect);
- tourneMatrix.concat(translateMatrix);
- dadaMatrix = tourneMatrix.clone();
- tourneMatrix.concat(dodoMatrix);
- tourneMatrix.tx = posxrect;
- tourneMatrix.ty = posyrect;
- }
- neo.matrix = tourneMatrix;
-
- } else if (Key.isDown(Key.UP)) {
- comptc = 1;
- if ((comptc != compta) && (comptc != comptb)) {
- nume = nume+0.1;
- echelleMatrix.scale(nume,nume);
- translateMatrix.translate(posxrect,posyrect);
- echelleMatrix.concat(translateMatrix);
- dodoMatrix = echelleMatrix.clone();
- } else {
- nume = nume+0.1;
- echelleMatrix.scale(nume,nume);
- translateMatrix.translate(posxrect,posyrect);
- echelleMatrix.concat(translateMatrix);
- dodoMatrix = echelleMatrix.clone();
- echelleMatrix.concat(dadaMatrix);
- echelleMatrix.tx = posxrect;
- echelleMatrix.ty = posyrect;
- }
- neo.matrix = echelleMatrix;
-
- } else if (Key.isDown(Key.DOWN)) {
- comptd = 1;
- if ((comptd != compta) && (comptd != comptb)) {
- nume = nume-0.1;
- echelleMatrix.scale(nume,nume);
- translateMatrix.translate(posxrect,posyrect);
- echelleMatrix.concat(translateMatrix);
- dodoMatrix = echelleMatrix.clone();
- } else {
- nume = nume-0.1;
- echelleMatrix.scale(nume,nume);
- translateMatrix.translate(posxrect,posyrect);
- echelleMatrix.concat(translateMatrix);
- dodoMatrix = echelleMatrix.clone();
- echelleMatrix.concat(dadaMatrix);
- echelleMatrix.tx = posxrect;
- echelleMatrix.ty = posyrect;
- }
- neo.matrix = echelleMatrix;
- }
- };
- Key.addListener(keyListener);
- }
- }
- Mouse.addListener(mouseListener);
import flash.geom.Transform;
import flash.geom.Matrix;
plasrou_mc.onPress = function() {
this.startDrag(false);
};
plasrou_mc.onRelease = function() {
this.stopDrag();
};
var num:Number = new Number();
var numleft = -5;
var numright = 5;
var nume = 1;
var compta:Number = 0;
var comptb:Number = 0;
var comptc:Number = 0;
var comptd:Number = 0;
var mouseListener:Object = new Object();
mouseListener.onMouseUp = function():Void {
if (plasrou_mc.hitTest(_xmouse, _ymouse)) {
var posxrect = plasrou_mc._x;
var posyrect = plasrou_mc._y;
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
var tourneMatrix:Matrix = new Matrix();
var translateMatrix:Matrix = new Matrix();
var neo:Transform = new Transform(plasrou_mc);
var echelleMatrix:Matrix = new Matrix();
if (Key.isDown(Key.LEFT)) {
compta = 1;
if ((compta != comptc) && (compta != comptd)) {
numleft = numleft-5;
num = numleft+numright;
tourneMatrix.rotate(num*Math.PI/180);
translateMatrix.translate(posxrect,posyrect);
tourneMatrix.concat(translateMatrix);
dadaMatrix = tourneMatrix.clone();
} else {
numleft = numleft-5;
num = numleft+numright;
tourneMatrix.rotate(num*Math.PI/180);
translateMatrix.translate(posxrect,posyrect);
tourneMatrix.concat(translateMatrix);
dadaMatrix = tourneMatrix.clone();
tourneMatrix.concat(dodoMatrix);
tourneMatrix.tx = posxrect;
tourneMatrix.ty = posyrect;
}
neo.matrix = tourneMatrix;
} else if (Key.isDown(Key.RIGHT)) {
comptb = 1;
if ((comptb != comptc) && (comptb != comptd)) {
numright = numright+5;
num = numright+numleft;
tourneMatrix.rotate(num*Math.PI/180);
translateMatrix.translate(posxrect,posyrect);
tourneMatrix.concat(translateMatrix);
dadaMatrix = tourneMatrix.clone();
} else {
numright = numright+5;
num = numright+numleft;
tourneMatrix.rotate(num*Math.PI/180);
translateMatrix.translate(posxrect,posyrect);
tourneMatrix.concat(translateMatrix);
dadaMatrix = tourneMatrix.clone();
tourneMatrix.concat(dodoMatrix);
tourneMatrix.tx = posxrect;
tourneMatrix.ty = posyrect;
}
neo.matrix = tourneMatrix;
} else if (Key.isDown(Key.UP)) {
comptc = 1;
if ((comptc != compta) && (comptc != comptb)) {
nume = nume+0.1;
echelleMatrix.scale(nume,nume);
translateMatrix.translate(posxrect,posyrect);
echelleMatrix.concat(translateMatrix);
dodoMatrix = echelleMatrix.clone();
} else {
nume = nume+0.1;
echelleMatrix.scale(nume,nume);
translateMatrix.translate(posxrect,posyrect);
echelleMatrix.concat(translateMatrix);
dodoMatrix = echelleMatrix.clone();
echelleMatrix.concat(dadaMatrix);
echelleMatrix.tx = posxrect;
echelleMatrix.ty = posyrect;
}
neo.matrix = echelleMatrix;
} else if (Key.isDown(Key.DOWN)) {
comptd = 1;
if ((comptd != compta) && (comptd != comptb)) {
nume = nume-0.1;
echelleMatrix.scale(nume,nume);
translateMatrix.translate(posxrect,posyrect);
echelleMatrix.concat(translateMatrix);
dodoMatrix = echelleMatrix.clone();
} else {
nume = nume-0.1;
echelleMatrix.scale(nume,nume);
translateMatrix.translate(posxrect,posyrect);
echelleMatrix.concat(translateMatrix);
dodoMatrix = echelleMatrix.clone();
echelleMatrix.concat(dadaMatrix);
echelleMatrix.tx = posxrect;
echelleMatrix.ty = posyrect;
}
neo.matrix = echelleMatrix;
}
};
Key.addListener(keyListener);
}
}
Mouse.addListener(mouseListener);
Conclusion
Si quelqu'un a un code plus compact je suis preneur.
Historique
- 14 mars 2008 11:10:15 :
- faute d'orthographe
- 14 mars 2008 20:49:07 :
- oubie de la dernire ligne du code
- 14 mars 2008 23:42:21 :
- correction code
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
rotation d'un symbole par évènement utilisateur [ par fredd75 ]
Bonjour à tous Je cherche à faire tourner un symbole par on (press)Malheureusement, le symbole ( bien que son point d'ancrage soit centr
rotation (inteligente???) [ par arthur07b ]
bon voila jaimerai fais un cercle avec plusieur icone dessus puis faire que en appuyant sur des bouton corespondant a c icone le cercle tourne jusque&
matrix : comment changer la police d'un effet matrix ? [ par MATEO1200 ]
je voudrais savoir comment est-il possible de modifier la police d'un effet matrix disponible sur le site, en demandant bien évidemment le droit
createTextField et rotation [ par djagger ]
Salut ! Je crées un texte avec createTextField, pas de pb.Par contre quand je fais une rotation sur mon texte, il disparait !? _root.createTextFi
rotation+ et - [ par jultoys ]
Hello,j ai une roue que je fais trourner e, cliquant sur un bouton voici le code:on (press) { _root.onEnterFrame = function() { roue._rotat
rectangle avec coins arrondis [ par on_drag_on ]
Bonsoir!... ou bonjour! (selon). Voilà passer des heures a essayer de faire un prototype d'un rectangle avec coins arrondis. Mais j'ai beau reli
Rotation d'un objet [ par anthony1616 ]
Bonjour, je suis débutant en Flash et je voudrais savoir comment faire pour effectuer une rotation d'un objet sur lui meme mais en faisant des pa
setProperty >> rotation [ par Gizmil ]
Salut, Ma question est relativement simple! Dans une animation, je possède un clip qui remplace le pointeur de ma souris. J'a
Problème animation (rotation) [ par anthony1616 ]
Bonjour,Comment faire pour que une animation se joue en boucle sans intervenir avec les autre animations de la scène?Merci.
Redimensionnement impossible [ par thomas1406 ]
Bonjour,voilà le code de ma page html contenant un swf centré verticalement et horizontalement.Malheureusement, avec ce code, je n'arrive pa
|
Téléchargements
Logiciels à télécharger sur le même thème :
Comparez les prix Nouvelle version

HTC G1
Entre 449€ et 449€
|