2012-03-22 32 views
0

對於如何在Flash中實現它有點粗略。 是否容易適應Actionscript,以便您可以獲得多次翻轉?也就是說,您可以翻轉卡片幾次並每次獲得不同的圖像?是否容易適應Actionscript,以便您可以獲得多個翻轉?

這是兩次翻轉和執行此代碼。現在我打算稍微轉移一下以實現翻轉卡片數次。

package 
{ 
    import flash.display.*; 
    import flash.text.*; 
    import flash.events.*; 

    import com.greensock.TimelineLite; 
    import com.greensock.TweenLite; 
    import com.greensock.easing.*; 

    public class Main extends MovieClip 
    { 
     public function Main() 
     { 
      addEventListener(Event.ADDED_TO_STAGE,init); 
     } 

     private function init(evt:Event=null):void 
     { 
      removeEventListener(Event.ADDED_TO_STAGE,init); 

      setClip(); 
     } 

     private function setClip():void 
     { 
      clip_mc.z=300; 
      clip_mc.getChildAt(0).visible=false; 
      clip_mc.getChildAt(0).rotationY=180; 
      clip_mc.mouseChildren=false; 
      clip_mc.buttonMode=true; 
      clip_mc.addEventListener(MouseEvent.MOUSE_DOWN,onClipDown); 
     } 

     private function onClipDown(evt:MouseEvent) 
     { 
      evt.target.mouseEnabled=false; 

      var arrive:Number; 
      if(clip_mc.rotationY > 89) 
       arrive=0; 
      else 
       arrive=180; 

      var my_tween=new TimelineLite(); 
      my_tween.insert(TweenLite.to(clip_mc,0.5,{z:200,ease:Back.easeOut })); 
      my_tween.insert(TweenLite.to(clip_mc,1.5,{rotationY:arrive,ease:Strong.easeInOut,onUpdate:setClipSide,onUpdateParams:[clip_mc]})); 
      my_tween.insert(TweenLite.to(clip_mc,0.5,{z:300,ease:Back.easeIn,onComplete:done}),0.75); 
     } 

     private function setClipSide(clip_mc) 
     { 
      if(clip_mc.rotationY > 89) 
      { 
       clip_mc.getChildAt(1).visible=false; 
       clip_mc.getChildAt(0).visible=true; 
      } 
      else 
      { 
       clip_mc.getChildAt(0).visible=false; 
       clip_mc.getChildAt(1).visible=true; 
      } 
     } 

     private function done():void 
     { 
      clip_mc.mouseEnabled=true; 
     } 
    } 
} 
+0

是的,這絕對有可能。你的問題是「容易嗎?」那取決於程序員。對於優秀的程序員來說,這非常簡單。指定你已經嘗試了什麼,以及你有什麼麻煩,而不是隻是要求我們爲你做這件事。如果你需要向正確的方向推動,試着擴展你的setClipSide到更多的如果有更多的孩子的語句,是不同的圖像....只是展開你已經有的東西。 – 2012-03-22 12:41:38

+0

ty laing讓我試試這個。 – 2012-03-22 12:48:47

回答

0

是的,這是安靜的可能你的差不多了,你怎麼安排,你可以不停地重複這個結構

private function setClipSide(clip_mc) 
    { 
     if(clip_mc.rotationY > 89 && clip_mc.rotationY<280) // i added 
     { 
      clip_mc.getChildAt(1).visible=false; 
      clip_mc.getChildAt(0).visible=true; 
     } 
     else 
     { 
      clip_mc.getChildAt(0).visible=false; 
      clip_mc.getChildAt(1).visible=true; 
     } 
    } 

什麼,你會想要做的就是替換以下變量這些線路的翻轉方式,或函數或公式

  clip_mc.getChildAt(1).visible=false;// here you have only limited yourself 
      clip_mc.getChildAt(0).visible=true;// 

所以在這個區域中,您既可以增加一個功能隨機生成卡值,無論是從一個變量或簡單地做一個RNG出託塔的l你的數組長度[] - 1如果這就是你的圖像或值的存儲方式。

繼承人老虎機我做了所有的影片剪輯是如何加入到thier地方根據我的號碼genenerator,除了我的RNG的一個例子是PHP,然後通過通到http://www.gamezslave.net/game/Slots.html讓我知道你如何去。

相關問題