I’m new to programming. I need to add new properties to the Sound object, but I can’t get it to work. This is what I’m doing:
S31 = new Sound();
S31.load(new URLRequest("mp3/S31.mp3"));
Sound.prototype.correctas = 0;
trace(S31.correctas);
I get this error message:
“1119: Access of possibly undefined property correctas through a reference with static type flash.media:Sound”.
I don’t know what to do.
Thanks for your time.
The prototype class really isn’t used in as3 (please someone correct me if I’m wrong here, I know its include but I’m not really sure why you would use it.)
You can create dynamic classes that allow you to add properties to them at runtime but in this case I would stick to OOP.
What you would want to do is create a class that extends Sound and holds whatever extended functionality you want to include. This new class will inherit all the functionality of the base Sound class.
Try creating a new AS3 class and having it extend Sound
Now to use this you would create a new MySound object instead of Sound