タコをピコピコ

by komagata forked from インド人(タコ)を右に (diff: 23)
♥0 | Line 33 | Modified 2009-06-03 23:45:47 | MIT License
play

ActionScript3 source code

/**
 * Copyright komagata ( http://wonderfl.net/user/komagata )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/rpKJ
 */

// forked from komagata's インド人(タコ)を右に
package {
  import flash.display.Sprite
  import flash.display.Loader
  import flash.net.URLRequest
  import flash.events.Event
  import flash.events.TimerEvent
  import flash.utils.Timer
  import flash.media.Sound
  
  [SWF(width=320, height=240, frameRate=30, backgroundColor = "#0099ff")]

  public class Octopus extends Sprite {
    private const octUrl:String = 'http://farm4.static.flickr.com/3402/3585305269_57582463d0_o.gif'
    
    // Sound by Machida Teppei <http://fjord.jp>
    private const picopicoUrl:String = 'http://fjord.jp/mp3/picopico_blues.mp3'
    private var timer:Timer = new Timer(30)

    public function Octopus() {
      var octReq:URLRequest = new URLRequest(octUrl)
      var player:Loader = new Loader()
      player.load(octReq)
      player.y = 100
      
      var picopicoReq:URLRequest = new URLRequest(picopicoUrl)
      var picopico:Sound = new Sound()
      picopico.load(picopicoReq)
      picopico.play()
      
      addChild(player)
      
      timer.addEventListener(TimerEvent.TIMER, function (event:Event):void {
        player.x += 23
        if (player.x > 320) {
          player.x = 0
        }
      })
      timer.start()
    }
  }
}