Need help with my scrollable textfield class

Hi,

I’m still new to flash and actionscript so would appreciate any help.

I’ve made a class called scrollertext which creates a textfield to my dimensions, which is then scrollable by clicking on the text and dragging it.

Can someone have a look at the code and give me a hint at why it’s not working!

It seems to work with the 4 lines of text but more and it breaks??

The scrollertext class is linked to a scrollertext movieclip which consists of:

masker(movieclip)
textmc(movieclip)…this contains textportion(textfield)



package 
{

    import flash.events.*;
    import flash.display.*;
    import flash.text.*;
    import flash.geom.*;
    import flash.display.Sprite;
    import flash.display.Shape; 

    ///////// I CAN CALL ON THIS CLASS TO MAKE A TEXTFIELD OF SPECIFIED CONFIG TO BE ADDED TO MY STAGE/MOVIECLIPS
    //// I.E. 
    /*
    var testy = new scrollertext();
            testy.configuration = [
                                   { 
                                   w: 400, 
                                   h: 200, 
                                   colourhex: "0x000000", 
                                   size: 35, 
                                   autosize: "left",
                                   canselect: false,
                                   font: "Avenir 85 Heavy",
                                   back: true,
                                   backcolour: "0xFFFFFF",
                                   textstring: "This is 4 lines of text.
 This is 4 lines of text.
 This is 4 lines of text.
 This is 4 lines of text." 
                                   }
                                   ];
            
            addChild(testy);
    */
    
    
    public class scrollertext extends MovieClip
    {


        private var newwidth = 150;
        private var newheight = 150;
         private var _value;
        private var roundRect;




        public function scrollertext()
        {

            addEventListener(Event.ADDED_TO_STAGE, doAdded);

        }



        private function doAdded(evt:Event)
        {

            textmc.textportion.mask = masker;

            setupsizes();

            textmc.textportion.addEventListener(MouseEvent.MOUSE_DOWN, movetext);
            stage.addEventListener(MouseEvent.MOUSE_UP, stoptext);

        }



        //adds a rounded rectangle background to the textfield
        private function sortbg()
        {
            if(_value[0].back == true && _value[0].backcolour != null)
            {
                if(roundRect!=null){removeChild(roundRect);}
                
                roundRect = new Shape();
                roundRect.graphics.beginFill(_value[0].backcolour, 1);
                
                //background is based up the sizes of the mask
                roundRect.graphics.drawRoundRect(0-(newwidth*0.05), 0-newheight*0.05, newwidth+((newwidth*0.05)*2), newheight+((newheight*0.05)*2), newwidth*0.05, newheight*0.05);
                roundRect.graphics.endFill();
                
                //set it behing the mask
                addChildAt(roundRect,numChildren-1);
            }
        }





        function movetext(e:MouseEvent)
        {

            
            textmc.startDrag(false, new Rectangle( 0, 0,0, 0-(textmc.height-newheight)));
            
            

            
        }


        function stoptext(e:MouseEvent)
        {

            textmc.stopDrag();
             
        }


        private function setupsizes()
        {
            textmc.textportion.x = 0;
            textmc.textportion.y = 0;
            masker.x = 0;
            masker.y = 0;
            textmc.textportion.height = newheight;
            textmc.textportion.width = newwidth;
            masker.height = newheight;
            masker.width = newwidth;
            
            sortbg();

        }



        public function set configuration(value:Array)
        {
            if(_value==null) { _value=value;}
            
                     
                newwidth = _value[0].w;
                newheight = _value[0].h;

                textmc.textportion.text = _value[0].textstring;
                textmc.textportion.selectable = _value[0].canselects;
                textmc.textportion.wordWrap = true;

                switch (_value[0].autosize)
                {
                    case "left" :
                        textmc.textportion.autoSize = TextFieldAutoSize.LEFT;
                        break;

                    case "right" :
                        textmc.textportion.autoSize = TextFieldAutoSize.RIGHT;
                        break;

                    case "center" :
                        textmc.textportion.autoSize = TextFieldAutoSize.CENTER;
                        break;


                }

                var myFormat:TextFormat = new TextFormat();
                myFormat.color = _value[0].colourhex;
                myFormat.size = _value[0].size;
                myFormat.align = _value[0].alignment;
                myFormat.font = _value[0].font;


                textmc.textportion.setTextFormat(myFormat);
                
                             
            
            
            
            

        }




    }

}


Try calling it with the following:



var l=1;
            var bitoftext="";
            while(l<411)
            {
                bitoftext+="Line "+l+" 
";
                l++;
            }
            
            
            testy = new scrollertext();
            testy.configuration = [
                                   { 
                                   w: 300, 
                                   h: 200, 
                                   colourhex: "0x000000", 
                                   size: 20, 
                                   autosize: "left",
                                   alignment: "left",
                                   canselect: false,
                                   font: "Avenir 85 Heavy",
                                   back: true,
                                   backcolour: "0xFFFFFF",
                                   textstring: bitoftext 
                                   }
                                   ];
            
            testy.x = 50;
            testy.y = 50;
            
            addChild(testy);


Somethings wrong with the sizing somewhere???

UPDATE:

I’ve changed the font and it’s now working exactly as intended.
I’m a little bit confused as I embedded the Avenir 85 Heavy font - but if I change the font to arial it works fine???