There is another way of doing it as well, FYI, that doesn't use the delegate class. You can take advantage of the fact that handler functions can see local variables and use a local variable to make reference to the class. The line:

        var parent = this;
        (or fully typed, var parent:MyClassName = this;)

allows you to store a reference to the class instance. You can then reference any method or property by just calling parent.methodName() or parent.propertyName from within your handler functions.


private function doFade():Void{
        var parent = this;
        container_mc.onEnterFrame = function(){
                this.fader_mc._alpha-=faderSpeed;
                if(this.fader_mc._alpha <= 0){
                        this.fader_mc._alpha=0;
                        parent.startTimer();
                        delete this.onEnterFrame;
                }
        }

        container_mc.onRelease = function()
        {
                parent.startTimer();
        }
}

Nathan
http://www.nathanderksen.com


On Feb 21, 2006, at 9:40 AM, Wouter Steidl wrote:

private function doFade():Void{
        container_mc.onEnterFrame = function(){
                this.fader_mc._alpha-=faderSpeed;
                if(this.fader_mc._alpha <= 0){
                        this.fader_mc._alpha=0;
                        Delegate.create(this, startTimer); <-- DOESN'T WORK
                        delete this.onEnterFrame;
                }
        }
        container_mc.onRelease = Delegate.create(this, startTimer); <--

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to