-
Access stage objects from class
I'm trying to access a MovieClip created within the authoring tool from an ActionScript class. Here is my code:
PHP Code:
package {
import flash.display.*;
public class MoreVideos extends Sprite {
public function MoreVideos():void {
moreVideosBox.visible = false;
}
}
}
moreVideosBox being the MovieClip I created in flash. When I attempt to do this, I get:
"1120: Access of undefined property moreVideosBox."
I also tried changing that to [stage.moreVideosBox.visible = false;], but I then got "1119: Access of possibly undefined property moreVideosBox through a reference with static type flash.display:Stage."
Is it possible to directly alter items in the authoring tool from a class? If I move 'moreVideosBox.visible = false;' outside of the class, in the main .as file, it works fine.
-
Is MoreVideos your document class?
-
Yes,
In my base .as file, I have the following:
var myMoreVidoes:MoreVideos = new MoreVideos();
And I can tell it's being loaded/called, as the error then happens in MoreVideos.as on line 7.
-
If you have a base .as file that is not MoreVideos.as, that means that MoreVideos is NOT your document class.
Ideally, MoreVideos would not directly manipulate things by reaching up the display hierarchy. You could pass an explicit reference to the box (and keep a reference in MoreVideos), or you could have MoreVideos dispatch an event and have the main timeline/document class listen for that event and react to it by changing the box's visibility.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|