2012-01-24 16 views
0

好吧,現在情況變得有點複雜。 我需要構建一個可以坐在圖像角落的Flash對象來提供額外的內容。 這是超出我的Flash技能水平的方式,我的作品通常僅限於在Photoshop和Illustrator中打印作品,所以請原諒,如果以下任何不明確。我盡力學習,所以任何指向正確方向的指針都將不勝感激。分階段創建複雜的Flash翻轉(循環>翻轉動畫>定時動畫)

所以這就是它應該如何工作,以及我的問題;

  1. 當圖像&閃存加載項小循環動畫將起到吸引眼球/顯示項目互動。 當用戶滾過這個角落時會剝離。我有一個用於翻轉的工作剝離動畫,對鼠標懸停/鼠標關閉以及初始的循環動畫作出反應,但我無法確定如何在鼠標懸停之前進行初始循環,然後在鼠標結束時播放剝離。如果用戶滾動,則返回到最初的動畫循環。 (這些動畫中的每一個都作爲庫中的影片剪輯存儲)

  2. 然後它變得更加複雜......如果用戶停留在角落直到完全剝離,我需要進行一個小倒數(排序的3,2,1情況)顯示,在啓動一個燈箱之前(這必須是jQuery,或者它可以在Flash中完成?)在瀏覽器中提供內容。

感謝任何人的幫助,任何人都可以提供這方面的任何部分。就像我說的,我正在盡我所能學習,所以任何解釋將不勝感激!

回答

0

UPDATE:基於OP的評論,下面概述了一種新的建議解決方案。

我已經寫出了一個改進(但未經測試)的解決方案。由於你對Flash比較陌生,因此我添加了一些小小的「彎路」,希望能夠闡明ActionScript 3的各個部分如何工作,尤其是在事件處理方面。

開始了,這是我怎麼會設置您的主要FLA時間表:

  1. 你的主時間軸創建4層 - 動作,熱點循環,捲曲,按照這個順序從上到下
  2. 在熱點層上,創建一個覆蓋剪輯「可鼠標」區域的矩形。將矩形的顏色設置爲alpha = 0並刪除其具有的任何邊框。然後將其轉換爲MovieClip符號並將舞臺實例命名爲「hotspot_mc」。
  3. 將循環MovieClip放置在循環圖層上並將其命名爲「loop_mc」。
  4. 將捲曲MovieClip放在捲曲層上並將其命名爲「curl_mc」。
  5. actions圖層的第一個關鍵幀添加代碼沿着這些線路:

import flash.external.ExternalInterface; 
import flash.events.MouseEvent; 
import flash.events.Event; 

//Stops the main timeline on the first frame 
stop(); 

//Makes the curl_mc invisible 
//(Note: alpha varies from 0 to 1, so for instance you can make any 
//clip half-transparent by typing clipName.alpha = 0.5) 
curl_mc.alpha = 0; 

//Stop the curl_mc clip from playing initially, we only want it to begin 
//playing on rollover 
curl_mc.stop(); 

//Make your hotspot look like a button when users mouse over it 
//by setting these properties on it 
hotspot_mc.useHandCursor = true; 
hotspot_mc.buttonMode = true; 

//We attach our event handlers to the hotspot. Because the hotspot is a 
//rectangle of specific position and size it lets us control exactly where 
//mouse actions will trigger events. You *could* attach the handlers to 
//loop_mc instead, so a hotspot clip isn't strictly necessary, but it's 
//handy. You can also make the shape in the hotspot_mc any shape you 
//want, it does not need to be a rectangle. 

hotspot_mc.addEventListener(MouseEvent.ROLL_OVER, onLoopRollover, false, 0, true); 
hotspot_mc.addEventListener(MouseEvent.ROLL_OUT, onLoopRollout, false, 0, true); 

//Lastly, to be extra fancy, let's trigger your lightbox when 
//the user clicks the hotspot OR when the curl_mc dispatches 
//the 'curlComplete' event (which you will set up yourself on 
//the last frame of the curl_mc timeline). 

hotspot_mc.addEventListener(MouseEvent.CLICK, showLightbox, false, 0, true); 
curl_mc.addEventListener('curlComplete', showLightbox, false, 0, true); 

//When we roll over the hotspot, hide the loop and show the curl 
function onLoopRollover(e:MouseEvent):void 
{ 
    //Hide the loop animation so we can see the curl beneath it 
    loop_mc.alpha = 0; 
    loop_mc.stop(); 

    //Show the curl animation and play it 
    curl_mc.alpha = 1; 
    curl_mc.gotoAndPlay(1); 
} 

