Forums: Flash:

 

can't get sound to work in my class

first
 

JERKSTORE can't get sound to work in my class

This is AS2


import mx.utils.Delegate;
import mx.transitions.Tween;
import mx.transitions.easing.*;

class com.site.content.Book extends MovieClip {
private var bookMusic:Sound = new Sound();
...
}


The error I get is:

A class's instance variables may only be initialized to compile-time constant expressions.

and then it lists the var declaration shown above as the issue.

Is there an include I'm missing (if so I looked through the MX folder but couldn't find it).
Can I not use Sound in a MovieClip object?

 

lithium

i'm not sure if you can instantiate sounds at declaration-time.

try :


import mx.utils.Delegate;
import mx.transitions.Tween;
import mx.transitions.easing.*;

class com.site.content.Book extends MovieClip {
private var bookMusic:Sound;

public function Book()
{
bookMusic = new Sound();
}

}


haven't worked in as2 for years so it might be a long shot shrug.gif

A.

 

JERKSTORE

Yeah, that was it. I had tried that earlier, but an ID10T error prevented it from working as it should, which is why I was so lost.

Got it working now.

Thanks for the reply smile

 
first
 

Forums: Flash: can't get sound to work in my class

 
New Post
 
You must be logged in to post