# Can a class use a class?

**URL:** <https://forum.kirupa.com/t/can-a-class-use-a-class/261698>\
**Category:** Uncategorized\
**Created:** [May 30, 2008, 12:11am UTC](https://forum.kirupa.com/t/can-a-class-use-a-class/261698 "2008-05-30T00:11:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeancnicolas](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jeancnicolas](https://forum.kirupa.com/u/jeancnicolas)\
**Post date:** [May 30, 2008, 12:11am UTC](https://forum.kirupa.com/t/can-a-class-use-a-class/261698/1 "2008-05-30T00:11:09Z")

</div>

Hello,  
I have created a simple button class, to fire roll over and out states of a movie clip attached from the library.

However - I want to use a Tween engine to make my onRollOver events animate nicely.  
This causes my class to clash with my tween class!  
Is there any way around this??!!

```auto
class IndexClass extends MovieClip
{
    public function IndexClass()
    {
        this.onRollOver = this.over();
        this.onRollOut = this.out();
    }
    public function over()
    { 
        this.tween("_x",280,1,"easeoutSine");
    }
    public function out()
    {
        this.tween("_x",0,1,"easeinSine");
    }
}

```

Is my class code.  
So the ‘tween’ isn’t recognised by the class file, although it would if it were in the native actionscript code where the

```auto
#include "MC_tween.as"

```

is kept and initialised…

Any help out there! There’s always a way around!:stare:

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [May 30, 2008, 8:34am UTC](https://forum.kirupa.com/t/can-a-class-use-a-class/261698/2 "2008-05-30T08:34:37Z")

</div>

I don’t think you include “include” in a class file.

I think you main swf pulls in seperate classes and they communicate via the swf.

_shrugs_

---

<div class="post-metadata">

**Author:** ![jeancnicolas](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jeancnicolas](https://forum.kirupa.com/u/jeancnicolas)\
**Post date:** [May 30, 2008, 10:43am UTC](https://forum.kirupa.com/t/can-a-class-use-a-class/261698/3 "2008-05-30T10:43:12Z")

</div>

that’s right - but how can the class communicate to the tween class within the swf its been associated to?!

Im sure it’s a case of syntax … one minor line of code … … …

---

<div class="post-metadata">

**Author:** ![claudio](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@claudio](https://forum.kirupa.com/u/claudio)\
**Post date:** [May 30, 2008, 12:09pm UTC](https://forum.kirupa.com/t/can-a-class-use-a-class/261698/4 "2008-05-30T12:09:46Z")

</div>

First of all get the AS 2.0 version of that class.  
Then simply use the import statement inside your custom class.

```auto

import mc_tween_as2
class YourCustomClass extends MovieClip{
	//...
}

```

---

<div class="post-metadata">

**Author:** ![jeancnicolas](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jeancnicolas](https://forum.kirupa.com/u/jeancnicolas)\
**Post date:** [May 30, 2008, 2:36pm UTC](https://forum.kirupa.com/t/can-a-class-use-a-class/261698/5 "2008-05-30T14:36:42Z")

</div>

interesting …  
So let me get this right … \>  
inside MyCustomClass.as file I associate the class I wish to Import?  
So If im using a tween engine such as “lmc\_tween”.as:  
my root SWF

```auto
#include "lmc_tween.as"

```

MyCustomClass.as

```auto
import lmc_tween_as2
class MyCustomClass extends MovieClip{
//......
}

```

Is that what you’re saying? I don’t quite get, ‘get the AS 2.0 version of the class’ …

Thanks!
