# Access movieclip on stage?

**URL:** https://forum.kirupa.com/t/access-movieclip-on-stage/258471
**Category:** Uncategorized
**Created:** [April 24, 2008, 10:22am UTC](https://forum.kirupa.com/t/access-movieclip-on-stage/258471 "2008-04-24T10:22:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bobohob](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@bobohob](https://forum.kirupa.com/u/bobohob)
#### Post date: [April 24, 2008, 10:22am UTC](https://forum.kirupa.com/t/access-movieclip-on-stage/258471/1 "2008-04-24T10:22:11Z")

</div>

I have a movieclip on stage, named “book1”.

Now I have a class called “Shelf” (it’s NOT a document class). Here it is :

```php
package{
  import flash.display.Sprite;
  import flash.display.MovieClip;

  public class Shelf extends MovieClip {
    public function Shelf {
      // .... How do I access book1 on stage ?
    }
  }
}

```

How do I access “book1” movieclip on stage from Shelf class ?

Thanks.

---

<div class="post-metadata">

### Author: ![rahul\_7star](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@rahul\_7star](https://forum.kirupa.com/u/rahul_7star)
#### Post date: [May 20, 2008, 6:44am UTC](https://forum.kirupa.com/t/access-movieclip-on-stage/258471/2 "2008-05-20T06:44:54Z")

</div>

[quote=x0b;2317812]it looks like you aren’t saving the class in the right place, make sure it is called Main.as

I still couldn’t get this to work though, I get ‘1120: Access of undefined property ro.’ error. I have made a movieclip with the instance name ‘ro’ and placed it on the stage.

I really need to understand how this is done too, someone please help :)[/quote]

make a movie clip on the stage and name it “ro” and save as w.fla

and in tha same directory make Main.as and write this code  
package {  
//…imports and stuff

import flash.display.MovieClip;  
import flash.utils.Timer;  
import flash.events.TimerEvent;

public class Main extends MovieClip {

/\*\*

- Constructor  
\*/  
public function Main() {  
var spinTimer:Timer = new Timer(10);  
spinTimer.addEventListener(TimerEvent.TIMER, timerHandler);  
spinTimer.start();  
}

/\*\*

- Timer Event handler to spin the movieclip  
\*/  
public function timerHandler(event:TimerEvent):void{  
ro.rotation+=3; ///// ro is the name of movie clip on stage

}  
}  
}

now in Fla write “Main” in Document class and save and run

---

<div class="post-metadata">

### Author: ![dail](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@dail](https://forum.kirupa.com/u/dail)
#### Post date: [May 20, 2008, 9:11am UTC](https://forum.kirupa.com/t/access-movieclip-on-stage/258471/3 "2008-05-20T09:11:16Z")

</div>

You have a couple of options.

You can pass in a reference to the movieClip to your class. Or if your class is added to the display list, you can access elements on the stage through either the parent or root properties.

```auto
package{
  import flash.display.Sprite;
  import flash.display.MovieClip;

  public class Shelf extends MovieClip {
    private var bookRef:MovieClip

    public function Shelf (bookRef:MovieClip){
     bookRef.doSomething()
      // .... How do I access book1 on stage ?
    }
  }
}

```

This is a good article about developing for the display list: [http://developer.yahoo.com/flash/articles/display-list.html](http://developer.yahoo.com/flash/articles/display-list.html)

[QUOTE=bobohob;2317251]I have a movieclip on stage, named “book1”.

Now I have a class called “Shelf” (it’s NOT a document class). Here it is :

```php
package{
  import flash.display.Sprite;
  import flash.display.MovieClip;

  public class Shelf extends MovieClip {
    public function Shelf {
      // .... How do I access book1 on stage ?
    }
  }
}

```

How do I access “book1” movieclip on stage from Shelf class ?

Thanks.[/QUOTE]
