3
votes

I'm a total AS3 / Starling newbie, but I'm trying to (programmatically) add an FLV video file to the 'background' of what is essentially a splash screen.

Example code I have found online basically distills to... var v:Video = new Video(100, 100); this.addChild(v);

This works in the top-level class that extends flash.display.Sprite, however my Game class (that extends starling.display.Spite) fails, complaining of an "Implicit coercion of a value of type Video to an unrelated type DisplayObject."

Strangely enough, the signature of the addChild function on the Starling Sprite class is the same as that of the Flash Sprite class.

So basically the question is: why do I seem to be unable to add a Video object as a child to a Starling Sprite class (but successfully to a Flash Sprite class)?

I'm sure the answer is ridiculously simple... please let me know if I need to add more code or anything. Or if what I'm doing is totally the wrong way.

2

2 Answers

3
votes

Or you could add the video to the Flash layer which sits above Starling:

Starling.current.nativeOverlay.addChild(v);

and

Starling.current.nativeOverlay.removeChild(v);

Bare in mind you are not using Starling GPU drawing with this though.

3
votes

This is because the Starling framework was designed to mimic the regular Flash DisplayList (not completely recreating all the features though). Concretely, you are trying to pass a reference to an object of type starling.display.DisplayObject instead of flash.display.DisplayObject, which gives the appropriate error.

In order to play a video with Starling, you could upload each frame of the movie to a texture. Have a look at this topic on Starling's forum.