Sébastien,

You can't instantiate MovieClips with the new operator.  You need to use
attachMovie() to get it to work.

Doing this simply wont work:

var cow:MovieClip = new Cow();

In order to use attachMovie though, you will need to get the linkage ID set on
your class.

Here is how I would do it using the cow class the Jesse provided:

class your.package.Cow extends MovieClip
{
        public static var symbolName:String = "__Packages.your.package.Cow";
        public static var symbolOwner:Function = Cow;
        public static var symbolLinked = Object.registerClass(symbolName,
symbolOwner); 
        
    function Cow()
    {
        _alpha = 50;
    }

    function onRollOver()
    {
        trace("onRollOver");
        _alpha = 100;
    }

    function onRollOut()
    {
        trace("onRollOut");
        _alpha = 50;
    }
}

//now you can create the cow instance from your application like this:

public function createCow():Void {
        var mc:MovieClip = _root.createEmptyMovieClip("cow",
_root.getNextHighestDepth());
        mc.attachMovie(your.package.Cow.symbolName, "cow",
mc.getNextHighestDepth());
}

You could use any MovieClip to do this instead of using _root.

You can see more info on use the __Packages trick to get the linkage ID on Peter
Hall's website: 
http://www.peterjoel.com/blog/?archive=2004_01_01_archive.xml

I hope that helps.

-Chris

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Sébastien Pierre
Sent: Monday, July 25, 2005 11:06 AM
To: Open Source Flash Mailing List
Subject: Re: [osflash] How to properly handle rollOver and rollOut inMovieClips


Le 25 juil. 05 à 16:32, JesterXL a écrit :

> class Cow extends MovieClip
> {
>     function Cow()
>     {
>         _alpha = 50;
>     }
>
>     function onRollOver()
>     {
>         trace("onRollOver");
>         _alpha = 100;
>     }
>
>     function onRollOut()
>     {
>         trace("onRollOut");
>         _alpha = 50;
>     }
> }
>

This would be great, but sadly I can't get to properly instantiate my  
own specialized MovieClips with MTASC... Do you have a complete  
working example that does so ?

TIA,

  -- Sébastien


_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

Reply via email to