Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.85k stars 819 forks source link

BugReport about Starling.isNativeDisplayObjectEmpty #887

Closed leefj closed 8 years ago

leefj commented 8 years ago

Hi, I Use the Starling.current.nativeOverlay add a loading movieclip to show a loading progress. the movieclip is exported in a swc file witch is created in flash profession. it is so strange,the container.numChildren return 8, when i add to watch expression

container.getChildAt(0) container.getChildAt(1) container.getChildAt(2)

all returns null.

so the last row of Starling.isNativeDisplayObjectEmpty report TypeError: Error #1009: Cannot access a property or method of a null object reference.

is it a bug of starling?

leefj commented 8 years ago

now i just add my loading mc in a sprite and override it's numChildren function

public override function get numChildren():int { return 0; }

it works well now !

PrimaryFeather commented 8 years ago

That's really strange ... I haven't seen anything like that before! If you want, I can look into this - but I'd need a sample SWF and the code you're using to load it. I can't say if there's anything I can do against this, though, since "nativeOverlay" is just a normal Flash Sprite, nothing that Starling really has any control over.

Just let me know!

leefj commented 8 years ago

http://114.55.1.228:8080/images/cx.loading.zip

I have upload my swc ,pls download and test. I use this loading instance.

var loading:mc_animation9=new mc_animation9();

PrimaryFeather commented 8 years ago

Thanks a lot for the update! I'll look into it in the coming days.

PrimaryFeather commented 8 years ago

I just tried it out, but it worked just fine for me! I used the following code:

package
{
    import cx.loading.mc_animation9;

    import starling.core.Starling;
    import starling.display.Sprite;

    public class NativeOverlayIssue887 extends Sprite
    {
        public function NativeOverlayIssue887()
        {
            var loading:mc_animation9=new mc_animation9();
            Starling.current.nativeOverlay.addChild(loading);
            trace("added animation");
        }
    }
}

That's the class I used as "root" for Starling. The SWC was linked to the project. The animation loaded just fine, they were no problems.

Thus, there must be something specific going on in your case; maybe the problem only shows in a specific setup?

I used the latest AIR SDK (22) and Flash Player (22, standalone, debug). What's the environment you were using?

leefj commented 8 years ago

Hi, then problem is here

this._starling.skipUnchangedFrames = true;

set skipUnchangedFrames as true will cause this

TypeError: Error #1009: Cannot access a property or method of a null object reference. at Function/isNativeDisplayObjectEmpty()[/Users/leefangjie/develop/as3_space_v4/Starling_2.0.1/starling/src/starling/core/Starling.as:1085] at Function/isNativeDisplayObjectEmpty()[/Users/leefangjie/develop/as3_space_v4/Starling_2.0.1/starling/src/starling/core/Starling.as:1079] at Function/isNativeDisplayObjectEmpty()[/Users/leefangjie/develop/as3_space_v4/Starling_2.0.1/starling/src/starling/core/Starling.as:1079] at Function/isNativeDisplayObjectEmpty()[/Users/leefangjie/develop/as3_space_v4/Starling_2.0.1/starling/src/starling/core/Starling.as:1079] at starling.core::Starling/get mustAlwaysRender()[/Users/leefangjie/develop/as3_space_v4/Starling_2.0.1/starling/src/starling/core/Starling.as:778] at starling.core::Starling/render()[/Users/leefangjie/develop/as3_space_v4/Starling_2.0.1/starling/src/starling/core/Starling.as:445] at starling.core::Starling/nextFrame()[/Users/leefangjie/develop/as3_space_v4/Starling_2.0.1/starling/src/starling/core/Starling.as:414] at starling.core::Starling/onEnterFrame()[/Users/leefangjie/develop/as3_space_v4/Starling_2.0.1/starling/src/starling/core/Starling.as:634]

PrimaryFeather commented 8 years ago

Ah, of course. Yes, that change does the trick. I can reproduce it now! I'm already looking into it, and I'll share my findings here.

PrimaryFeather commented 8 years ago

Indeed, that seems to be a common behavior of the native MovieClip. I found occasional mentions of this (e.g. here).

With that knowledge, it's thankfully a very easy fix. Thanks a lot for pointing me at this issue!

leefj commented 8 years ago

I want Starling better and better !