Accueil > > > REDIMENSIONNER ET TOURNER UN CLIP A L'AIDE DES FLECHES
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
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 3d et Rotation 3d [ par Orange73 ]
Hello, Je voulais connaitre la difference entre modifier un clip avec matrix3d ou modifier ce clip via les propriete x/y/z et rotationX/Y/Z : 1/ Mat
animation de bouton (balancement) [ par Soa3 ]
Bonjour, je réalise une application en Action Script 2 et je débute; J'ai des boutons que je souhaite faire se balancer mais j'ai deux problèmes : je
Code pour rotation et deplacement avec la souris d'un clip [ par benjone ]
Bonjour, je sais faire ces deux fonctions en AS3(voir sujet), mais comment faire pour les combiner à un clip et que cela fonctionne bien? je veux dire
Page qui se tourne [ par cagoulechonchon ]
Bonjour a vous, je cherche a créer une intro en flash sur mon site. J'aimerais 2 volets qui s'ouvrent. Non pas comme les portes rigides d'un saloon m
Texte en rotation 360° Y [ par muana ]
[^^happy13]Bonjour à tous! Je viens de commencer avec flash, j'utilise la version CS3 (Adobe Design Premium). Lors de mes récentes recherches, suis to
Problème redimensionnement image apres chargement externe [ par matthmuc72 ]
Bonsoir!! Voici mon soucis: j'aimerais pouvoir redimensionner mon image après l'avoir chargé mais il ne se passe rien lorsque je fais ceci: [code=a
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
|
Derniers Blogs
COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE?COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE? par Matthieu MEZIL
Avec EF, les vues doivent être mappées sur des entity types. Le problème c'est que les entity types doivent avoir une clé. Avec EF, nous avons les complex type qui n'ont pas de clé mais les vues ne peuvent pas être mappées dessus. Avec EF4, il est possibl...
Cliquez pour lire la suite de l'article par Matthieu MEZIL [WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL?[WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL? par JeremyJeanson
Certain d'entre vous on peut être vécu cette situation embarrassante après quelques temps passer avec WF4 : Au début avec mon " ActivityDesigner" , tout allait bien. Et puis un jour j'ai au des problèmes de " Binding" . Alors nous sommes allé sur le site ...
Cliquez pour lire la suite de l'article par JeremyJeanson MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ?MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ? par junarnoalg
La prochaine session de MyTIC aura lieu à Namur, le 23 mars prochain. Pendant presque une heure, nous parlerons de SharePoint 2010. Voici un aperçu du programme.
Accueil : 17h30 Début de la session : 18h00 - Les nouvelles int...
Cliquez pour lire la suite de l'article par junarnoalg
Forum
RE : PROBLEME RE : PROBLEME par yoplaboum69
Cliquez pour lire la suite par yoplaboum69
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|