Flash Array of custom classes

Posted on 2007-10-10
Last Modified: 2010-04-03
How do I make this work?

import package.myClass;

var arrayOfMyClass:Array;

arrayofMyClass= new Array;

arrayofMyClass[0]=new myClass;
arrayofMyClass[1]=new myClass;
arrayofMyClass[2]=new myClass;
arrayofMyClass[3]=new myClass;

Clearly I want an Array, but I want each element of the array to be an instance of my custom class.

Question by:dban00b
    LVL 10

    Accepted Solution

    well from first glance you've called new on your myClass class but you haven't called it properly - with a ()

    so it'd be more like

    new myClass();

    but i've never done what you're doing before so other than that suggestion I can't comment.
    LVL 10

    Expert Comment

    oh and same goes for the array - the new operator will expect a () after the class

    so arrayofMyClass= new Array();

    This might seem strange, but you're actually calling the constructor method. Method calls take arguments in brackets, and if there aren't any arguments, you leave the brackets empty.
    LVL 1

    Author Comment

    whoops.  Oh well. thanks for the easy fix.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
    In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
    The goal of the tutorial is to teach the user how to how to record live broadcast.
    The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now