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

  • SEARCH
  • Home
  • 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 616003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:16:49+00:00 2026-05-13T18:16:49+00:00

I have found some code that uses the virtual keyword for functions, like: package

  • 0

I have found some code that uses the virtual keyword for functions, like:

package tryOut{
    public class Parent {

        public function Parent() {}

        public function foo():void{
            trace("Parent foo");
        }//foo

        public virtual function bar():void{
            trace("Parent virtual bar");
        }//bar      
    }//class
}//package

As far as I understand using the virtual keyword should modify the way overriding a method works, or the way using a child method would work, or something. But it seems it does nothing at all. Having the extention:

package tryOut {
    public class Child extends Parent {
        public function Child() {}

        public override function foo():void {
            trace("Child foo");
        }//foo

        public override function bar():void {
            trace("Child virtual bar");
        }//bar

    }//class
}//package

The following code prints:

var parent:Parent = new Parent();
var child:Child = new Child();

parent.foo(); //Parent foo
child.foo(); //Child foo
parent.bar(); //Parent virtual bar
child.bar(); //Child virtual bar

var childCast:Parent = child as Parent;

parent.foo(); //Parent foo
childCast.foo(); //Child foo
parent.bar(); //Parent virtual bar
childCast.bar(); //Child virtual bar

So both methods work the same regarding the override. Does the virtual keyword changes something I am missing?

  • 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-13T18:16:50+00:00Added an answer on May 13, 2026 at 6:16 pm

    From the help documents (If you’re using Flash, do a search for ‘virtual’):

    There are also several identifiers
    that are sometimes referred to as
    future reserved words. These
    identifiers are not reserved by
    ActionScript 3.0, though some of them
    may be treated as keywords by software
    that incorporates ActionScript 3.0.
    You might be able to use many of these
    identifiers in your code, but Adobe
    recommends that you do not use them
    because they may appear as keywords in
    a subsequent version of the language.

    abstract boolean byte cast
    
    char debugger double enum
    
    export float goto intrinsic
    
    long prototype short synchronized
    
    throws to transient type
    
    virtual volatile
    

    So in AS3, virtual does absolutely nothing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to adapt some code that I have found online that uses this
I'm using NetBeans as my IDE. Whenever I have some code that uses another
I have inherited a bit of Java code that uses Hibernate. Some of the
I have a some code that gets passed a class derived from a certain
I have some C# code that uses some constructs specific to .NET 3.5. When
I'm using Grails 1.3.7. I have some code that uses the built-in base64Encode function
I have some inherited code that uses hibernate. I'm getting the following error: Caused
Taking over some code from my predecessor and I found a query that uses
I have some code that uses an ArrayCollection, it imports: import mx.collections.ArrayCollection; then: static
I have some code that uses ctypes to try to determine if the file

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.