//When we roll out of the hotspot, hide the curl and show the loop 
function onLoopRollout(e:MouseEvent):void 
{ 
    loop_mc.alpha = 1; 
    loop_mc.gotoAndPlay(1); 

    curl_mc.alpha = 0; 
    curl_mc.stop(); 
} 

//Shows the JavaScript-based lightbox 
function showLightbox(e:Event = null):void 
{ 
    ExternalInterface.call('JS_ShowLightbox'); 
} 

...最後,curl_mc時間軸的最後一幀(後您的倒計時序列),該代碼添加到關鍵幀時間線的行爲層:

import flash.events.Event; 
dispatchEvent(new Event('curlComplete')); 
stop(); 


//dispatchEvent() is a function that sends an event out to be 
//handled by any listening handler functions (like the ones on 
//frame 1 of the main timeline). dispatchEvent() accepts an Event 
//as a parameter, which we create new for this purpose. In turn, 
//when creating a new Event, you pass in the name of the event so 
//that handlers can tell them apart. This matches the event name 
//passed in to addEventListener(eventName, eventHandler, false, 0, true). 

//This is how event handlers basically work in AS3. By putting this 
//code on the last frame of curl_mc, we use a new event to signal to 
//our application that the curl animation is done. 

還有比這一個編寫這種情況下,當然是這樣了。然而,通過這種方法,您可以看到如何從應用程序的某個區域創建和「派發」事件,並讓它們由您在不同位置編寫的函數處理。

HTH!

原來的答案

我無法工作,如何進行初始循環,直到鼠標懸停,然後播放揭開廣告,當鼠標懸停。如果用戶滾動,則返回到最初的動畫循環。

使用ActionScript函數gotoAndPlay()和gotoAndStop()。

您可以使用這兩個函數創建循環並控制動畫的播放。例如,如果你創建一個關鍵幀,選擇它,並打開操作窗口,您可以添加此ActionScript:

gotoAndPlay(1); 

只要播放頭到達這個關鍵幀,時間線將跳轉到並從第1幀播放。這將創建從第1幀到關鍵幀的無限循環。每次播放頭碰到這個關鍵幀時,它都會跳回來並重新啓動。

您還可以使用幀標籤,如果他們在時間軸上的定義,如:

gotoAndPlay('rolloverStart'); 

gotoAndStop()的工作方式相同,不同的是它會跳轉到指定的幀並停止動畫那裏。

如果用戶停留在角落裏,直到其完全剝離後,我需要做一個小的倒計時(排序的3,2,1分的情況)展會上,推出燈箱(前將這個必須的jQuery ,還是可以在Flash中完成?)在瀏覽器中提供內容。

只是爲了澄清,有兩個函數來執行:

  1. 當用戶在角落(「熱點」)懸停鼠標時,一個次級動畫將開始播放,並採取當它完成一個動作

  2. Flash必須提高網頁

再上一個收藏夾:#1功能,我能想到的最簡單的方法是將倒計時動畫添加到翻轉動畫的末尾。這有效地創建了一個最終動作的長時間翻轉動畫。

Re:函數#2,你可以使用Flash來調用Javascript函數,包括一個函數將顯示燈箱。在您的倒計時動畫結束時,你可以添加一個關鍵幀,並使用ActionScript 3代碼:

import flash.external.ExternalInterface; 
ExternalInterface.call('JS_ShowLightbox'); 

當閃存到達這個關鍵幀如果您有)您的網頁調用JS_ShowLightbox(一個JavaScript函數,它會被稱爲。

HTH,

羅斯

+0

謝謝,這似乎是一個良好的開端。作爲一個新的我肯定感謝所有的解釋。我關於這一切的一個問題是關於第一部分,循環和剝離。我將每個設置爲庫中的影片剪輯,循環位於關鍵幀1中,並在關鍵幀2中進行剝離。將它引導至這些關鍵幀看起來並不會使這些文件管理器發揮作用。有沒有不同的方式來引用他們或什麼? – TheSwansonCode

+0

您可以通過使用ActionScript對它們調用play()和/或gotoAndPlay()來使這些影片剪輯播放。您的時間線上的影片剪輯首先需要通過名稱來訪問它們。例如第1幀的「loop_mc」和第2幀的「rollover_mc」。然後在第1幀的動作幀中,您可以在第2幀調用「loop_mc.play()」和「rollover_mc.play()」。在每一個影片剪輯,您需要針對ExternalInterface.call的答案等操作關鍵幀。 –

+0

此外 - 我忽略了有關鼠標事件的部分問題。您是否有處理如何使用MouseEvent和addEventListener()函數設置鼠標滾動和卷展欄功能? –