getDefinitionByName() で ReferenceError: Error #1065 が出る場合
たとえば、以下のようなコードがあるとする。
ex1
var clazz:Class = getDefinitionByName('com.example.classes.Hoge');
このコードを実行したとき、以下のエラーが出る場合がある。
ex2
ReferenceError: Error #1065: 変数 Hoge は定義されていません。
at global/flash.utils::getDefinitionByName()
どうも、あらかじめメモリ上に Hoge クラスがロードされていないために発生しているっぽい。
なので、以下のようにあらかじめ Hoge クラスがメモリ上にロードされるようにしてあげると解決する。
ex3
import com.example.classes.Hoge;
// あらかじめクラスをロードさせる
Hoge;
var clazz:Class = getDefinitionByName('com.example.classes.Hoge');
Author And Source
この問題について(getDefinitionByName() で ReferenceError: Error #1065 が出る場合), 我々は、より多くの情報をここで見つけました https://qiita.com/snaka/items/df14ac63b18a27508ad9著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .