1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Animate CC preloading error

Last updated at Posted at 2021-02-22

Animate CC で HTML5 に書き出した後、ブラウザの読み込み時に次のエラーが出ることがあります

Uncaught TypeError: Cannot read property 'getContext' of undefined

出る時と出ない時があるので厄介かつ、このアラートでは見当もつかずに試行錯誤をした記憶があるのですが、以下のサイトで理由と解決方法がわかりました。

Preloading error with canvas project on first load with a large spritesheet file

If one or more of your assets is taking longer than 8 seconds to load, that's probably what's causing the page to fail. Also your page is loading too much and is going to be a bad user experience.
 
There appears to be no official way to specify a longer timeout, so to extend the timeout period you'll have to manually hack up your generated code. The simplest way appears to be to increase the default timeout. In the libs/createjs file, search for LOAD_TIMEOUT_DEFAULT=8e3. The "8e3" is 8000 written using engineering notation. The 8000 is milliseconds, or 8 seconds. Change the 3 to 4. This gives you an 80-second timeout per asset. The createjs file is overwritten every time you publish, so keep a backup copy of the modified version.

createjsのデフォルトロードウェイト時間が8秒なのが原因でした。
なのでブラウザで読み込みが8秒以上かかるとエラーになります。

解決方法はHTMLで読み込まれているcreatejs.min.jsのLOAD_TIMEOUT_DEFAULTを8e3(=8秒)から変更します

8e4にすると80秒ロードウェイトします。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?