AS 3 Custom Class

I have been trying to convert the code posted previously to a custom class:


package {
    import flash.display.*;
    import flash.events.*;
    import flash.net.*;
    import flash.display.Stage;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.display.StageDisplayState;
    import flash.accessibility.AccessibilityProperties;
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextLineMetrics;
    import flash.text.AntiAliasType;
    import flash.text.TextFormat;
    //----------------------------------------------------------------
    import flash.utils.getDefinitionByName;
    import flash.media.Sound;
    import flash.media.SoundLoaderContext;
    import flash.media.SoundChannel;
    //----------------------------------------------------------------
    var stage:Stage;
    var content_tb:TextField;
    var xmlLoader:URLLoader;
    //----------------------------------------------------------------
    stage.displayState = StageDisplayState.FULL_SCREEN;
    stage.scaleMode = StageScaleMode.NO_SCALE;
    //----------------------------------------------------------------
    content_tb.embedFonts = true;
    content_tb.selectable = false;
    //----------------------------------------------------------------
    var clickSound:Sound;
    var librarySoundOne:Class = getDefinitionByName ( "Click" ) as Class;
    clickSound = new librarySoundOne();
    var clickChannel:SoundChannel;
    //----------------------------------------------------------------
    var dingSound:Sound;
    var librarySoundTwo:Class = getDefinitionByName ( "Ding" ) as Class;
    dingSound = new librarySoundTwo();
    var dingChannel:SoundChannel;
    //----------------------------------------------------------------

    public class LoadXML extends MovieClip {
        var xmlLoader:URLLoader = new URLLoader();
        var xmlData:XML = new XML();
        xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
        xmlLoader.load(new URLRequest("xml/modernism.xml"));

        // Constructor
        public function LoadXML(e:Event):void {
            xmlData = new XML(e.target.data);
            LoadContent(xmlData);
        }
        // Method invoked automatically when the XML finishes loading
        function LoadContent(textData:XML):void {
            //CONTENT TO BE DISPLAYED ON INITIAL LOAD
            var defaultText = textData.item[0].content.text();
            var pageTitle_text = textData.item.label.text()[0];
            pageTitle_tb.htmlText = "<b>" + pageTitle_text + "</b>";
            var formatSpacing:TextFormat = new TextFormat();
            formatSpacing.letterSpacing = 4;
            pageTitle_tb.setTextFormat(formatSpacing);

            //----------------------------------------

            function setPage(page:Number):void {
                field.scrollV = (page - 1) * linesPerPage + 1;
            }
            // Assigns the text field that is on the stage to a local variable
            var field:TextField = content_tb;
            field.embedFonts = true;
            // Assign the content to the text field
            field.htmlText = defaultText;

            // Extracts the text format and line height properties
            var format:TextFormat = field.getTextFormat();

            var leading = int(format.leading);
            var extent:TextLineMetrics = field.getLineMetrics(0);
            var ascent = extent.ascent;
            var descent = extent.descent;

            // CALCULATE THIS NUMBER USING BODY TEXT OF THE SAME FONT SIZE
            // IF HTML TEXT INCLUDES HEADINGS OF DIFFERING SIZES THE NUMBERS WILL BE SKEWED
            //var lineHeight = ascent + descent + leading;
            var lineHeight = 16;
            var linesPerPage = Math.floor((field.height - 4 + leading) / lineHeight);
            var lineCount = (field.maxScrollV - 1) + linesPerPage;
            var pageCount = Math.ceil(lineCount / linesPerPage);

            var offset = (linesPerPage * pageCount) - lineCount + 1;
            var lineBreak:String = "<br />";
            //var lineBreak:String = "
";

            for (var i = 0; i < offset; i++) {
                defaultText.htmlText += lineBreak;
            }
            //LINE BELOW IS A NECESSARY REPEAT
            field.htmlText = defaultText;

            var panelNum = pageCount;
            var curNum = 1;
            pageNum.htmlText = "<b>" + curNum + "</b>";
            pageTotal.htmlText = "<b>" + panelNum + "</b>";
            prevButton_mc.visible = false;

            function NextOnClick(event:MouseEvent):void {
                curNum++;
                pageNum.htmlText = "<b>" + curNum + "</b>";
                setPage(curNum);
                if (curNum == 2) {
                    prevButton_mc.visible = true;
                    clickChannel = clickSound.play();
                } else if (curNum == panelNum) {
                    event.currentTarget.visible = false;
                    curNum = panelNum;
                    dingChannel = dingSound.play();
                } else {
                    clickChannel = clickSound.play();
                }

            }
            nextButton_mc.buttonMode = true;
            nextButton_mc.addEventListener(MouseEvent.CLICK, NextOnClick);

            function PrevOnClick(event:MouseEvent):void {
                curNum--;
                pageNum.htmlText = "<b>" + curNum + "</b>";
                setPage(curNum);
                if (curNum == 1) {
                    setPage(curNum);
                    event.currentTarget.visible = false;
                    curNum = 1;
                    dingChannel = dingSound.play();
                } else {
                    clickChannel = clickSound.play();
                }
                nextButton_mc.visible = true;
            }
            prevButton_mc.buttonMode = true;
            prevButton_mc.addEventListener(MouseEvent.CLICK, PrevOnClick);
        }
    }
}

I’ve managed to eliminate all the errors except one:

1067: Implicit coercion of a value of type Class to an unrelated type Function.

That error refers to the following line:

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);

The compiler doesn’t like the name of the public function I guess. Shouldn’t the public function name be the same as it’s class name? Hopefully someone can spot the issue. (I’m sure I’ll get a whole other group of errors once this is fixed)