Ok, I've nailed down where the problem is as to why my silly little *.as file 
that worked so well before won't work with minor changes in my latest *.as 
file. The problem appears to be that Flash freaks out over different image 
files! Here's the code, simplified:

package 
{
    import flash.display.Sprite;
    import flash.text.TextLineMetrics;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.text.TextFormatAlign;
    import flash.text.TextFieldAutoSize;
    import flash.net.navigateToURL;
    import flash.display.Bitmap;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.display.MovieClip;
    import com.greensock.*;
    import com.greensock.easing.*;
    import flash.display.Loader;
    import flash.events.ProgressEvent;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.text.TextFieldAutoSize;
    import flash.net.URLRequest;

    [SWF(backgroundColor="0x565656")]

    public class DeJonghPreloader extends MovieClip
    {
        var loader:Loader = new Loader();
        private var myTextField:TextField = new TextField();
        var imgFlag1:Boolean = new Boolean(false);

        public function DeJonghPreloader()
        {
            addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
        }
        
        private function init(e:Event)
        {
            var clientName:TextField = new TextField();
            var format:TextFormat = new TextFormat();
            format.font = 'Arial';
            format.size = 35;
            clientName.textColor = 0x023048;
            clientName.text = 'Delta Electric';
            clientName.autoSize = TextFieldAutoSize.LEFT;
            clientName.setTextFormat(format);
            var nameSprite:Sprite = new Sprite();
            nameSprite.x = stage.stageWidth/2 - 70;
            nameSprite.y = stage.stageHeight/2 - 40;
            nameSprite.alpha = 0;
            TweenLite.to(nameSprite, 2, {alpha:1});
            addChild(nameSprite);
            nameSprite.addChild(clientName);
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, 
imageLoaded);
            loader.load(new URLRequest("images/charles.jpg"));
            loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, 
loop);
            removeEventListener(Event.ADDED_TO_STAGE, init);
            addChild(myTextField);
            myTextField.width = 250;
            myTextField.x = stage.stageWidth/2;
            myTextField.y = stage.stageHeight/2;
            myTextField.selectable = false;
            myTextField.border = false;
            myTextField.borderColor = 0xAA0000;
            myTextField.autoSize = TextFieldAutoSize.LEFT;
            var myFormat:TextFormat = new TextFormat();
            myFormat.color = 0x023048;
            myFormat.size = 24;
            myFormat.italic = true;
            myTextField.defaultTextFormat = myFormat;
        }

        private function imageLoaded(event:Event):void
        {
            imgFlag1 = true;
            completePreloader();
        }
    
        function completePreloader()
        {
            var req:URLRequest = new URLRequest('index.py');
            navigateToURL(req, '_self');
        }
    
        function loop(e:ProgressEvent):void
        {
            var perc:Number = e.bytesLoaded/e.bytesTotal;
            myTextField.text = Math.ceil(perc*100).toString() + "%";
        }
    }
}

Now, that code works just fine. However, if I change the image from 
"charles.jpg" to "left1.png" it doesn't work. What breaks? Who knows? If I put 
a trace in completePreloader(), it traces, so one would thing that the 
URLRequest works, right? Wrong. The page is never sought, witnessed by the fact 
that, if "charles.jpg" is in, an error is traced on my Mac when trying to find 
the relative address, but if "left1.png" is in, no error. Now, it doesn't 
matter if it's a png or a jpg, because the original file that works has a 
couple pngs as well. I've gone so far as to copy and rename the working files 
in the same directory as the originals, prove they work, copy over my images 
and change them and watch this code break. So it _is_ the images that are 
causing the problem. But why, o why???
John



      

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to