2011-12-17 24 views
5

我開始用鞋子編碼GUI。我試圖從例子中的進度條,但我發現沒有辦法退出動畫,break沒有工作......Abort Rubys Shoes動畫

animate do |frames| 
    unless frames > 100 
    @p.fraction = (frames % 100)/100.0 
    else 
    break 
    end 
end 

是否有可能停止與鞋子動畫?謝謝。

+0

什麼樣的價值觀不'i'穿過塊運行?它只能達到100? (因爲它是一個進度條而要求) –

+0

'i'代表動畫完成的幀。現在改變了。 – Scott

+0

沒有得到您的答案的電子郵件...謝謝! – Scott

回答

3

肯定,停止這是否

Shoes.app do 
    stack :margin => 0.1 do 
    title "Progress example" 
    @p = progress :width => 1.0 
    @animate = animate (24) do |i| 
     @p.fraction = (i % 100)/100.0 
     @animate.stop if i > 99 
    end 
    end 
end