Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 553811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:38:39+00:00 2026-05-13T11:38:39+00:00

I want to extend my function to a better design to where I can

  • 0

I want to extend my function to a better design to where I can pass a canvas object into so I don’t have to write N functions.. I’m not sure as how to do this properly I’ve come up with a naive design with a switch but even then if I add another canvas I still need to write new code for the new canvas.

function fadeCanvasOut(event:TimerEvent):void
{ 
canvas1.alpha -= 0.1;
}

private function showForm():void
{
var myTimer:Timer = new Timer(20, 10);
myTimer.addEventListener("timer", fadeFormIn);
myTimer.start();        
}

what I need is something like:

function fadeCanvasOut(event:TimerEvent, aCanvas:Canvas):void
{ 
aCanvas.alpha -= 0.1;
}

private function showForm(aCanvas:Canvas):void
{
var myTimer:Timer = new Timer(20, 10);
myTimer.addEventListener("timer", fadeFormIn(timerEvent, canvas1);
myTimer.start();        
}

if someone could please enlighten me I would appreciate it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:38:39+00:00Added an answer on May 13, 2026 at 11:38 am

    If you’re using ActionScript 2, then I would look into using the Delegate class for this. It will allow you to change the scope of a method call. This will change your code to this:

    import mx.utils.Delegate;
    
    function fadeCanvasOut(event:TimerEvent):void
    { 
        this.alpha -= 0.1;
    }
    
    private function showForm():void
    {
        var myTimer:Timer = new Timer(20, 10);
        myTimer.addEventListener("timer", Delegate.create(canvas1, fadeCanvasOut);
        myTimer.start();        
    }
    

    If you are using ActionScript 3, Delegates are now built into the language (they removed the Delegate class, and made the element on which the event was fired the scope of the function call). This means that no longer can use you use the delegate class to change the scope to what you want. So you would now need to write it like this:

    function fadeCanvasOut(event:TimerEvent, aCanvas:Canvas):void
    { 
        aCanvas.alpha -= 0.1;
    }
    
    private function showForm():void
    {
        var myTimer:Timer = new Timer(20, 10);
        myTimer.addEventListener("timer", function(event:TimerEvent):void {
            fadeCanvasOut(event, canvas1);
        });
        myTimer.start();        
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to extend NSSlider class to have an output textfield appended to it.
I want to extend standard PDO class. So i have: namespace Example; class NewPDO
I want to extend the IEnumerable class but only for types that can be
I have a Django template that I want to extend in multiple places. In
I want to have a function defined in a superclass that returns an instance
I want to create a ruby gem that calls a c function I have
First of all, I do not want to extend a class. I would ideally
I want to extend a particular aspect of jQuery UI: https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.js Search in the
I want du extend my makefile.am with an option like this: This is the
I want to extend the Ajax functionality of JQuery for having advanced options and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.