Hi all

 

I have 2 classes - Category and MovieData.

 

Category holds an array of MovieDatas that are initially created by passing
the movie name, id and description to it in the constructor. It is possible
that the desc is not initially known so I also want to pass the same data to
the constructor after the object has been created. This is the code:

 

for(i = 0; i < catStruct.movies.length; i++)

{

            var movieStruct:Object = catStruct.movies[i];

            trace("movie ID: " + movieStruct.id);

            if(movieArray[movieStruct.id] == null){

                        currentMovie = movieArray[movieStruct.id] = new
MovieData(movieStruct.id,movieStruct.name,movieStruct.desc);

            } else {

                        currentMovie = movieArray[movieStruct.id];

 
currentMovie.MovieData(movieStruct.id,movieStruct.name,movieStruct.desc);

            }

            this.movies.push(currentMovie);

}

 

This is pretty much identical to the code that adds categories to an array
of categories. If the category does not exist a new one is created, if it
does exist the same data is passed to the constructor.

 

For the above code though I get error on the 9th line:

 

currentMovie.MovieData(movieStruct.id,movieStruct.name,movieStruct.desc);

 

"Call to a possibly undefined method MovieData through a reference with
static type components:MovieData"

 

Is this the compiler getting it wrong or aren't I supposed to be able to do
this. If so why does the similar Category code work:

 

if(catArray[categoryID] != null){

            catArray[categoryID] = new
Category(catStruct,catArray,movieArray,null,passedParams,1);

} else {

 
catArray[categoryID].Category(catStruct,catArray,movieArray,null,passedParam
s,1);

}

 

thanks

 

Giles Roadnight

 

Reply via email to