dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Access stage objects from class

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    2

    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.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Is MoreVideos your document class?

  3. #3
    Junior Member
    Join Date
    Feb 2010
    Posts
    2
    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.

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center