AS3 Classes and MXML... difficulty seeing relationship

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.