Accessing display objects via the stage var

I'm passing a stage reference to my class, but when I try to
access a movieclip on the stage I get an error.
this gives me an error:
var mc = targetStage.myMovieClip;
Thanks!

var myClass = new MyClass (this.stage);
That would be the same thing, this.stage would refer to the
Stage instance. Each .swf has one Stage instance. In a Flash
project, the stage has one child, the MainTimeline instance.
MainTimeline is basically a big MovieClip, and it contains all your
objects, scenes and timelines you create in Flash.
So, if you instantiate from the main timeline itself (either
on a frame script or Document class) you are already inside
MainTimeline, which is what you want to pass along a reference to,
so you would pass in "this" as Colin said, or "root".
Colin mentioned that MovieClip(root) would work anyway; if I
understand he is referring to the fact that every DisplayObject
(such as MovieClips and SimpleButtons created in Flash) already
have a "root" property that usually refers to the MainTimeline
instance. However, your class "MyClass" does not extend
DisplayObject so there is no root property available, which is why
you need to manually pass in a reference to the root
timeline.

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 we can disable access to BOM via the Display Master Recipe (C203)?

    Hi Gurus,
    How we can disable access to BOM via the Display Master Recipe (C203)?
    Thanks!

    Hi Mae Baraquio  
    Have you tried screen variant to make it as display mode.
    please refer below document for your reference.
    Learning SHD0 with Example
    if you find any query kindly revert back.
    Thanks & Regards
    Sandeep Kumar Praharaj

  • Adding objects to the stage & acceessing stage properties - I'm a bit confused..

    Hi,
    I'm a little confused on two fronts regarding display
    programming:
    A. What the best way to add objects to the stage?
    B. How to access stage properties.
    I can do both of these when the project is an 'Action Script
    Project', but I'm having trouble when it is a 'Flex Project' (e.g.
    an MXML file). See the two attached files with questions included
    in the comment to see exactly what I mean.
    A. What the best way to add objects to the stage?
    =====================================
    In an action script project that extends Sprite I can just
    call addChild()
    In an MXML project I can add objects to the stage by first
    adding them to a UIComponent, then adding that to the stage.
    1. Is that the best way to do it?
    In this doc:
    http://livedocs.adobe.com/flex/3/html/help.html?content=05_Display_Programming_02.html
    it says that
    quote:
    Each SWF file has an associated ActionScript class, known as
    the main class of the SWF file. When Flash Player opens a SWF file
    in an HTML page, Flash Player calls the constructor function for
    that class and the instance that is created (which is always a type
    of display object) is added as a child of the Stage object. The
    main class of a SWF file always extends the Sprite class
    2. why cant I just add a sprite object direct to the stage
    without the UIComponent?
    3. What is the 'main class', and how can i get access to it?
    B. How to access stage properties.
    =========================
    In an action script project that extends Sprite I can just
    call trace(stage.framerate)
    But in an MXML file I cannot figure out how to access the
    stage properties.
    See the attached code for the things that I tried, but which
    didnt work.
    In the page:
    http://www.actionscript.org/forums/showthread.php3?t=140655
    It says
    quote:
    For stage access you have a couple of rules:
    * natively, only display objects have inherent access to
    stage
    * display objects only have a valid reference to stage if
    they're within the stage's display list (on the screen, after added
    to it with addChild)
    * The only display objects which immediately have access to
    the stage before the use of addChild (in their constructor) are the
    document/application class instance (root) and any instance from
    the library placed on the timeline (not created with AS).
    * Non-display object classes have to be passed or assigned a
    reference to the stage from another object which already has access
    to it - they cannot access it otherwise.
    4. How do I access the stage properties in the MXML project?
    5. I suspect this is related to the "main class", which I
    dont yet understand - is it?
    Sorry for the long post.
    cheers
    tom

    "tom saffell" <[email protected]> wrote in
    message
    news:gd7cm9$d1v$[email protected]..
    > Thanks Luigi - that helps a lot.
    > I hadnt seen the Flex 3 Developer Guide before - it's
    very useful.
    >
    > I now see that I can access properties of the
    application object directly
    > with
    > this.<property>.
    > However, the framerate property cannot be set by
    actionscript, only in
    > MXML (I
    > can set it in the <mx:application> tag). But I
    need to be able to set it
    > programatically, dependent on user input.
    >
    > 5. Is there a way around this?
    > 6. Can I set the stage's framerate to achieve the same
    outcome?
    >
    > I still dont understand why I cannot access the stage
    object. When I call
    > either
    this.stage or
    uic.stage * then I get
    quote:
    Cannot access
    > a
    > property or method of a null object reference.
    My understanding is
    > that I
    > can access the stage object via any display object on
    the display list.
    > I'm
    > confused about this bit..
    >
    > * - uic is a UIComponent that has been added to the
    display list (i think)
    > by
    > calling addChild(uic) from the AS3 within the
    application
    >
    > 7. How do I access stage properties in AS3 in an MXML
    project?
    http://www.adobe.com/livedocs/flex/3/html/help.html?content=05_Display_Programming_10.html
    It seems like possibly your real problem is that you're
    having trouble
    searching the Help effectively:
    http://flexdiary.blogspot.com/2008/07/getting-help-in-flex-builder.html

  • DropTarget check against all objects on the stage

    Hey all,
    Not sure the best way to do this.  I have a class we will call DropActivity, here is the code
    package com.activitycontrol
              import com.activitycontrol.DropCheck;
              public class DropActivity
                   // Constants:
                   // Public Properties:
                   // Private Properties:
                   private var _selectedClip:Object;
                        // Initialization:
                        public function DropActivity(/*selectedClip:Object*/)
                        // Public Methods:
                        public function set selectedClip(selectedClip:Object):void
                                  _selectedClip = selectedClip;
                        public function stopDraggingMe():void
                                       var dropCheck:DropCheck = new DropCheck();
                                       //dropCheck.checkAgainst = dropTarget.name; ///***********
                                       if (dropCheck.canBeDropped == true)
                                            _selectedClip.stopDrag();     
                        // Protected Methods:
    when the stopDraggingMe() method is called from another object (code shown below) I need to see all the objects on the stage to see what objects on the stage my currently selected movie clip is over and assign it to the dropCheck.checkAgainst method (that will be checked against an array to see if it can in fact be dropped, if so set the canBeDropped value to true and therefor run the .stopDrag() ).  I have read using root is not a good coding practice in AS 3.
    call to the stopDraggingme() mehod.
    private function setDown(event:MouseEvent):void
                             var droppedItem:DropActivity = new DropActivity();
                             droppedItem.selectedClip = this;
                             droppedItem.stopDraggingMe();

    No, I think I can use drop target, I just need to use it from the DropActivity class and not a document class. I just don't know how to use it from a non-document class.
    "and you need to loop through all displayobjects to see which have a positive hitTest with your dropped object, correct?"
    I am trying to say..... ok, what movie clip is currently under the one I have selected,  the drop activity class knows what object I have selcted as it is in the selectedClip variable.  so I need to find out what clip is under it ......... the light just came on!
    answer duh......dropCheck.checkAgainst = _selectedClip.dropTarget.parent.name;
    thanks a bunch kglad you have helped me out once again, you are the man. I might just have to buy you a beer one of these days.

  • Does anyone get the mouse lag with an external display connected via the display port?

    does anyone get the mouse lag with an external display connected via the display port?

    You don't describe the problem in great detail.  Is this the issue you are describing?
    https://discussions.apple.com/thread/4398076?start=0&tstart=0
    If so, then, "Yes."  I have the same problem.  Note that this isn't a tracking speed problem for me, it's a lag between my hand moving and the pointer moving on the external display.
    Andrew

  • Deleting objects from the stage

    Hi all,
    I've got some items on my stage that I'm removing with
    RemoveChild(). The items no longer show, however, as stated in
    LiveDocs, the item is not actually destroyed. This means any
    bindings/listeners created by that object are still in existence
    and are creating errors (Specifically, I'm getting "The supplied
    DisplayObject must be a child of the
    caller").
    LiveDocs mentions that if I want to actually delete an object
    from the stage entirely, I should use the "delete operator", but
    for the life of me, I can not find any documentation on the
    existence of such an operator. Any advice would be much
    appreciated.
    -Hob

    It IS ridiculously hard to find. Searcing Live Docs for
    delete oprator will turn up a slew of hits, but which is the right
    one?
    This is from old docs, but it is still valid:
    http://livedocs.adobe.com/flash/8/main/00001865.html
    Tracy

  • Positioning and temporarily hiding objects on the stage

    (Flash newbie here - bear with me...)
    I have two graphic objects on the stage overlapping each
    other. The first I was able to position to the document boundaries
    just fine. When adding the second object, however, the first object
    covers the boundaries so I cannot see them to align the second
    object.
    The question: Is it possible to temporarily hide an object on
    the stage so I can see the stage boundaries to position another? I
    don't see any options that will allow me to do this.
    Thx!

    there is a little colored square on each layer, to the right
    of the layer name, click that square on the layer that the first
    object resides, it will then just show an outline. click it again
    to bring it back. You can also click the first 'dot' next to the
    layer name, it will completely hide the contents of that
    layer.

  • Can't edit objects on the stage

    Hi,
    I'm stumped helping my colleague on the issue below so I'm logging this question.
    Issue: My colleague is trying to edit a slide but can't edit any of the objects on the stage. However, it works fine when I open the same project on my machine. Is there a setting on her machine that's causing the issue?
    In the screenshot below, check out Slide 2 (selected) notice how:
    in the thumbnail there are multiple objects (white image on the left, blue text caption in the center) on the slide.
    in the timeline multiple objects are available and selectable. All are set to be visible (the little "eye" isn't switched to off).
    when you look at the stage, the only things that we see are the background and a single button.
    The objects also appear fine in Preview.
    On the stage, can "phatomly" select objects, but she can't change the characteristics of them (e.g., change text in a text caption, resize object, move object).
    Screenshot:
    OS: Windows 7
    Captivate: v5.5 (running as Administrator)
    Background info:
    This project was initially created in an older Captivate version (4.0 or 5.0) and is now being edited/updated.
    Last week, my colleague was trying to edit the same project (using v5.0). When she clicked play on the timeline, her audio wouldn't play. When she watched the Preview or tried to edit the audio, the audio would play just fine. Also, on my machine (running v5.5) it worked fine. This prompted me to suggest that she update to v5.5. Alas, it seems this fixed the audio issue, only to create this video issue.
    Thanks,
    - Dino

    Here's a bigger/better quality image. I hope it helps.
    Notice how the Text Caption is selected in the timeline and it's properties are visible on the right. Yet the item itself is nowhere to be seen on the stage. Also, now it seems to have disappeared from the thumbnail.

  • Duplicating the motion of an object across the stage

    Suppose I have a single moving object on the stage is it possible to replicate the object at regular intervals across the stage WITH the motion?

    Is this motion achieved through actionscript or is it a tween on the stage? If this is a tween on the main timeline on the stage, then you could make that animation a movieClip and play the movieClip at an interval, maybe using a timer. If the animation is achieved using actionscript then write the animation as a function and call the function at an interval, again, possibly using a timer.

  • HT204053 hi there. my phone was stolen and i have heaps of notes that i need to access, but i'm not able to access my notes via the cloud, any tips on how to do this? thanks

    hi there. my phone was stolen and i have heaps of notes that i need to access, but i'm not able to access my notes via the cloud, any tips on how to do this? thanks

    i'm not able to access my notes via the cloud
    If your notes sync with your icloud account, you can access them at www.icloud.com

  • Hide objects outside the stage

    Hi there!
    I have recently downloaded a sample FLA file and I see the stage is FIXED on top-left side of the flash screen and objects outside the stage does not appear on screen (Like a mask, but there is no mask layer).
    And when I create a new file the stage appears in middle of the screen and objects outside the stage are not masked.
    Would you please help me what should I do in this case?
    (I always use a very big White layer in top of all other layers, to cover out of stage, OR use a mask layer)
    Regards,
       Ali

    Hi!
    Sorry if my question was not clear. here is the link (adobe TV):
    http://downloads.tv.adobe.com/2012-00-24/WebChallenge_FL_3.zip
    I have uploaded that single FLA file to the address below :
    http://www.howallah.com/Mobile.fla
    To simplify my question, each flash scene is indeed divided into 3 sections based on colors (white, light grey, dark grey) as marked below :
    (the Zoom is 20% to cover them all).
    Section 1.  is called Stage (I know)
    Section 2.  it expands automatically as you move an object outside the stage (image, movieclip etc.) and it works like a mask (I dont know the name of this section)
    Section 3.   is something like "out of Scene" (I don't know the name of this section as well)
    What I want to do is sort of FITTING Section 1 (Stage) to Section 2.
    Exactly like the FLA sample file above.
    What is that good for?? to help me only see the stuff INSIDE the stage, without any need to make a mask layer or a LARGE white layer above all layers etc.!
    Anybody knows what I am talking about and having a clue please?
    Regards,
       Ali

  • Access object on the stage using an as3 widget

    I am trying to use a FlashPro as3 widget and Captivate 6, to toggle an image on the Captivate stage (hide/show) and can't find enough information on how to access the stage objects.
    I can use 
    var numKids:int = parent.parent.parent.numChildren() 
    to see the number of children (of the stage object?) , but can't seem to figure out how to hide or show the child objects (image, button or anything).
    My image names in my Captivate Project are Img_Einstein1 and Img_Einstein2.  They reside on a blank slide along with two buttons and another widget.
    I have looked at Tristen's web site and found a lot of useful information, but I guess I am just not putting it all together.  Because I am a contractor I can't use the Widget Factory or purchase outside widgets.
    Any help will be greatly appreciated!

    On 6 you don't have shared actions yet. I don't understand the explanation with 20 and 10. There are several examples of toggle buttons on my blog. For showing/hiding here a simple one:
    http://blog.lilybiri.com/blog-after-posterous-clickclick

  • Importing objects onto the stage

    I'm not really sure how to put  this, so I hope someone understands...
    Basically, is there a way to export an object from 3DS Max, and then  import it into Director onto the stage? Say, I create an object for a  user and export it, would the end user then be able to place the  exported object into a folder on their computer, "press a button" (with  some magical code involved) and have that object be imported onto the  stage at a specific location?
    I'm not looking for a walkthrough (at the minute!), I just wanted to know if it was possible. If it's not, does anyone have any idea of how it would be possible, if at all?
    Thanks for any help!

    Yes, it is possible.
    You might import their W3D as a cast member then cloneModelFromCastmember, or use loadFile on an existing W3D member. In either case you need an existing W3D castMember displayed on the stage as a sprite.

  • When accumulating objects on the stage, they start to disappear

    I have three windows containing a total of 33 panes. The
    panes each have a different graphic in them. I start with blank
    panes and fill one pane at a time until all the panes appear.
    Each pane is on a transparent gif with the same dimensions as
    all the other gifs. I put the panes on the stage one at a time, in
    separate layers and leave them there until the end of the show.
    When I get part way through, it gets sluggish and objects
    start disappearing. It works fine in the fla file but not the swf.
    A rough working-version of the swf file is
    here. This one
    only works because I inserted intermediate "screen shots" to make
    it work.
    I am sorry that I cannot upload the source files at this time
    (restriced access from office server) but can provide them later
    today, if necessary.
    Could it be that I have too many items that collect on the
    stage?
    Any guidance would be appreciated. Thanks in advance!

    You can find the source code and SWF file
    here.

Maybe you are looking for

  • Can't Get Group Wiki to Work

    Ok, I have everything setup according to the docs and still can't get the group wiki to work. - OD Master - Web Services for the domain, Group Wiki checked on - Group applied to Wiki - Group granted Wiki access in WGM for this domain So, I navigate t

  • Mouse cursor appearing as an arrow instead of a hand over album links

    Hi. I've just published my iWeb 08 site on .Mac (using Zone Edit to set up the CNAME for my personal domain, purchased from Last Digital). For some reason, when I hover over the links in the My Albums page, the mouse cursor appears as an arrow instea

  • No sessionstore.js in ~/.mozilla/firefox/*/

    Hi, I lost all my open tabs in firefox. Again! It is so easy to do. Open another instance and close the first one before the second and it's all gone. After some googling I discovered that there should be a sessionstore.js file in ~/.mozilla/firefox/

  • How to set portal context using Java/JPDK api.

    Hi, I am in the process of converting pl/sql based database provider contect portlets to Java based JPDK. I ran into issue where the database provider portlet users were getting context auto matically. Now with Java/JPDK portlets , I am receiving no

  • How to run Indesign on ten journalism computers affordably in public high school?

    We get money every five years for new software. For our school news paper and yearbook we have $2,000 every five years. That equals $200 a copy for software per machine (we use 10 computers for newspaper editors and yearbook staff). Under current ado