Jump to content
Search Community

Error loading in Starling Framework

youwh test
Moderator Tag

Recommended Posts

I have a class that is using starling framework, and I'm trying to use LoaderMax to loads in a swf, but it returns the error

col: 13 Error: Implicit coercion of a value of type com.greensock.loading.display:ContentDisplay to an unrelated type starling.display:DisplayObject.

 

This is my code:

package
{
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.ContentDisplay;
import com.greensock.loading.SWFLoader;
import starling.display.Sprite;
import starling.core.Starling

public class Game extends Sprite
{		
	private var queue:SWFLoader
	private var mm:ContentDisplay

	public function Game():void
	{			
		queue = new SWFLoader("MainMenu.swf", {onComplete: completeHandler})
		queue.load()
	}

	private function completeHandler(e:LoaderEvent):void
	{
		mm = queue.rawContent
		addChild(mm)
	}		
}
}

Link to comment
Share on other sites

the rawContent of a SWFLoader is MovieClip.

the content is a ContentDisplay (container Sprite)

 

just make sure you are casting your objects as the right type that starling can allow.

 

 

 

 private var mm:ContentDisplay
mm = queue.rawContent  //try using content instead

Link to comment
Share on other sites

the rawContent of a SWFLoader is MovieClip.

Just to clarify, it is probably the most common for it to be a MovieClip, but if the swf's document class extends something else, like a Sprite, then the rawContent would reflect that.

 

As for the error you're running into, that sounds like a starling issue/question. Your object (which is a starling.display.Sprite) will only allow you to addChild() objects that are also starling objects (technically, starling.display.DisplayObject) but of course a SWFLoader works in the world of regular DisplayObjects - it doesn't convert them into starling ones for you (nor should it - that would be a very bad thing). See what I mean? In other words, this issue has nothing to do with LoaderMax/SWFLoader - it's a starling issue. I'm not intimately familiar with starling but I don't think you can just make a MovieClip/Sprite/swf into a starling object in one easy step. It requires sprite sheets and other workarounds that get your content into bitmap-like form. That should be easy for ImageLoaders, but not nearly as easy for existing MovieClips/Sprites with interactivity, multiple frames, etc.

Link to comment
Share on other sites

I'm not intimately familiar with starling but I don't think you can just make a MovieClip/Sprite/swf into a starling object in one easy step. It requires sprite sheets and other workarounds that get your content into bitmap-like form. That should be easy for ImageLoaders, but not nearly as easy for existing MovieClips/Sprites with interactivity, multiple frames, etc.

hm, thanks for the help! Guess I have to see if there is anyway to convert Starling DisplayObject to use a default DisplayObject :lol:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...