Access MovieClip in the stage

Hello,
I am using the ActionScript 3 in a aplication and i have
problem to access the MovieClips that is on the Stage. Let me
explain.
I the stage i have two MovieClips, with instance of mc1 and
mc2. Inside of mc1 i try to access some proprerties from mc2 but
without success.
I try using this:
trace(parent.mc2.width);
But the Flash return the error 1119, undefined propertie.
So, how can i access the MovieClips that is on my stage from
another MovieClip.
Thanks

:

Similar Messages

  • TypeError: Error #1006 - Removing MovieClip from the stage

    I have a movie clip that is called to the stage and once the movieclip is finished it calls a function that removes it from the stage. The code works but I get an error message about 4 seconds after the movie clip ends.
    Here’s the error message:
    TypeError: Error #1006: exitWordMicroscopic is not a function.
                    at ASvocabulary_microscopic/frame110()[ASvocabulary_microscopic::frame110:1]
    Here’s the stage code:
    //************************Removes the movieclip from the stage and enables the button.*************************
    function exitWordMicroscopic():void
                    bnt_vocab_microscopic.mouseEnabled = true;
                    removeChild(word_Microscopic);
    //******************************Stage buttons**************************************
    stage.addEventListener(MouseEvent.MOUSE_DOWN, goButtonsHomeRead_1);
    function goButtonsHomeRead_1(event:MouseEvent):void
                    //Vocabulary buttons
                    if (event.target == bnt_vocab_microscopic)
                                    bnt_vocab_microscopic.mouseEnabled = false;
                                    SoundMixer.stopAll();
                                    addChild(word_Microscopic);
                                    word_Microscopic.x = 47;
                                    word_Microscopic.y = 120;
    Here’s the code inside the movie clip. This is what the error message is referring to:
    //****************** Calls function to remove itself from the stage****************************
    Object(parent).exitWordMicroscopic();
    What am I doing wrong?

    Here' how the code looks now:
    Objective: To remove the current movieclip while it's playing so that it does not show on the next (or previous) frame.
    Here’s the stage code:
    var word_Microscopic:ASvocabulary_microscopic = new ASvocabulary_microscopic();
    //Removes the movieclip from the stage and enables the button.
    function exitWordMicroscopic():void
        bnt_vocab_microscopic.mouseEnabled = true;
        removeChild(word_Microscopic);
    //******************************Stage buttons**************************************
    stage.addEventListener(MouseEvent.MOUSE_DOWN, goButtonsHomeRead_1);
    function goButtonsHomeRead_1(event:MouseEvent):void
        //Vocabulary buttons
        if (event.target == bnt_vocab_microscopic)
            SoundMixer.stopAll();
            bnt_vocab_microscopic.mouseEnabled = false;
            addChild(word_Microscopic);
            word_Microscopic.x = 47;
            word_Microscopic.y = 120;
            word_Microscopic.play();
    //This button takes the user to the Main Screen
        if (event.target == bnt_ReadGoHome_1)
           // exitWordMicroscopic(); [If I use this function I get this error ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.]
            SoundMixer.stopAll();
            gotoAndPlay("1","Main");
            stage.removeEventListener(MouseEvent.MOUSE_DOWN, goButtonsHomeRead_1);
    //This takes the user to the next frame.
    if (event.target == GoNext_1)
            SoundMixer.stopAll();
            gotoAndPlay("2");
            stage.removeEventListener(MouseEvent.MOUSE_DOWN, goButtonsHomeRead_1);
    Here’s the code inside the movie clip.
    //****************** Calls function to remove itself from the stage****************************
    Object(parent).exitWordMicroscopic();

  • Dynamically loaded swf to communicate with MovieClip on the stage

    I have a heck of time here with an issue. I have an xml document that when a certain button on the stage is clicked it loads it's corresponding external swf into an empty movieclip on the stage. This empty movie clip is a holder for all external swfs.
    So what I'm trying to do is when an external swf is loaded that has buttons on it, I need those buttons to communicate with the main timeline and remove a mc that is on the Stage. I need the currently loaded swf(s) to be able to do this. So whatever the currently loaded external swf is that's loaded, I need it to talk to the main timeline. (I have quite a few external swfs that need to do this) So I imagine I need to somehow target the currently loaded external swf to get it to talk to the main timeline.
    The code below in summary doesn't work but it doesn't give errors either. I don't pretend to know what I'm doing and I haven't been successful in searching for a solution to this particular issue. If someone could give me guidance or direct me to a solution. I'd so much appreciate it.
    // main timeline object
    var index:Object=this;
    function loadComplete (e:Event) {
            TweenMax.to(index.mcholder,1, {alpha: .5});
    // add the current module to the mcholder movieclip by using addChild
            index.mcholder.addChild(e.currentTarget.content);
           (e.currentTarget.content as MovieClip).addEventListener("eventTriggered", startListener);
    function startListener(e:Event):void {
    var ext_swf:MovieClip;
    ext_swf = e.currentTarget.content as MovieClip;
    trace("external swf");
    ext_swf.button1.addEventListener(MouseEvent.CLICK, talktomainswf);
    function talktomainswf():void {
    TweenMax.to(index.mc_thatsonthestage, 1, {x:1000});
    // now we have the first load we set firstLoad to false
            index.firstLoad = false;
        function loadError (e:Event) {
            trace("error");

    You can use the event dispatcher to communicate between external swfs and a main timeline,
    like so:
    //in an external swf
    //Once loaded
    function onLoadComplete(event:Event):void
         //dispatch an event in the form of a string
         dispatchEvent(new Event("Talk to Main Timeline")); 
    //On the Main timeline
    //listen for "Talk to Main Timeline"
    stage.addEventListener("Talk to Main Timeline", listenForCallsFromExternalFiles, true);
    //if the event is heard, do this:
    function listenForCallsFromExternalFiles(e:Event):void
         trace("I heard ya, now do stuff...");
    That's the basic idea anyways, I use it all the time.
    hope that helps,
    ~chipleh

  • Accessing things on the stage

    I have a movie clip on the stage. In the main .as file, I can
    easily access the instance i.e., myMovieClip_mc.x = 10;
    How do I do that from a class in my "classes" package? I am
    passing the stage instance into the constructor of the class, so I
    would think something like myStage.myMovieClip_mc.x = 10 would
    work, but it comlains that it is null.
    thanks

    Are you using a document class?
    In your example, is myState null or is just
    myStage.myMovieClip_mc null?

  • 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

  • Placing movieclips on the stage

    Hello,
    I am trying to place movieclips from the librari on the stage
    but i only get one row.
    This is wat i want to archieve. (for example M = a
    movieclip).
    M M M M M M
    M M M M M M
    M M M M M M
    M M M M M M
    If i also fill in the _y the result looks like this.
    M
    .. M
    ..... M
    ........ M
    ............. M
    now it looks like this:
    M M M M M M
    This is the code i used:
    var tegelhouder:MovieClip =
    this.createEmptyMovieClip("tegelhouder",
    this.getNextHighestDepth());
    tegelhouder._x = -70;
    tegelhouder._y = 0;
    for(i=1; i<9; i++) {
    tegelhouder.attachMovie("tegelanim", "tegels"+i, i);
    tegelhouder["tegels"+i]._x = i*70;
    So the first thing i am trying to archive is to place the
    movieclips vertical as horizontal.
    Can someone help me with this?
    Regards,
    Micheal

    //this is very simple
    //All is you need them in rows one by one
    //do this
    for (var a:Number = 1; a<=30; a++) {
    attachMovie("dd", "dd"+a, a);
    //if you want them in 5 clips in a row then
    trace(a%5);
    if (a == 1) {
    // to place the first one at some point
    _root["dd"+a]._x = 100;
    _root["dd"+a]._y = 100;
    } else {
    if (a%5 == 1) {
    _root["dd"+a]._y =
    _root["dd"+(a-1)]._y+_root["dd"+(a-1)]._height+2;
    _root["dd"+a]._x = 100;
    } else {
    _root["dd"+a]._y = _root["dd"+(a-1)]._y;
    _root["dd"+a]._x =
    _root["dd"+(a-1)]._x+_root["dd"+(a-1)]._width+2;
    Hope you enjoy

  • Removing a movieclip from the stage after a set amount of time (or once it's finished its animation)

    I've got a movieclip animation which is added to the stage at the start of the .swf.  Its an introduction to the game, and the user is encouraged to click on the movieclip to start the animation.
    Once the animation is finished I'd like the movieclip to be removed from the stage.
    How do I go about doing this?  Do I need to setup some sort of event handler which listens out if the movieclip has finished then start a function once its finished to remove it from the stage?  Which methods look out for movieclips finishing?
    Cheers

    there is no specific event that's called when a movieclip stops playing,
    what you could do is inside your intro movieclip  dispatch an event as soon as the animation is finished
    something like ... dispatchEvent(new Event("introFinished");
    and all you have to do is add and event listener to the intro movieclip intro.addEventListener("introFinished", onIntroFinished);
    when your onIntroFinished is called you can remove the intro from the stage.

  • 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.

  • How to tell who is on the Stage?

    How can I tell which movie currently is on the Stage, to be
    able to remove
    it?
    For example, I have 3 buttons on the stage:
    button "Banana"
    button "Apple"
    button "Orange"
    When I press "Apple", the movie clip "ApplePie" is attached
    to the movie
    container on the stage:
    _root.Banana.onRelease = function(){
    _root.MovieContainer.attachMovie("ApplePie","ApplePie",1,
    {_x:0, _y:0});
    Now, if I press Orange, I want to remove previous movie clip
    from the stage
    and attach new - "OrangePie".
    But how can I know what movie clip is currently on, to be
    able to remove it?
    I may have 50 buttons, and I can't know which of them was
    pressed
    previously..
    Any ideas?
    Thanks in advance,
    B.

    Thanks :)
    I didn't know that loading another movie would remove
    previously loaded..
    "Rob Dillon" <[email protected]> wrote in message
    news:fv4gou$bi3$[email protected]..
    > You can create a variable to hold the name of the
    currently loaded movie.
    > If you only need one movie on the stage at any time,
    then just have one
    > movieClip on the stage that you load the others into.
    >
    > If as in your example code, everything is loaded into a
    clip named
    > MovieContainer, then you don't need to unload the
    current movie. Loading a
    > new
    > movie into the same movieClip will remove the current
    movie by default.
    >

  • Access movieclip from class

    Hi,
    I would like to tell a movieclip on the stage to be visible from a class.  Is that possible?

    if that class has a reference to a displayobject, yes.

  • 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();

  • Access movieclip on stage from class?

    Hi all,
    Is it possible to access a movieclip which has been dragged onto the main stage in my FLA from an external class that i've written? Can i create a variable that refers to the object on the stage? Or does it have to be added dynamically to be accessible?
    Many Thanks
    Matt

    Hi Ned, i'm not instantiating it as such i'm just using it to store quite a large method which is being called from the document class.
    I'm trying to break all my code down into chuncks stored in .as files so that i dont have 2,000 lines of code all in frame one of the main timeline : S
    So this is my document class:
    package  {
              import flash.display.MovieClip;
              import loadXML;
              public class mainClass extends MovieClip {
                        public function mainClass () {
                              loadXML.importXML();
    then this is the class being called from the mainClass:
    package  {
              import flash.display.Stage;
              import flash.net.*;
              import flash.events.ProgressEvent
              import flash.events.Event;
              import flash.text.*;
              public class loadXML {
                        private static var myXML:XML;
                        private static var myLoader:URLLoader = new URLLoader();
                        public function loadXML() {
                        public static function importXML():void{
                                       myLoader.load(new URLRequest("pipeLineData.xml"));
                                       myLoader.addEventListener(Event.COMPLETE, processXML);
                        private static function processXML(e:Event):void {
                                       myXML = new XML(e.target.data);
                                       objectOnStage.text = myXML.TEXT[0];
                                       //etc...
                                       //etc...
    Many thanks
    Matt

  • 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");

  • Accessing the stage variable problems in AS 3.0

    Hi. Quick question...I'm trying to access the stage variable
    which I believe is supposed to be global and I should be able to
    access it from any class. Is this true? The compiler is complaining
    that it doesn't recognize this variable? Note that these objects
    have not been added to the stage yet but still, these are compile
    time errors, so why is that I'm getting these errors?
    Thanks,
    Sam

    Sam,
    > Actually, this doesn't have to do with that question.
    > Basically, the compiler is complaining that it doesn't
    > recognize the stage variable.
    It complains about the DisplayObject.stage property? Are you
    referencing it in conjunction with a DisplayObject instance?
    > This is weird because in my AS 3.0 book, I see that
    > the stage variable is being accessed without
    instantiating
    > it or retrieving it.
    What book is that? I might have it, then I can see what
    you're seeing.
    > I am extending Sprite in all my classes.
    Yeah, Sprite extends DisplayObject, by of InteractiveObject,
    then
    DisplayObjectContainer, so it certainly is entitled to the
    stage property.
    Let me know what book you're looking at, and if I don't have
    it (and if
    you're still interested), I'll try to recreate a simplified
    proof of concept
    on this end.
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • How can I search the stage for a given Movieclip and then add all instances of it to an Array? AS3

    I would like to Add multible instances of one Movieclip, (Library Name = Bats | instance name = none), inside of another Movieclip (instance name = back.visuals) // (By HAND) NOT by addChild(mc_name); // Easy
    If anyone could help me out with code to do the next steps:
    Search the Movieclip, (instance name = back.visuals), that contains the Movieclips, (Library Name = Bats | instance name = none), manually added to the stage by hand.
    Then for all instances of this movieclip (Library Name = Bats | instance name = none) add them to an Array.
    Thank You,
    Dyami

    I think we are having some missed communication. I do not wish to Change Flash's IDE or deveolp new features for flash. I was wondering if there was a way to do my question with AS3. something along the lines of :
    var enemyList:Array = new Array;
    for (var index:int = 0;index < back.visuals.numChildren;index++)
        var wall:MovieClip = back.visuals.getChildAt(index) as MovieClip;
    /* Check to see if wall is of a Specfic MovieClip */
    /* if (Above is True){ enemyList.push(wall) };

Maybe you are looking for