Results 1 to 4 of 4

Thread: How to access stage elements from within a class

  1. #1
    Join Date
    Oct 2008
    Posts
    86

    How to access stage elements from within a class

    Please let me know how to figure out how to access stage elements from within a class. I enter the following code in my program which does not work by itself..
    Code:
    tarkey as string
    
    public property let key(byval putData as string)
    tarkey=putdata
    end property
    This is very little code that I have used in Program I have inserted this because I think here is something wrong...

  2. #2
    Join Date
    Apr 2008
    Posts
    193

    Re: How to access stage elements from within a class

    You may use the following method this method will be important from all aspects if you wanted to access your elements within the class. You might want to add a constructor or a set function otherwise you will not be able to modify.

    Code:
    package {
        import flash.display.*;
    
        public class Main extends StandrdMotionclip{
            public static var mainStage:Stage;
            
            public function Main() {
                mainStage = stage;
            }
        }
    }

  3. #3
    Join Date
    Nov 2008
    Posts
    118

    Re: How to access stage elements from within a class

    When you view your content in the standalone Flash player, to resize the stage you resize the player itself, The only time I would access a field directly is when the accessor has a lot of overhead. And when you view your content embedded in an HTML page, the stage only resizes when the browser changes the size of the element Flash is embedded into (via Javascript, for instance). another thing to mention is if your looking to retrieve the stage width/height that was used when you published an externally loaded swf.

  4. #4
    Join Date
    Dec 2008
    Posts
    93

    Re: How to access stage elements from within a class

    The great part about private variables is that you are able to see all the places they are used when you change something. it is not generally possible to resize the stage from within application logic, unless the container exposes a way to do it. If your getter/setter does something you need, use it. If it doesn't matter you decide. if you do have off stage elements you would need to use a mask so that the mask is the size of your 'virtual' stage.. which can be manually placed .. or drawn by actionscript.. Most browsers do indeed expose such functionality via JavaScript.

Similar Threads

  1. Replies: 8
    Last Post: 22-03-2012, 10:32 PM
  2. Which stage in TES had the best class creator?
    By Elettra in forum Video Games
    Replies: 6
    Last Post: 29-06-2011, 10:40 PM
  3. Replies: 5
    Last Post: 27-04-2011, 03:46 PM
  4. Access the non-public members of the class:C++
    By UseME in forum Software Development
    Replies: 3
    Last Post: 18-01-2010, 11:23 AM
  5. Photoshop Elements and Premiere Elements go to version 7.0
    By Killen in forum Customize Desktop
    Replies: 2
    Last Post: 29-08-2008, 01:17 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,266,213.68953 seconds with 17 queries