How can you determine if swf is played standalone or loaded in other swf?

旧时模样 提交于 2019-12-02 12:00:15

问题


I have two swf's. One "show" of some sort, and one "menu" that acts as a loader for "shows". The "show" swf can run in its own respect, or by being loaded via the "menu".

Is there a way to determine, if the "show" is run stand-alone or as loaded into the "menu"?

One solution is to have the "menu's" Loader object set a variable on the loaded "show", like myLoader.content.thisIsFromMenu = true; and then checking in the "show", if such a variable exists and is true. BUT I was wondering, if there is any more generic way, that would not require for the "show" to know anything about the "menu" to determine, if it is loaded into a swf or played by itself?


回答1:


if (root.parent && root.parent == stage) {
  // Standalone
}



回答2:


In the constructor of loaded swf:

if (stage && parent == stage) {/*I'm standalone*/}

Or maybe if (parent is Loader) will also work (vice versa logic)




回答3:


if (root.name == "root1") //standalone


来源:https://stackoverflow.com/questions/9757972/how-can-you-determine-if-swf-is-played-standalone-or-loaded-in-other-swf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!