This blog has moved to a new location! http://iqandreas.github.com/

Wednesday, September 9, 2009

Error: Error #2071: The Stage class does not implement this property or method.

Error: Error #2071: The Stage class does not implement this property or method.
at Error$/throwError()
at flash.display::Stage/set x()
at Untitled_fla::MainTimeline/frame1()[Untitled_fla.MainTimeline::frame1:1]
Similar to Error #2069, Error #2071 occurs when you try to set stage properties that have been overriden.

To quote the ActionScript 3.0 Language Reference:
Quote:
In addition, the following inherited properties are inapplicable to Stage objects. If you try to set them, an IllegalOperationError is thrown. These properties may always be read, but since they cannot be set, they will always contain default values.
  • accessibilityProperties
  • alpha
  • blendMode
  • cacheAsBitmap
  • contextMenu
  • filters
  • focusRect
  • loaderInfo
  • mask
  • mouseEnabled
  • name
  • opaqueBackground
  • rotation
  • scale9Grid
  • scaleX
  • scaleY
  • scrollRect
  • tabEnabled
  • tabIndex
  • transform
  • visible
  • x
  • y
Logically thinking, you can't really set the x, y, or rotation values of the stage, since it is supposedly "God", what everything else in Flash is measured against. Sure, if the user is running a SWF as a projector or through the debugger, they can move the dialog box around, however, this doesn't really change the x and y values of the stage, as the stage will still always be at 0,0 inside of its container.

If you want to measure any farther, you will have to start measuring in the operating system's coordinate space. That's going a little too far, and is even outside of Flash's capabilities.

Also note that the following stage properties are overriden, and throw errors if you try to set them. These are different than the properties listed above because they will hold actual values, not just the default ones, but you are still not allowed to modify them.
  • height - can be read, but throws an IllegalOperationError if set
  • width - can be read, but throws an IllegalOperationError if set
  • stageHeight - is able to be set, and will not throw an error, but it seems as though changing this property has no effect on the stage, at least not when run in the Debugger Player
  • stageWidth - is able to be set, and will not throw an error, but it seems as though changing this property has no effect on the stage, at least not when run in the Debugger Player
  • textSnapshot - cannot be read or accessed. Should be in the list above, but I'm not sure why Adobe didn't include this property to the list.

NOTE: Unless you like boring nitty gritty details, you can just stop reading right here. The rest is just for reference.

In addition, some properties and methods cannot be run outside of the stage's security sandbox without the proper permissions, so those methods are overridden just so Flash can check their security credentials. They act just as the regular methods they override with the difference that they will dispatch a SecurityError if accessed by an object outside of the current sandbox.

The affected properties all have to do with children and are "mouseChildren", "numChildren", and "tabChildren". The affected methods that have to do with containing children are addChild(), addChildAt(), removeChild(), removeChildAt(), setChildIndex(), and swapChildrenAt(). Finally, the only other affected methods have to do with Event Dispatching, and are all overriden for security checks; addEventListener(), dispatchEvent(), hasEventListener(), and willTrigger(). Strangely enough, removeEventListener(), doesn't require a security check...

However, don't bother memorizing them as these methods will act just like any other display object to outside users, and won't affect your code at all.



Thanks to Senocular for pointing much of this out.

1 comment:

  1. IMHO it's best not to use the 'stage; as your root movieclip/sprite. I create a container (root) movieclip which everything attaches to then I attach that to the stage...

    ReplyDelete