Hi,
I am getting the following errors:
1118: Implicit coercion of a value with static type Object to a possibly unrelated type Function.
**Warning: 1090: **Migration issue: The onLoad event handler is not triggered automatically by Flash Player at run time in ActionScript 3.0. You must first register this handler for the event using addEventListener ( ‘load’, callback_handler).
Warning: 3594: load is not a recognized method of the dynamic class XML.
The following is the full as3 code:
var mXML:XML = new XML();
mXML.ignoreWhite = true;
mXML.onLoad = function(){
if(mXML.loaded){
//create array that will hold the movies info
var arrMovies:Array = this.firstChild.childNodes;
var i:Number = 0;
for(i; i < arrMovies.length; i++){
//Let's retrieve the values of the attributes and store them in variables
var movieName:String = arrMovies*.attributes.name;
var movieYear:Number = arrMovies*.attributes.year;
var movieGenre:String = arrMovies*.attributes.genre;
//Let's create an associative array using an Object constructor
//this array will be used to populate our DataGrid
var item:Object = {Name:movieName, Year:movieYear, Genre:movieGenre};
//Let's set our columns widths
dgMovies.getColumnAt(0).width = 250;
dgMovies.getColumnAt(1).width = 50;
dgMovies.getColumnAt(2).width = 150;
dgMovies.getColumnAt(0).resizable = false;
dgMovies.getColumnAt(1).resizable = false;
dgMovies.getColumnAt(2).resizable = false;
dgMovies.addItem(item);
}
//let's create the event listener to our DataGrid object
var dgListener:Object = new Object();
dgListener.cellPress = function(eObj:Object) {
//to retrieve cell values in the "Genre" column
var cellVal:Object = eObj.target.selectedItem.Genre;
dtxtOutput.text = cellVal.toString();
};
//let's add the event listener to our DataGrid object
dgMovies.addEventListener("cellPress", dgListener);
}
}
mXML.load("movies.xml");