闪存加载器问题

发布于 2024-10-19 22:08:24 字数 1225 浏览 6 评论 0原文

我在某个问题上遇到困难: 我有一个主要的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

波浪屿的海角声 2024-10-26 22:08:24

避免使用 root 的一种方法是从时间轴中像这样初始化您的应用程序:

var app:App=new App(this);

在这种情况下,您向应用程序传递对包含脚本的影片剪辑的引用,无论它是在 root 中还是在其他位置。下面是该类的示例:

class App{
    public var appRoot:MovieClip=null;
    function App(appRoot:MovieClip){
        this.appRoot=appRoot:
    }
    function setHeadline(text:String):void{
         appRoot.textField.text=text;
    }
}

现在您已经保存了对影片剪辑的引用,并且可以使用它来访问(例如:setHeadline() 函数)所有内容,而不必担心 root 不包含您期望的内容。

A way to avoid using root would be initalizing your app like this from the timeline:

var app:App=new App(this);

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:

class App{
    public var appRoot:MovieClip=null;
    function App(appRoot:MovieClip){
        this.appRoot=appRoot:
    }
    function setHeadline(text:String):void{
         appRoot.textField.text=text;
    }
}

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文