2

I have a weird problem, and I don't know why this is happening.

I have a movieClip with the name of wellcomeMenu. It is exported for AS with the name of WellcomeMenu, and in the document class I do this:

public var _welcome:WellcomeMenu = new WellcomeMenu();

    public function MainTest()
    {
        _welcome.x = stage.stageWidth * 0.5 
        _welcome.y = stage.y
        addChild(_welcome);

    }

All simple stuff. Then I go into the WellcomeMenu movieClip and make a shape with the name Box, then I make it a movieClip too, and give its Instance Name the name specialItem.

To sum up: I dynamically call a wellcomeMenu movieclip, which contains another movieClip with an instance name of specialItem. Then I compile and get this error:

ReferenceError: Error #1056: Cannot create property specialItem on WellcomeMenu.
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at WellcomeMenu()
at MainTest()

what am I doing wrong?

When I remove its instance name, it shows just fine, but I can't manipulate the movieclip within the WellcomeMenu.

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
GregorII
  • 221
  • 4
  • 13
  • try using different instance name. Also, first obtain stage instance and then proceed. – Rajneesh Gaikwad Feb 08 '14 at 02:20
  • 1
    ok i found this and made it work http://stackoverflow.com/questions/1734169/flash-as3-referenceerror-error-1056-cannot-create-property but before that i was freely doing that without checking the **Automatically decleare stage instances** , or atleast i think i did ?(didnt pay attention to this ever). can someone explain me what is going on ? – GregorII Feb 08 '14 at 02:24
  • I tried with many different instance names... nothing changed, and what do you mean by "obtain stage instance and then proceed" – GregorII Feb 08 '14 at 02:25
  • Anyway your problem was different but I mean to say `Event.ADDED_TO_STAGE` – Rajneesh Gaikwad Feb 08 '14 at 02:29
  • auu :D i did even that ... yet it was the same ? any clue when i dont have **Automatically decleare stage instances** checked , how to solve this, cause i red in the lint that its better if its turned off? – GregorII Feb 08 '14 at 02:38
  • Maybe export that `Box` to Actionscript too? – Vesper Feb 08 '14 at 04:59

2 Answers2

2

I think the problem is in specialItem attribute in the WellcomeMenu class (by the way, you may have an extra l in there if it's English). If the environment is failing to create the attribute, it is probably already there, but with the wrong permission.

If you declared specialItem manually, make sure it's public and not private (public Sprite specialItem) or else the environment won't have permission to set its value.

Another possible issue is that you declared specialItem manually and still enabled the "automatically declare instance", the environment may try to redeclare the attribute and fail. So either remove the manual declaration or disable that option.

BoppreH
  • 8,014
  • 4
  • 34
  • 71
  • yea after several attempts i did somehow manage to solve it,but you from you now i know what i did right :D – GregorII Feb 09 '14 at 00:20
0

The error can happen if you assign an object of one type to another.

var square:Square = new Square();
square.row = 9;  //OK, There is a row property in the Square class
var block:Block = new Block(); 
square = block; //this is not a compiler error, but probably a mistake
square.row = 0; //error if there is no row property on Block