Search code examples
actionscript-3airstarling-framework

AIR StageText Implicit Coercion error


I am trying to implement StageText in and AIR/AS3 app and when I use something like:

private var txtField:StageText = new StageText();
txtField.stage = stage;
txtField.viewPort = new Rectangle(200, 150, 400, 35);

for example I get the error:

1067: Implicit coercion of a value of type starling.display:Stage to an unrelated type flash.display:Stage.

I have no idea why this is happening as I have followed the documentation.


Solution

  • Note the difference between starling.display:Stage and flash.display:Stage - these are different types. Starling uses its own implementation of display list and this often seems to cause some misunderstanding among developers. So, what you really want to assign to txtField.stage is your Starling Stage, not the Flash native one.