Flex - Effet Rotate3D

introduction

La classe Rotate3D fait pivoter un objet cible en trois dimensions autour des axes x, y ou z. La rotation se produit autour du centre de transformation de la cible.

Déclaration de classe

Voici la déclaration pour spark.effects.Rotate3D classe -

public class Rotate3D
   extends AnimateTransform3D

Propriétés publiques

Sr.Non Propriété et description
1

angleXFrom : Number

L'angle de départ de rotation de l'objet cible autour de l'axe x, exprimé en degrés.

2

angleXTo : Number

Angle de rotation final de l'objet cible autour de l'axe x, exprimé en degrés.

3

angleYFrom : Number

Angle de départ de rotation de l'objet cible autour de l'axe y, exprimé en degrés.

4

angleYTo : Number

Angle final de rotation de l'objet cible autour de l'axe y, exprimé en degrés.

5

angleZFrom : Number

Angle de départ de rotation de l'objet cible autour de l'axe z, exprimé en degrés.

6

angleZTo : Number

Angle final de rotation de l'objet cible autour de l'axe z, exprimé en degrés.

Méthodes publiques

Sr.Non Méthode et description
1

Rotate3D(target:Object = null)

Constructeur.

Méthodes héritées

Cette classe hérite des méthodes des classes suivantes -

  • spark.effects.AnimateTransform3D
  • spark.effects.AnimateTransform
  • spark.effects.Animate
  • mx.effects.Effect
  • flash.events.EventDispatcher
  • Object

Exemple d'effet Flex Rotate3D

Suivons les étapes suivantes pour vérifier l'utilisation de Rotate3D Effect dans une application Flex en créant une application de test -

Étape La description
1 Créez un projet avec un nom HelloWorld sous un package com.tutorialspoint.client comme expliqué dans le chapitre Flex - Créer une application .
2 Modifiez HelloWorld.mxml comme expliqué ci-dessous. Gardez le reste des fichiers inchangé.
3 Compilez et exécutez l'application pour vous assurer que la logique métier fonctionne conformément aux exigences.

Voici le contenu du fichier mxml modifié src/com.tutorialspoint/HelloWorld.mxml.

<?xml version = "1.0" encoding = "utf-8"?>
<s:Application xmlns:fx = "http://ns.adobe.com/mxml/2009"
   xmlns:s = "library://ns.adobe.com/flex/spark"
   xmlns:mx = "library://ns.adobe.com/flex/mx
   width = "100%" height = "100%" minWidth = "500" minHeight = "500">
   
   <fx:Style source = "/com/tutorialspoint/client/Style.css" />
   <fx:Script>
      <![CDATA[
         private function applyRotateProperties():void {
            rotateEffect.play();
         }
      ]]>
   </fx:Script>

   <fx:Declarations>
      <s:Rotate3D id = "rotateEffect" target = "{imageFlex}"
         angleXFrom = "0.0" angleXTo = "{Number(rotateX.text)}"
         angleYFrom = "0.0" angleYTo = "{Number(rotateY.text)}"
         angleZFrom = "0.0" angleZTo = "{Number(rotateZ.text)}"
         />
   </fx:Declarations>

   <s:BorderContainer width = "630" height = "480" id = "mainContainer"
      styleName = "container">
      <s:VGroup width = "100%" height = "100%" gap = "50"
         horizontalAlign = "center" verticalAlign = "middle">
         <s:Label id = "lblHeader" text = "Effects Demonstration"
            fontSize = "40" color = "0x777777" styleName = "heading" />
            
         <s:Panel id = "rotate3DPanel" title = "Using Rotate3D Effect"
            width = "500" height = "300">
            <s:layout>
               <s:HorizontalLayout  gap = "10" verticalAlign = "middle"
                  horizontalAlign = "center" />
            </s:layout>
               
            <s:VGroup top = "10" left = "15">
               <s:HGroup verticalAlign = "middle">
                  <s:Label text = "Rotate By X:" width = "70" />
                  <s:TextInput id = "rotateX" text = "45.0" width = "50" />
               </s:HGroup>

               <s:HGroup verticalAlign = "middle">
                  <s:Label text = "Rotate By Y:" width = "70" />
                  <s:TextInput id = "rotateY" text = "15.0" width = "50" />
               </s:HGroup>
                  
               <s:HGroup verticalAlign = "middle">
                  <s:Label text = "Rotate By Z:" width = "70" />
                  <s:TextInput id = "rotateZ" text = "15.0" width = "50" />
               </s:HGroup>

               <s:Button label = "Apply Properties"
                  click = "applyRotateProperties()" />
            </s:VGroup>

            <s:Image id = "imageFlex"
               source = "http://www.tutorialspoint.com/images/flex-mini.png"
               height = "200" width = "200" />
         </s:Panel>
      </s:VGroup>
   </s:BorderContainer>
</s:Application>

Une fois que vous êtes prêt avec tous les changements effectués, laissez-nous compiler et exécuter l'application en mode normal comme nous l'avons fait dans le chapitre Flex - Créer une application . Si tout va bien avec votre application, elle produira le résultat suivant: [ Essayez-le en ligne ]