Sep 22
Door: Mickel van Kouwen

Genoeg van Fuse? Tijd voor een echte AS3 tweenengine! Bekijk dan TweenMax van Jack Doyle. Alle functies die Fuse in zich heeft zijn te vinden in TweenMax en nog veel meer. Max rulezzzzzzzzz!

Hier een voorbeeld van de functie AllFrom.
De functie heeft als eigenschap om meerdere movieclips in één keer een x en y waarde te geven, bijv. : random()*400. De movieclips op de stage zullen eerst gerenderd worden voordat ze zichtbaar worden. Hierna zullen de movieclips naar hun oorsponkelijke x en y waarden animeren. (altijd al willen doen, helaas kan Fuse dit niet, erg vet dus! :-) )

Download source .fla
Bekijk broncode:

CODE:
  1. import gs.TweenMax;
  2. import gs.easing.*;
  3.  
  4. stage.frameRate = 30;
  5. var aMc:Array = [mc1, mc2, mc3, mc4, mc5, mc6, mc7, mc8];
  6.  
  7. function go():void
  8. {
  9.     enableBtn.enabled = false;
  10.     disableBtn.enabled = false;
  11.    
  12.     TweenMax.allFrom(aMc, 3, {scaleX:2,
  13.                               scaleY:2,
  14.                               rotation:5*360,
  15.                               blurFilter:{blurX:30, blurY:30, quality:1},
  16.                               x:-200,
  17.                               y:500,
  18.                               bezierThrough:[{x:75, y:274},{x:400, y:-400}],
  19.                               orientToBezier:false,
  20.                               delayIncrement:0.2,
  21.                               ease:Back.easeInOut,
  22.                               // easeParams:[2, 0.2], // for Elastic.easeOut
  23.                               renderOnStart:false,
  24.                               onCompleteAll:makeButtons,
  25.                               onCompleteAllParams:["make buttons"]
  26.                               });
  27. }
  28.  
  29. function makeButtons(sEnd:String):void
  30. {
  31.     for (var i:Number = 0; i <aMc.length; i++) {
  32.         //aMc[i].idName = "mc" + i;
  33.         aMc[i].addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
  34.         aMc[i].addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
  35.         aMc[i].addEventListener(MouseEvent.CLICK, onMouseClick);
  36.         aMc[i].buttonMode = true;
  37.         aMc[i].useHandCursor = true;       
  38.     }
  39.    
  40.     txt.text = sEnd;
  41.    
  42.     enableBtn.enabled = true;
  43.     disableBtn.enabled = true;
  44. }
  45.  
  46. var scaleTween:TweenMax;
  47.  
  48. function onMouseOver(event:MouseEvent):void
  49. {
  50.     scaleTween = TweenMax.to(event.target, 0.5, {scaleX:1.2,
  51.                                              scaleY:1.2,
  52.                                                  //dropShadowFilter:{color:0xFFFFFF, alpha:0.4, blurX:10, blurY:10, angle:0, distance:10, quality:3}
  53.                                                  glowFilter:{color:0xFFFFFF, alpha:0.6, blurX:10, blurY:10, strength:5, quality:3}
  54.                                                  });
  55.     txt.text = event.target.name;
  56.    
  57. }
  58.  
  59. function onMouseOut(event:MouseEvent):void
  60. {
  61.     scaleTween = TweenMax.to(event.target, 0.5, {scaleX:1,
  62.                                              scaleY:1,
  63.                                                  //dropShadowFilter:{color:0xFFFFFF, alpha:0, blurX:0, blurY:0, angle:0, distance:0, quality:3}
  64.                                                  glowFilter:{color:0xFFFFFF, alpha:0, blurX:0, blurY:0, strength:0, quality:3}
  65.                                                  });
  66. }
  67.  
  68. function onMouseClick(event:MouseEvent):void
  69. {
  70.     scaleTween = TweenMax.to(event.target, 2, {rotation:360*2});
  71.    
  72.     txt.text = "click!";
  73. }
  74.  
  75. disableBtn.addEventListener(MouseEvent.CLICK, disableButtons);
  76. disableBtn.buttonMode = true;
  77. disableBtn.useHandCursor = true;
  78.  
  79. enableBtn.addEventListener(MouseEvent.CLICK, enableButtons);
  80. enableBtn.buttonMode = true;
  81. enableBtn.useHandCursor = true;
  82.  
  83. resetBtn.addEventListener(MouseEvent.CLICK, resetAnimation);
  84. resetBtn.buttonMode = true;
  85. resetBtn.useHandCursor = true;
  86.  
  87. function enableButtons(event:MouseEvent):void
  88. {
  89.     for (var i:Number = 0; i <aMc.length; i++) {
  90.         aMc[i].mouseEnabled = true;
  91.        
  92.     }
  93. }
  94.  
  95. function disableButtons(event:MouseEvent):void
  96. {
  97.     for (var i:Number = 0; i <aMc.length; i++) {
  98.         aMc[i].mouseEnabled = false;
  99.     }
  100. }
  101.  
  102. function resetAnimation(event:MouseEvent):void
  103. {
  104.     go();
  105. }
  106.  
  107. go();

  • Share/Bookmark

Gerelateerde

Laat hier je reactie achter

*
Vul hier de code in
Anti-Spam Image