闪存加载器问题
我在某个问题上遇到困难: 我有一个主要的 Flash 应用程序,可以加载不同的内容 - 游戏、应用程序等。在某些游戏中,加载它时,其部件(电影剪辑)的行为会发生变化。例如,如果没有加载程序应用程序,您可以在内容游戏中射击并杀死一个人,但在加载程序中,当您玩您射击的同一个游戏时,尽管子弹接触到了人,但什么也没有发生。 我希望我能解释清楚))。 知道为什么会发生这种情况吗? 谢谢我提前
更新:
嗨,Malte Köhrer, 非常感谢您的回复!这简直让我发疯——答案就在这附近,但被错过了)。 这是代码 - 在 Event.COMPLETE 上我更改了加载内容的位置。我有另一个在 COMPLETE 期间运行的函数,它添加了其位置发生更改的部分。重要的是它们是在完成时而不是之前更改的。 感谢您的帮助。
var loader:Loader = new Loader();
addChild(loader);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadingFunc);
loader.load(new URLRequest(urlAdr));
function loadingFunc(event:Event):void
{
var loaderInf:LoaderInfo = event.target as LoaderInfo;
dispObj = loaderInf.loader;
//dispObj.x = stage.stageWidth/2-loaderInf.width/2; --------------- That how it was before I changed root property
//dispObj.y = stage.stageHeight/2-loaderInf.height/2;
var mb:MovieClip = dispObj.loaderInfo.content as MovieClip; //----------- That how it's now
mb.x = stage.stageWidth/2-loaderInf.width/2;
mb.y = stage.stageHeight/2-loaderInf.height/2;
//var app:App = new App(mb); This give the same resault as var mb:MovieClip = dispObj.loaderInfo.content as MovieClip;
}
I am have difficulties with a certain issue :
I have a main flash application that loads different content - games, applications and etc. In some games when it is loaded there is change in it's behavior of parts(movieclips) . For example without the loader-application you shoot and kill a person in content game but in the loader when you play with the same game you shoot and although the bullet has touched the person-mc nothing happens.
I hope I explain it ok)).
Any idea why is that happens?
thanks i advance
update :
Hi Malte Köhrer,
Thank you for your replies very much! It just drives me crazy - the answer is somewhere around here but is missed).
Here is the code - on Event.COMPLETE I change the position of the loaded content. I have another function that runs during the COMPLETE and it adds the parts that their placement is changed. The important that they are changed onCOMPLETE not before.
thanks for your kind help.
var loader:Loader = new Loader();
addChild(loader);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadingFunc);
loader.load(new URLRequest(urlAdr));
function loadingFunc(event:Event):void
{
var loaderInf:LoaderInfo = event.target as LoaderInfo;
dispObj = loaderInf.loader;
//dispObj.x = stage.stageWidth/2-loaderInf.width/2; --------------- That how it was before I changed root property
//dispObj.y = stage.stageHeight/2-loaderInf.height/2;
var mb:MovieClip = dispObj.loaderInfo.content as MovieClip; //----------- That how it's now
mb.x = stage.stageWidth/2-loaderInf.width/2;
mb.y = stage.stageHeight/2-loaderInf.height/2;
//var app:App = new App(mb); This give the same resault as var mb:MovieClip = dispObj.loaderInfo.content as MovieClip;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
避免使用 root 的一种方法是从时间轴中像这样初始化您的应用程序:
在这种情况下,您向应用程序传递对包含脚本的影片剪辑的引用,无论它是在 root 中还是在其他位置。下面是该类的示例:
现在您已经保存了对影片剪辑的引用,并且可以使用它来访问(例如:setHeadline() 函数)所有内容,而不必担心 root 不包含您期望的内容。
A way to avoid using root would be initalizing your app like this from the timeline:
In that case you pass the App a reference to the movieclip that is containing the script, no matter if it's in root or anywhere else. Here's an example of how the class could look like:
Now you got the reference to the movieclip saved and can use it to access (example: setHeadline() function) everything without worrying about root not containing what you expect it.