View Full Version : root?
Pattt
November 7th, 2007, 12:04 PM
When I use root.i++ I get:
1119: Access of possibly undefined property i through a reference with static type flash.display.DisplayObject.
When I use root[I]++ I get:
1120: Access of undefined property i.
What shall I use to make i++? Please help!
senocular
November 7th, 2007, 12:10 PM
root is typed as DisplayObject. This means in Flash, it expects you to use only methods and properties that are associated with that type - even if other properties actually exist.
To get around this you need to recast root to a different type, either a dynamic type where you can validly access any property without error (an example dynamic type would be Object) or to the real type of root, that being your document class.
Object(root).i++; // dynamic casting
MainTimelineOrDocumentClassNameHere(root).i++; // casting to correct type
453.0
November 7th, 2007, 01:12 PM
^ Cool, thanks for the info.
Pattt
November 7th, 2007, 01:34 PM
It worked when I used
root["i"]++;
:pa:
senocular
November 7th, 2007, 01:36 PM
using array access operators is another way to escape typing http://www.senocular.com/smilies/yes.gif
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.