Perspective dynamique
Film 640
480
Couleur fond #000066
Vitesse 35
Mettre 2 curseurs en place
hslider1 et hslider2
Aller sur scène_1 et cliquer sur l'outil rectangle
mettre 1 petit rectangle en haut
le nommer « hslider1 »
cliquer sur transforme et mettre ses dimensions
cliquer sur forme et mettre
ligne 0 couleur rose
remplissage plein
cible coche
faire la même chose avec « hslider 2 »
en changeant x = 630
y = 10
se mettre sur scène_1 et cliquer sur l'outil texte
et mettre « gradient aléatoire »
nommer le gradient
texte statique
cible coché
dans transforme mettre ceci
se mettre sur scène_1
outil ellipse
mettre un petit cercle vert à gauche de gradient aléatoire
et nommer le « dotG »
cible coché
ligne aucune
aller dans transforme et mettre ceci
vous devez avoir ceci
au meme endroit que le cercle vert mettre un cercle identique
mais de couleurs rouge nommer le « dotR »
vous avez ceci
se mettre sur scène_1 et cliquer sur l'outil texte
à droite de gradient aléatoire écrire « filaire »
et nommer le « filaire »
>
voilà où nous en sommes
partie 2 :scripts
cliquer sur scène_1 et script expert
et mettre ce script
onLoad()
{ // limites de déplacement
limX1 = 10; limX2 = 630;
// initialise les angles
teta1 = 15; teta2 = 30; teta3 = 45;
tetap1 = teta1; tetap2 = teta2; tetap3 = teta3;
// initialise les 2 pts de fuite
xF1 = limX1; yF1 = 10;
xF2 = limX2; yF2 = 10;
// initialise les coordonnées
x1 = x2 = x3 = x4 = x5 = x6 = x7 = x8 = 0;
y1 = y2 = y3 = y4 = y5 = y6 = y7 = y8 = 0;
// couleurs
lavender = 0xE6E6FA;
rouge = 0xFF0000;
gold = 0xFFCC00;
cyan = 0x00FFFF;
lightsteelblue = 0xB0C4DE;
mediumslateblue = 0x7B68EE;
paleturquoise = 0xAFEEEE;
colors = [lavender , paleturquoise ,mediumslateblue , lightsteelblue ];
alphas = [50, 50, 50, 50];
// point rouge visible, point vert caché
dotR._visible = true;
filaire._visible = false;
// on l'appelle cube
createEmptyMovieClip("cube", 0 );
gradient = false; // pas de gradient de couleurs
draw(); // tracé filaire
}
onEnterFrame()
{
cube.clear(); // efface le précédent tracé
draw();
}
// pour equation de droite
function y( x , xf, yf, teta )
{
return ( yf + ( x-xf)*Math.tandeg(teta) );
}
// calcule abscisse x intersection de 2 droites
// ang2 est < 0 car calculé à partir de F2
// et je ne veux utiliser qu'une seule fonction
function x_inter( ang1 , ang2 )
{
return ( (yF2-yF1 + xF1*Math.tandeg(ang1) - xF2*Math.tandeg(ang2) ) / ( Math.tandeg(ang1) - Math.tandeg
(ang2) ) );
}
// calcule les points
function getPoints()
{
//----- pt1 -----------------
x1 = x_inter( teta2 , -tetap1 );
y1 = y( x1 , xF1, yF1, teta2 );
//---- pt2 ------------------
x2 = x_inter( teta1 , -tetap1 );
y2 = y( x2 , xF1, yF1, teta1 );
//---- pt3 ------------------
x3 = x_inter( teta1 , -tetap2 );
y3 = y( x3 , xF1, yF1, teta1 );
//---- pt4 ------------------
x4 = x_inter( teta2 , -tetap2 );
y4 = y( x4 , xF1, yF1, teta2 );
//---- pt5 ------------------
x5 = x1;
y5 = y( x5 , xF1, yF1, teta3 );
//---- pt6 ------------------
x6 = x2;
// calcul de l'angle pt5xF2 / horizontale
dx = xF2 - x5;
if (dx==0) tetap4 = 90;
else tetap4 = atan2deg( y5 - yF2 , dx );
y6 = y( x6 , xF2, yF2, -tetap4 );
//---- pt7 ------------------
x7 = x3;
// calcul de l'angle pt6xF1 / horizontale
dx = x6 - xF1;
if (dx==0) teta4 = 90;
else teta4 = atan2deg( y6 - yF1 , dx );
y7 = y( x7 , xF1, yF1, teta4 );
//---- pt8 ------------------
x8 = x4;
y8 = y( x8 , xF1, yF1, teta3 );
}
// fonction de tracé
function draw( )
{
getPoints();
if (gradient) // gradient demandé, so let's get it !
{ // le tracé a été fait en conséquence
ratios = [5, 100, 150, 5];
matrix = {matrixType:"box", x:x3, y:y4, w:x3-x1, h:y4-y2, r:30*Math.random(3)};
cube.beginGradientFill("linear", colors, alphas, ratios, matrix);
}
cube.lineStyle(1, _root.gold, 100 );
cube.moveTo( x1 , y1 );
cube.lineTo( x2 , y2 );
cube.lineTo( x3 , y3 );
cube.lineTo( x4 , y4 );
cube.lineTo( x1 , y1 );
if (gradient)
{
cube.endFill();
matrix = {matrixType:"box", x:x8, y:y8, w:x8-x5, h:y8-y1, r:0};
cube.beginGradientFill("linear", colors, alphas, ratios, matrix);
}
cube.lineTo( x5 , y5 );
cube.lineTo( x8 , y8 );
cube.lineTo( x4 , y4 );
cube.lineTo( x1 , y1 );
if (gradient)
{
cube.endFill();
matrix = {matrixType:"box", x:x8, y:y8, w:x7-x8, h:y8-y3, r:180};
ratios = [5, 10, 150, 5];
cube.beginGradientFill("linear", colors, alphas, ratios, matrix);
}
cube.moveTo( x4 , y4 );
cube.lineTo( x8 , y8 );
cube.lineTo( x7 , y7 );
cube.lineTo( x3 , y3 );
cube.lineTo( x4 , y4 );
if (gradient) cube.endFill();
cube.lineStyle(1, _root.gold, 50 ); // traits cachés en alpha 50%
cube.moveTo( x5 , y5 );
cube.lineTo( x6 , y6 );
cube.lineTo( x7 , y7 );
cube.moveTo( x2 , y2 );
cube.lineTo( x6 , y6 );
}
// zut ! un point de fuite a été déplacé
// il faut recalculer les angles
function recalcule_angle( xfixe , yfixe, xxF , eps)
{
dx = xfixe - xxF;
if (dx==0) return 90; // on se prémunit de la division par 0 !
else return eps*atan2deg( yfixe - yF1 , dx );
}
cliquer sur « texte gradient » et mettre ce code dans script expert
on (press)
{
_root.gradient = true;
_root.dotR._visible = false; // cache le rouge
_root.filaire._visible = true; // filaire est visible
}
Cliquer sur « hslider1 « et mettre ceci dans script expert
onLoad ()
{
// définit la zone de déplacement de F1
left1 = _root.limX1;
top1 = _root.yF1;
right1 = (_root._width / 2) - 10;
bottom1 = top1;
// position de départ de F1
this._X = left1;
this._Y = top1;
}
onSelfEvent(press) { this.startDragLocked(left1, right1, top1, bottom1); }
onEnterFrame()
{
//_root.txtdyn1 = this._X add " " add this._Y;
_root.xF1 = this._X;
// si F1 est déplacé on prend 3 4 7 8 comme pts fixes
// on recalcule les angles teta1, 2, 3, 4
_root.teta1 = _root.recalcule_angle( _root.x3 , _root.y3, _root.xF1 , 1 );
_root.teta2 = _root.recalcule_angle( _root.x4 , _root.y4, _root.xF1 , 1 );
_root.teta3 = _root.recalcule_angle( _root.x8 , _root.y8, _root.xF1 , 1 );
_root.teta4 = _root.recalcule_angle( _root.x7 , _root.y7, _root.xF1 , 1 );
}
onSelfEvent (release) { this.stopDrag(); }
Cliquer sur « hslider2 « et mettre ceci dans script expert
onLoad ()
{ // définit la zone de déplacement de F2
left2 = (_root._width / 2) + 10;
top2 = _root.yF2;
right2 = _root.limX2;
bottom2 = top2;
// position de départ de F2
this._X = right2;
this._Y = top2;
}
onSelfEvent(press) { this.startDragLocked(left2, right2, top2, bottom2); }
onEnterFrame()
{
_root.xF2 = this._X;
//_root.txtdyn2 = this._X add " " add this._Y;
// si F2 est déplacé on prend 1 4 5 8 comme pts fixes
// on recalcule les angles tetap1, 2, 3, 4
_root.tetap1 = _root.recalcule_angle( _root.x1 , _root.y1, _root.xF2 , -1 );
_root.tetap2 = _root.recalcule_angle( _root.x4 , _root.y4, _root.xF2 , -1 );
_root.tetap3 = _root.recalcule_angle( _root.x8 , _root.y8, _root.xF2 , -1 );
_root.tetap4 = _root.recalcule_angle( _root.x5 , _root.y5, _root.xF2 , -1 );
}
onSelfEvent (release) { this.stopDrag(); }
et voilà, cliquer sur les carrés roses et faites les bouger
0/10 sur 0 vote
Sélectionnez une note dans le menu déroulant.Aucun commentaire
Créer un site internet gratuit avec E-monsite.com
- Signaler un contenu illicite
- Voir d'autres sites dans la catégorie Webmaster
Comment créer un site - Création de site Amiens -
Videos Droles
- Clips musique
- Cours création de site web