# AS3 Classes and MXML... difficulty seeing relationship

**URL:** <https://forum.kirupa.com/t/as3-classes-and-mxml-difficulty-seeing-relationship/267845>\
**Category:** flash\
**Created:** [August 6, 2008, 1:02pm UTC](https://forum.kirupa.com/t/as3-classes-and-mxml-difficulty-seeing-relationship/267845 "2008-08-06T13:02:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![grandpaw\_broon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/grandpaw_broon/32/3985_2.png) [@grandpaw\_broon](https://forum.kirupa.com/u/grandpaw_broon)\
**Post date:** [August 6, 2008, 1:02pm UTC](https://forum.kirupa.com/t/as3-classes-and-mxml-difficulty-seeing-relationship/267845/1 "2008-08-06T13:02:59Z")

</div>

Hi all,

I have just been creating Actionscript 3 Projects in Flex for the last year and i moved over to AIR last week but i guess this question is general Flex.

Im having some difficulty with the relationship between custom classes and MXML layout.

For example, say i have a simple class called Square which extends Sprite and creates a box on screen which tweens through colors… It contain a public method “stop()” to stop the color cycle on the box. (as simple as i could think of).

I am unsure how to use this custom class in my Flex or AIR application. In a perfect world id just like to say

\<Square width=“100” height=“100” click="{this.stop()}" /\>

Or something to that nature but this wont work as my AS3 class is not a MXML component for use with Flex Builder…

I next thought that with Flex for display objects, id need to create custom components… based on Canvas. Then id put all of my Square.as class code into its \<Script\> tags? Is this the right idea?

I get confused again with this approach though because how do i access my stop() method now that it inside a custom MXML component? Does my Square Component now have some kind of a stop() method available to MXML and if so, how do i call it?

I am the first person to google and search before hand but on this occasion, i dont know what keywords to search for.
