(PHP 5)
SWFDisplayItem->rotateTo() — Tourne l'objet dans les coordonnées globales
Cette fonction est EXPERIMENTALE . Cela signifie que le comportement de cette fonction, son nom et, concrètement, TOUT ce qui est documenté ici peut changer dans un futur proche, SANS PREAVIS ! Soyez-en conscient, et utilisez cette fonction à vos risques et périls.
swfdisplayitem->rotateto() définit la rotation de l'objet courant à angle degrés dans les coordonnées globales.
L'objet peut être un objet swfshape() , un objet swfbutton() , un objet swftext() ou un objet swfsprite() . Il doit être ajouté avec la fonction swfmovie->add() .
Aucune valeur n'est retournée.
Cet exemple effectue trois rotations de chaînes de caractères depuis l'arrière plan vers le premier plan.
Exemple 1489. Exemple avec swfdisplayitem->rotateto()
<?php
$thetext
=
"ming!"
;
$f
= new
SWFFont
(
"Bauhaus 93.fdb"
);
$m
= new
SWFMovie
();
$m
->
setRate
(
24.0
);
$m
->
setDimension
(
2400
,
1600
);
$m
->
setBackground
(
0xff
,
0xff
,
0xff
);
// des fonctions avec beaucoup d'arguments arbitraires
// sont toujours de bonne idée ! vraiment !
function
text
(
$r
,
$g
,
$b
,
$a
,
$rot
,
$x
,
$y
,
$scale
,
$string
)
{
global
$f
,
$m
;
$t
= new
SWFText
();
$t
->
setFont
(
$f
);
$t
->
setColor
(
$r
,
$g
,
$b
,
$a
);
$t
->
setHeight
(
960
);
$t
->
moveTo
(-(
$f
->
getWidth
(
$string
))/
2
,
$f
->
getAscent
()/
2
);
$t
->
addString
(
$string
);
// nous pouvons ajouter des propriétés comme une variable normal PHP,
// tant que les noms ne sont pas déjà utilisés.
// e.g., nous ne pouvons pas définir $i->scale, parce que c'est une fonction
$i
=
$m
->
add
(
$t
);
$i
->
x
=
$x
;
$i
->
y
=
$y
;
$i
->
rot
=
$rot
;
$i
->
s
=
$scale
;
$i
->
rotateTo
(
$rot
);
$i
->
scale
(
$scale
,
$scale
);
// mais les modifications sont locales à la fonction, donc, nous devons
// retourner l'objet original.
return
$i
;
}
function
step
(
$i
)
{
$oldrot
=
$i
->
rot
;
$i
->
rot
=
19
*
$i
->
rot
/
20
;
$i
->
x
= (
19
*
$i
->
x
+
1200
)/
20
;
$i
->
y
= (
19
*
$i
->
y
+
800
)/
20
;
$i
->
s
= (
19
*
$i
->
s
+
1.0
)/
20
;
$i
->
rotateTo
(
$i
->
rot
);
$i
->
scaleTo
(
$i
->
s
,
$i
->
s
);
$i
->
moveTo
(
$i
->
x
,
$i
->
y
);
return
$i
;
}
$i1
=
text
(
0xff
,
0x33
,
0x33
,
0xff
,
900
,
1200
,
800
,
0.03
,
$thetext
);
$i2
=
text
(
0x00
,
0x33
,
0xff
,
0x7f
, -
560
,
1200
,
800
,
0.04
,
$thetext
);
$i3
=
text
(
0xff
,
0xff
,
0xff
,
0x9f
,
180
,
1200
,
800
,
0.001
,
$thetext
);
for (
$i
=
1
;
$i
<=
100
; ++
$i
) {
$i1
=
step
(
$i1
);
$i2
=
step
(
$i2
);
$i3
=
step
(
$i3
);
$m
->
nextFrame
();
}
header
(
'Content-type: application/x-shockwave-flash'
);
$m
->
output
();
?>
SWFDisplayItem->rotate() |