2
我想在Starling Framework項目上使用Greensock LoaderMax,但由於Starling有很多自己的類,所以我可以如何使其與其他類一起工作使用原生類?使Starling FrameWork與使用本機DisplayObject的類一起工作
經驗:
package
{
import flash.display.Sprite;
import flash.events.Event;
import starling.core.Starling
[SWF(width="1280",height="800",frameRate="60",backgroundColor="#002143")]
public class Main extends Sprite
{
private var mStarling:Starling
public function Main():void
{
mStarling = new Starling(Game, stage)
mStarling.antiAliasing = 1
mStarling.start()
}
}
}
package
{
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.ContentDisplay;
import com.greensock.loading.SWFLoader;
import starling.display.Sprite;
import starling.events.Event;
public class Game extends Sprite
{
private var queue:SWFLoader
private var mm:ContentDisplay
public function Game():void
{
if (stage)
init()
else
this.addEventListener(Event.ADDED_TO_STAGE, init)
}
private function init(e:Event = null):void
{
queue = new SWFLoader("MainMenu.swf", {onComplete: completeHandler})
queue.load()
}
private function completeHandler(e:LoaderEvent):void
{
mm = queue.content
addChild(mm)
}
}
}
將返回錯誤:因爲它們是不同的結構和等
Error: Implicit coercion of a value of type com.greensock.loading.display:ContentDisplay to an unrelated type starling.display:DisplayObject.