Skip to main content
frdmsun
Known Participant
April 24, 2011
Question

1152: A conflict exists with inherited definition in namespace public

  • April 24, 2011
  • 2 replies
  • 4598 views

I have an actionscript 3 library item, "BG", that is linked to the class BGClass. BG contains a Sprite that has an instance name, "bg" and likewise BGClass has a public bg property. So the class looks like this:

public class BGCass extends Base {

     public var bg:Sprite;

     public function BGCass() {

          bg.width = 200

     }

}

Everything works fine. But if I wish to move the public bg into the Base class like this I get the error.

public class BGCass extends Base {

     public function BGCass() {

          bg.width = 200

     }

}

public class Base extends Sprite {

     public var bg:Sprite;

     public function Base() {

     }

}

I have tried using getter setters in Base and overriding them in BGClass and I still get the error. Is this a bug in Flash? Is there a clean solution or do I need to create some sort of proxy variable to finally get bg to Base? I know that turning off "automatically declare stage instances" in Flash will get rid of the error but I need to keep it on for the designers. Any solutions?

Thanks.

This topic has been closed for replies.

2 replies

Participating Frequently
April 26, 2011

The issue is due to the AS3 inheritance.

Ok here is the thing, AutoDeclareStageInstance is automatically generated at compile time.  this ensures that all clips in the library are added as definitions.


This is ok if a class is generated for it.  The crappy thing is when you attach your own custom class to the clip.

When stageinstances decleration is on or off.  the compiler, expects the variables to remain within the attached class.


Even if your custom class extends another class.  that class can not have the variables declared within.  Again this is because of the AutoDefinitions whether on or off.

Adobe has tried to make the compilations streamlined so nothing breaks.  but because of this things get iffy.

so your way around this is 2 things.

turn off stage instances for them.  and do what your doing.  or do not declare public bg:Sprite in your class, and let the compiler do it.

Lee_Burrows
Participating Frequently
April 24, 2011

hi

if turning off "automatically declare stage instances" fixes the problem then there is probably an issue with the way you have named an instance - is something named "bg" on the stage?

if not can you post all the relevant code (ie the full classes for Base and BGCass)?