How do I refer to the stage from a class?

I have a class that places objects on stage with addChild(obj) it allowes me to position objects using pixels( say obj.x = 10; obj.y= 50; ) just fine but if
I try this:  obj.x = stage.stageWidth / 2;  I get a message that I Cannot access a property or method of a null object reference

The stage property is only available to objects that are currently on the display list. Your best bet is probably to pass a stage reference to the class when you instantiate it.

Similar Messages

  • Accessing display object on the stage from another class

    I've googled this to no avail, I've only found how to manipulate the stage itself and not a display object on it, and I'm noob enough to not be able to figure it out from there. :/
    I have a movie clip on the main timeline with instance name displayName. I created a button that should change what frame displayName goes to (in order to...did you guess it?! diplay the Name of the button. Awesome. )
    So I am trying to write the code in a reusable fashion and have the buttons all linked to a class called GeoPuzzle. Inside GeoPuzzle I instantiate a touch event and run the code. However, the function has to be able to change displayName in the main part of the timeline and, of course, the compiler says displayName doesn't exist because I'm in a class and I'm talking about the stage.
    Here is the simplified code in the class:
    package  com.freerangeeggheads.puzzleography {
        import flash.display.MovieClip;
        import flash.events.TouchEvent;
        public class GeoPuzzle extends MovieClip {
            //declare variables
            public function setInitial (abbrev:String, fullName:String, isLocked:Boolean):void {
                //set parameters
                this.addEventListener(TouchEvent.TOUCH_BEGIN, geoTouchBeginHandler);
            public function GeoPuzzle (): void {
            public function geoTouchBeginHandler (e:TouchEvent): void {
                   e.target.addEventListener(TouchEvent.TOUCH_END, geoTouchEndHandler);
                   //some other methods
                   nameDisplay.gotoAndStop(e.target.abbrev);
            public function geoTouchEndHandler (e:TouchEvent): void {
                //some other methods
               nameDisplay.gotoAndStop("USA");
    The lines in bold are my problem. Now this code doesn't actually execute as is so if you see an error in it, yeah, I have no idea what the problem is, but it DID execute before and these lines still gave me trouble so I'm trying to troubleshoot on multiple fronts.
    How can I tell displayName to change it's current frame from within display object class?
    Thanks!

    if displayName is a GeoPuzzle instance, use:
    package  com.freerangeeggheads.puzzleography {
        import flash.display.MovieClip;
        import flash.events.TouchEvent;
        public class GeoPuzzle extends MovieClip {
            //declare variables
            public function setInitial (abbrev:String, fullName:String, isLocked:Boolean):void {
                //set parameters
                this.addEventListener(TouchEvent.TOUCH_BEGIN, geoTouchBeginHandler);
            public function GeoPuzzle (): void {
            public function geoTouchBeginHandler (e:TouchEvent): void {
                   e.target.addEventListener(TouchEvent.TOUCH_END, geoTouchEndHandler);
                   //some other methods
                   this.gotoAndStop(this.abbrev);
            public function geoTouchEndHandler (e:TouchEvent): void {
                //some other methods
               this.gotoAndStop("USA");

  • How to target a label on the stage from a loaded composition

    from EdgeCommons I'm using EC.loadComposition to load another website into a container within EA.
    Now, from a button inside this loaded composition I would like to call a stop function to target a label on the main stage of the EA file.
    sym.getComposition().getStage().stop("scene4"); does not work.
    It think it has to go outside of sym because the composition container is actually an iframe.
    Thank you

    Hi,
    I think you may have replied to my post accidentally. I had asked a question regarding javascripts that could target the stage from a symbol, not about coloring book apps.  However I have made one in Flash, here is the page I made (don't laugh, I never finished it).
    http://boogerbunch.com/home.html
    Here is a link to the forum I used to get the Info to build it, I would think the process would be very close in edge.
    http://www.kirupa.com/developer/mx2004/coloringbook.htm
    Good luck!
    >>> scottsalter0 <[email protected]> 3/1/2013 10:29 AM >>>
    Adobe Community ( http://forums.adobe.com/index.jspa )
    Re: How to target a label on the stage from a div embedded in a symbol?
    created by scottsalter0 ( http://forums.adobe.com/people/scottsalter0 ) in Edge Animate - View the full discussion ( http://forums.adobe.com/message/5113759#5113759 ) 
    Hi there,
    I noticed your Edge Colouring Page post on the Adobe Forums.
    For my University work, I need to create a colouring page using Adobe Edge Animate. Is it possible if you could post a tutorial or step-by-step guide on how to do this please?
    Many Thanks
    Reply to this message by replying to this email -or- go to the message on Adobe Community ( http://forums.adobe.com/message/5113759#5113759 )
    Start a new discussion in Edge Animate by email ( mailto:[email protected] ) or at Adobe Community ( http://forums.adobe.com/choose-container!input.jspa?contentType=1&containerType=14&contain er=4823 )

  • Referring to functions on the stage from a movieclip.

    First of all, I'd like to thank you to anyone who takes their time to read this. I registered to this forum for the sole purpose of getting help to this one issue of mine, as I found most issues were solved in here. By reading my problem (and hopefully responding) you're doing me a huge favour. Thanks in advance.
    I just started "coding" in AS3. By "coding", I actually mean trying around with features and generally trying to grasp the vast amount stuff you can do with this software of. I have some coding experience, however the way   Flash likes to hide code snippets all over my project does tend to confuse me. Not knowing where I tried putting the code and/or rewrote some other stuff keeps me sorta busy.
    I'd also like to apologize for the title, if it in any way confuses you. Shortening down my problem to a single sentence was hard, please keep that in mind.
    Anyway, my issue is this:
    Messing around with movieclips inside movieclips, I've keep encountering the error "1120: Access of undefined property onTimerComplete." I do realize that this error generally is caused by not having defined an instance correctly or not having it defined at all - an error beginners tend to make.
    Nonetheless, I'm not trying to refer to an instance/symbol, I am trying to call a function defined on the stage from within a movieclip that also is placed on the stage.
    I've been reading huge amounts of text/articles and how-to 's, but they all seem to only touch the subject lightly or simply going in head-first - becoming far too complicated for me (a beginner) to grasp.
    So, trying to sum my questions up into something that looks like a tl;dr:
    - What's up with levels, "_root" and referring to functions like in the older versions of flash?
    Flash tells me to use some display-package instead of _root, when I use that... (I do realize the article is from Flash 5.0)
    - How do you refer to a function defined on the stage, from inside a movieclip? (The function is a timer, that is supposed to make the mother-movieclip continue to the next child-movieclip.)
    Please, I really don't know how to define my problem any further than this. Ask as many questions as you would like, I really appreciate any help I can get.
    - Mattimussi

    click file/publish settings/flash and tick "permit debugging".  highlight the line number referenced in the error message.  (and, use:
    Calling:
    stop();
    MovieClip(root).startTimer();
    Defining:
    var myTimer:Timer = new Timer(2000, 1);
    myTimer.addEventListener(TimerEvent.TIMER_COMPLETE,onTimerComplete);
    myTimer.start();
    function onTimerComplete(event:TimerEvent):void{
    play();
    //myTimer.stop();
    function startTimer():void{
    trace("startTimer function was executed");
    myTimer.start();

  • How can i refer to the parent window of the window containing an applet ?

    Hi all,
    I m stuck up with something. I have a web page say 'page1' which has a link that opens up a popup window. This popup say 'page2' window has an applet. On clicking particular pins on the applet i need to
    direct page1 to another URL & close the popup window. i hv tried this code.
    URL url = new URL(applet.getCodeBase(), path);
    AppletContext appletcontext = applet.getAppletContext();
    appletcontext.showDocument(url, "content");
    JSObject win = JSObject.getWindow(applet);
    win.eval("alert(\"Do u wnat to close!\");");
    win.eval("window.close()");
    This code opens up another window on click of the pin, & shows an alert before closing the popup window. On using
    appletcontext.showDocument(url, "_parent"); or
    appletcontext.showDocument(url, "_top");
    The window containing applet gets refreshed with the URL but not page1.
    How can i refer so to page1 from the applet.

    You don't show your code for what parent or top are, but in an
    applet, you must stick with relative links. Once you have the
    appletcontext, use a relative path from there:
    In the snippet below, docName is a relative path, i.e. ../up/above
       * Displays the specified document in the Web browser.
       * @param docName String pathname of document to download from Webserver
       * @return void
      private void fetchDocument(String docName) {
         AppletContext ctx = getAppletContext();
         java.net.URL serverURL = getDocumentBase();
         java.net.URL codeURL   = getCodeBase();
         java.net.URL docURL = null;
         try {
            docURL = new java.net.URL(codeURL, docName);
         catch (java.net.MalformedURLException err) {
            System.out.println("unable to compute URL from (" + serverURL + ", " +
                               docName + ")");
         if(this.bDebug)
           System.out.println("Open document: " + docURL.toString());
         ctx.showDocument(docURL);
      }

  • My aperture library lives on an external hard drive that is corrupt and I can not locate the library. I do have it backed up with TM. How do I safely restore the library from TM to my laptop? I am using the newest version of aperture on my macbook pr

    My aperture library lives on an external hard drive that is corrupt and I can not locate the library. I do have it backed up with TM. How do I safely restore the library from TM to my laptop? I am using the newest version of aperture on my macbook pro.

    Hello Sandra,
    The article linked below details how to go about restoring items from Time Machine in Snow Leopard.
    Mac OS X 10.6: Recovering items using Time Machine and Spotlight
    http://support.apple.com/kb/PH6379
    Sincerely,
    Allen

  • When creating a book how can I get all the photos from an album to show up in the order they were in the album?

    When creating a book in iphoto, how can I get all the photos from the album I want to use to show up in the order that they are in the album?  When I tried to use the option to add my own photos instead of having the program "flow" them, they showed up all mixed up.

    iPhoto puts them in the book in chronological order.  So to get your photos from an album into an iPhoto book in the same order you will need to use the Photos ➙ Batch Change ➙ Date menu option and set them all to the same date with a 1 minute time difference between each. 
    OT

  • The display on my MacBook Pro from 2007 finally gave out, how do I transfer all the data from the old one onto my new one?

    A week or so ago, the screen on the Macbook Pro I've had for 5 years went permanently black. The screen itself still works, but it's just all black. Went from flickering/flashing to black. I didn't have any kind of warranty on it or anything, and in addition to all of the other things about it that needed fixing, it seemed like it'd just be cheaper to get a new Macbook Pro.
    My question is: How do I get all the stuff from the old laptop to the new laptop without having to use the old laptop's display? Is there a cable I can use to connect the two, and I can just access the old one from the new one?

    FireWire between the two (get appropriate 800-800 or 400-800), Target Disk Mode on the old one, appears as an external disk on the new one. Drag everything over, or use Setup Assistant if first start of new one, or plain old Migration Assistant. You really don't need a display to see a prancing FireWire icon, do you?
    http://support.apple.com/kb/HT1661
    http://support.apple.com/kb/HT4889
    (with the added advantage that since you ain't booting anything off the drive, can turn the Mac on or off at will without risking data corruption on the drive)

  • How can I copy all the comments from my picture/s in fotostream to my picture/s in my library?

    How can I copy all the comments from my picture/s in fotostream to my picture/s in my library?

    Hi, first, you should prevent the iTunes library auto sync with iPhone: Launch iTunes > click Preferences... > click Devices. In the window, check the option 'Prevent iPods, iPhones, and iPads from syncing automatically'. Next, connect your iPhone with your computer via the USB cable. Click the mini menu for iTunes on the very top left and click the option 'Show menu bar'. After then you can see iTunes File, Edit, View, Control, Store and Help menus on the ribbon. Click File > Devices > Transfer purchases from (your iPhone name). You can also access to the File menu by holding down Alt (Option on Mac), Shift and F keys. This is how to get your iPhone purcahsed song transferred to iTunes Library.

  • How do I move all the photos from the i-photo library on one account to the i-photo library on another account?

    I have recently bought a new mac mini running Lion, and yesterday I migrated an account off an older machine running Tiger.
    I want to delete the older account from this machine as it is causing some problems with i-cloud, but I want to transfer the photos first and add them to a different account on the new computer.
    So my question is How do I move all the photos from the i-photo library on one account to the i-photo library on another account?

    Copy the iPhoto library from the old Mac to the Desktop of the new one.  Then download the paid version of  iPhoto Library Manager, which is now compatible with Mt. Lion, and use it to merge the two libraries into a new, third library.  This will preserve the two libraries in case the merged library isn't to your liking. 
    Here are screenshots of iPLM's coping and merging preferences:
    When you're satisfied that the new, merged libraray is complete and working OK you can delete the two earlier libraries.
    OT

  • How do I get all the songs from an album to show in the album view?  Currently, if an album lists the artist plus a guest artist, those are shown separately and appear to be two different albums on my iPod.  How do I get all the songs on that album togeth

    How do I get all the songs from an album to show in the album view?  Currently, if an album lists the artist plus a guest artist, those are shown separately and appear to be two different albums on my iPod.  How do I get all the songs on that album together on my iPod?  If the album is a collaboration wtih many artists, each sond may appear as a separate album.

    I used to have this problem.
    First, you need to go back on iTunes
    you need to go to each of the songs that are having this problem
    Click the album so all the songs drop down
    Right click the songs that have this problem
    Click ' Get info '
    Click the tab that says " info '
    The box that says ' album artist ' should probably be empty (correct me if I'm wrong)
    Click it and type the artist of the entire album, NOT the songs guest artist
    as such,
    ARTIST
    JAY-Z Feat. Justin Timberlake
    ALBUM ARTIST
    JAY-Z
    These should be separate for each artist
    If you write the same album artists for each song by that artist, all the songs should be on 1 album

  • How do I put all the songs from a compilation album into the same /album/folder in Itunes v12

    How do I put all the songs from a compilation album into the same /album/folder in Itunes v12 i know in other versions it was via get info but as all of the tunes have the same album title , I am not sure what tio change to achieve this ?

    I don't see your screenshot but I assume you're starting with something like this, i.e., the compilation split into multiple albums:
    If you select all the items that you want to be in a single album, right-click > Get Info you'll see this:
    As you say, in iTunes 12 you don't see a field to enter a distinct Album Artist value.  You can, however, address this by clicking the Add Field button and selecting Album Artist:
    That makes the field available in the metadata dialog so that you can enter the required value:
    You can also show the pre-iTunes 12 version of the dialog by holding the SHIFT key when selecting Get Info - this allows you to enter the Album Artist directly:

  • How can I turn off the sound from the original midi  or audio tracks when I turned on the duplicate tracks for editing ?

    How can I turn off the sound from the original midi or audio tracks when I edit or listen to the duplicate tracks in Logic Pro 9 ?
    I'm using iMac desktop with Mac OS X Version 10.7.3. Pls advise.

    Dan,
    It sounds like one of your preferences has changed.
    Go to preferences > audio > general, and make sure "track mute/solo" is set to "CPU saving (slow response)". It is probably set to "Fast " at the moment.
    This setting (fast) basically causes immediate muting from the channel strip while your song is in play. This is because the audio is still being read from the hard drive, but the channel strip is simply muted.... like a hardware mixer. When set to "CPU saving", the audio from that track, when muted, is actually stopped from streaming from the hard drive, but there is a couple second delay before the audio is actually muted.
    One would think that the fast setting is generally preferable, except when you need to do what you are doing. The only way to keep duplicate copies of channel strips acting independent of one another is to leave this setting on the "CPU saving" setting.
    Hope that helps

  • How can I delete all the email from a user's account?

    I have a user account with a huge amount of mail (around 50K messages) that Apple Mail can't deal with... it constantly hangs and/or crashes whether I use POP or IMAP to try and delete all the mail from the client.
    How can I delete all the mail from the mailbox on the server? I don't want to delete the account entirely, I just want to empty everything out of it.
    Thanks!

    sudo -u _cyrus /usr/bin/cyrus/bin/ipurge -d 0 -f user/mailboxname
    HTH,
    Alex

  • How can i get all the users from weblogic server?

    how can i get all the users from weblogic server?
    i have configurated a LDAP server using iPlanet and
    in weblogic server console i see those users from LDAP
    server. but how can i get all the users in my program
    from weblogic server instead of LDAP server?
    BTW,how to configure a RDBMSAuthenticator and what should i do
    in Oracle? which tables should i create? and how are their architectures?
    Thanks
    Daniel

    BTW, i use weblogic platform 8.1
    "Daniel" <[email protected]> дÈëÓʼþ
    news:[email protected]..
    how can i get all the users from weblogic server?
    i have configurated a LDAP server using iPlanet and
    in weblogic server console i see those users from LDAP
    server. but how can i get all the users in my program
    from weblogic server instead of LDAP server?
    BTW,how to configure a RDBMSAuthenticator and what should i do
    in Oracle? which tables should i create? and how are their architectures?
    Thanks
    Daniel

Maybe you are looking for

  • BDC PROGRAM

    Hi to all I'm new to BDC Progaram can u tell me how to write a BDC program to upload purchase order data from legacy system.

  • How do I download to save info?

    I am sending my broken unit (under warrenty) in for replacement. They said to back up files. How do I do this? Thanks, HM

  • DBMS_XMLGEN - Nested Objects

    Hi! I have to generate complex XML Documents. I tried already the SQLX Functions and everything works fine. Now I try the same with DBMS_XMLGEN to compare XML generating performance. -- Objects CREATE OR REPLACE TYPE dept_type AS OBJECT ( DEPTNO NUMB

  • What causes 'Unexpected end-of-file' error?

    Hi, I am a photographer and an avid Lightroom user. I have two camera's (Nikon D700 and D300) and two computers, a desktop PC and a MacbookPro. Lightroom is installed on both computers. For the last three photoshoots I have had this problem where 1 i

  • Photoshop Elements & computer upgrade

    I am running photoshop elements on a Pentium 4 box with 1TB hard drive.  I just built a I5-3570 machine with 256GB SSD and a 1TB hard drive, and will move the old 1TB drive to the new machine. I would like to install PSE 11 on the SSD and have the ph