立诚勿怠,格物致知
It's all about connecting the dots

Use of PreloadJS


var $ = jQuery
// indicator for preloading percentage
var $indicator = $('#loadingInner')
var preload
var manifest = [
  {
    src: '/img/magic.jpg',
    id: 'magic'
  }, {
    src: '/img/snow.png',
    id: 'snow'
  }
]

// start preloading
function startPreload () {
  preload = new createjs.LoadQueue(true)
  preload.on('fileload', handleFileLoad)
  preload.on('progress', handleFileProgress)
  preload.on('complete', loadComplete)
  preload.on('error', loadError)
  preload.loadManifest(manifest)
}

// handle single file
function handleFileLoad (event) {
  console.log('File type: ' + event.item.type)
  /*
  if(event.item.id == 'magic'){
    console.log('majic picture has been loaded!');
  };
  if(event.item.id == 'photo') {
    console.log('photo picture has been loaded!')
  }
  */
}

// handle preloading error
function loadError (evt) {
  // console.log('There is something wrong!',evt.text);
}

// handle preloading process
function handleFileProgress (event) {
  var percentage = preload.progress * 100 | 0
  $indicator.css({
    width: percentage + '%'
  })
}

// handle preloading success
function loadComplete (event) {
  // console.log('All resources have been loaded!');
  setTimeout(function () {
    $('#page0').slideUp(600)
  }, 300)
  // console.log('Hello world!');
}
// invoke the method
startPreload()
赞(0) 打赏
文章名称:《Use of PreloadJS》
文章链接:https://www.orzzone.com/use-of-preloadjs.html
商业联系:yakima.public@gmail.com

本站大部分文章为原创或编译而来,对于本站版权文章,未经许可不得用于商业目的,非商业性转载请以链接形式标注原文出处。
本站内容仅供个人学习交流,不做为任何投资、建议的参考依据,因此产生的问题需自行承担。

评论 2

  1. #1

    现在不从事专业的工作了?看你好像要跳进前端的坑了

    mary8年前 (2015-12-08)回复
    • 对啊,已经转行做前端了。

      Yakima Teng8年前 (2015-12-18)回复

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力提供更多优质内容!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册