A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 24 of 24

Thread: [CS3] Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.

  1. #21
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    You seem to be loading the xml file then making it redundant, not using it.

    You could use it better and call the images from the node values etc etc, however this works for you
    PHP Code:
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.display.MovieClip;
    import flash.display.Loader;
    import flash.events.MouseEvent;
    import flash.geom.Rectangle;
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFormat;

    var 
    xmlFile:XML;

    var 
    xmlLoader:URLLoader = new URLLoader(new URLRequest("gallery.xml"));
    xmlLoader.addEventListener(Event.COMPLETEonCompleteXmlLoad);

    var 
    xcoord:int 10;
    var 
    gal:gallery = new gallery();
    gal.10;
    gal.10;
    addChild(gal);
    var 
    loader:Loader = new Loader();

    function 
    onCompleteXmlLoad(e:Event):void
    {
        
    xmlFile = new XML(xmlLoader.data);
        
    trace(xmlFile.photo.url);

        var 
    len:int xmlFile.photo.length();
        
    trace(len);

        for (var 
    i:int=0i<leni++)
        {
            var 
    t:thumbs2 = new thumbs2();
            
    t.xcoord;
            
    t.320;
            
    t.buttonMode true;
            
    t.mouseEnabled true;
            
    t.name = (1).toString();
            
    trace(t.name);
            
    addChild(t);

            
    t.addEventListener(MouseEvent.MOUSE_OVERonMouseOver);
            
    t.addEventListener(MouseEvent.MOUSE_OUTonMouseOut);
            
    t.addEventListener(MouseEvent.CLICKonMouseClick);

            var 
    loaderThumb:Loader = new Loader();
            
    loaderThumb.load(new URLRequest("thumbs/" + (i+1) + ".jpg"));
            
    t.addChild(loaderThumb);

            
    xcoord +=  t.width 10;
        }

        
    loader.load(new URLRequest("imgs/1.jpg"));
        
    loader.contentLoaderInfo.addEventListener(Event.COMPLETEonComplete);
        
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERRORioErrorHandler);
    }

    function 
    onMouseOver(e:MouseEvent):void
    {
        
    e.currentTarget.alpha 0.5;
    }

    function 
    onMouseOut(e:MouseEvent):void
    {
        
    e.currentTarget.alpha 1;
    }

    function 
    onMouseClick(e:MouseEvent):void
    {
        var 
    imageToGet:String e.target.parent.name;
        
    loader.load(new URLRequest("imgs/" imageToGet ".jpg"));
    }

    function 
    ioErrorHandler(event:IOErrorEvent):void
    {
        
    trace("ioErrorHandler: " event);
    }

    function 
    onComplete(e:Event):void
    {
        
    trace("loaded");
        
    gal.addChild(loader);


  2. #22
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    First, name all your images inside the folder "imgs" 1.jpg, 2.jpg, 3.jpf, and so on. The same with the images in the "thumbs" folder.

    Then replace your script with this one:

    PHP Code:
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.display.MovieClip;
    import flash.display.Loader;
    import flash.events.MouseEvent;
    import flash.geom.Rectangle;
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import fl.transitions.Tween;
    var 
    xmlFile:XML;
    var 
    loader:Loader;
    var 
    gal:gallery;

    var 
    xmlLoader:URLLoader = new URLLoader(new URLRequest("gallery.xml"));
    xmlLoader.addEventListener(Event.COMPLETEonCompleteXmlLoad);

    var 
    xcoord:int 10;


    function 
    onCompleteXmlLoad(e:Event):void
    {

        
    xmlFile = new XML(xmlLoader.data);

        
    //trace(xmlFile.photo.url);
        
    gal = new gallery ();
        
    gal.10;
        
    gal.10;
        
    addChild(gal);

        var 
    len:int xmlFile.photo.length();
        
    trace(len);

        for (var 
    i:int=0i<leni++)
        {
            var 
    t:thumbs2 = new thumbs2 ();
            
    t.xcoord;
            
    t.320;
            
    t.buttonMode true;
            
    t.name String(1).toString();        
            
    addChild(t);

            
    t.addEventListener(MouseEvent.MOUSE_OVERonMouseOver);
            
    t.addEventListener(MouseEvent.MOUSE_OUTonMouseOut);
            
    t.addEventListener(MouseEvent.CLICKonMouseClick);


            var 
    loaderThumb:Loader = new Loader();
            
    loaderThumb.load(new URLRequest("thumbs/" + (i+1) + ".jpg"));
            
    t.addChild(loaderThumb);

            
    xcoord +=  t.width 10;
        }
        
    loader = new Loader();
        
    loader.load(new URLRequest("imgs/1.jpg"));
        
    gal.addChild(loader);

    }

    function 
    onMouseOver(e:MouseEvent):void
    {
        
    e.currentTarget.alpha 0.5;
    }

    function 
    onMouseOut(e:MouseEvent):void
    {
        
    e.currentTarget.alpha 1;
    }

    function 
    onMouseClick(e:MouseEvent):void
    {
        
    gal.removeChild(loader);
        
    loader = new Loader();
        
    trace(e.currentTarget.name);
        
    loader.load(new URLRequest("imgs/" int(e.currentTarget.name) + ".jpg"));
        
    loader.addEventListener(IOErrorEvent.IO_ERRORioErrorHandler);
        
        
    gal.addChild(loader);
        var 
    t1:Tween = new Tween(loader"alpha"null,0,1,10,false);
    }

     
    function 
    ioErrorHandler(event:IOErrorEvent):void
    {
        
    trace("ioErrorHandler: " event);

    Enjoy!
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  3. #23
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    To make use of the loaded xml file and the data stored in it (instead of not using it), try using this along side the other code
    PHP Code:
    function onMouseClick(e:MouseEvent):void
    {
        
    loader.load(new URLRequest(xmlFile.photo[e.currentTarget.name].url));
        
    text1.text xmlFile.photo[e.currentTarget.name].name;
        
    text2.text xmlFile.photo[e.currentTarget.name].desc;


  4. #24
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    If you structured your xml slightly differently, then you can contain all information within it, only slightly different to what you already have, like so
    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    
    <gallery>
    
    <photo>
    	<url>imgs/1.jpg</url>
    	<thumbs>thumbs/1.jpg</thumbs>
    	<name>Image 1</name>
    	<desc>This is the image 1</desc>
    </photo>
    
    <photo>
    	<url>imgs/2.jpg</url>
    	<thumbs>thumbs/2.jpg</thumbs>
    	<name>Image 2</name>
    	<desc>This is the image 2</desc>
    </photo>
    
    <photo>
    	<url>imgs/3.jpg</url>
    	<thumbs>thumbs/3.jpg</thumbs>
    	<name>Image 3</name>
    	<desc>This is the image 3</desc>
    </photo>
    
    <photo>
    	<url>imgs/4.jpg</url>
    	<thumbs>thumbs/4.jpg</thumbs>
    	<name>Image 4</name>
    	<desc>This is the image 4</desc>
    </photo>
    
    <photo>
    	<url>imgs/5.jpg</url>
    	<thumbs>thumbs/5.jpg</thumbs>
    	<name>Image 5</name>
    	<desc>This is the image 5</desc>
    </photo>
    <photo>
    	<url>imgs/6.jpg</url>
    	<thumbs>thumbs/6.jpg</thumbs>
    	<name>Image 6</name>
    	<desc>This is the image 6</desc>
    </photo>
    
    <photo>
    	<url>imgs/7.jpg</url>
    	<thumbs>thumbs/7.jpg</thumbs>
    	<name>Image 7</name>
    	<desc>This is the image 7</desc>
    </photo>
    
    <photo>
    	<url>imgs/8.jpg</url>
    	<thumbs>thumbs/8.jpg</thumbs>
    	<name>Image 8</name>
    	<desc>This is the image 8</desc>
    </photo>
    
    </gallery>
    and your flash file like so, it's easy to follow the code
    PHP Code:
    import flash.net.URLLoader;
    import flash.net.URLRequest;

    import flash.events.Event;
    import flash.events.MouseEvent;

    import flash.display.MovieClip;
    import flash.display.Loader;
    import flash.display.Sprite;

    //import flash.geom.Rectangle;

    import flash.text.TextField;
    import flash.text.TextFormat;

    import fl.transitions.Tween;

    var 
    xmlFile:XML;
    var 
    xmlLoader:URLLoader = new URLLoader(new URLRequest("gallery.xml"));
    xmlLoader.addEventListener(Event.COMPLETEonCompleteXmlLoad);

    var 
    loader:Loader = new Loader();
    var 
    gal:gallery = new gallery();

    function 
    onCompleteXmlLoad(e:Event):void
    {
        
    xmlLoader.removeEventListener(Event.COMPLETEonCompleteXmlLoad);
        
    xmlFile = new XML(xmlLoader.data);
        
    trace(xmlFile.photo.url);
        
    trace(xmlFile.photo.thumbs);
        
    trace(xmlFile.photo.name);
        
    trace(xmlFile.photo.desc);

        var 
    len:int xmlFile.photo.length();
        
    trace("Photo amount: " len);

        
    with (gal)
        {
            
    10;
            
    10;
        }
        
    addChild(gal);

        for (var 
    i:int=0i<leni++)
        {
            var 
    t:thumbs2 = new thumbs2();
            
    t.* (t.width 10);
            
    t.320;
            
    t.buttonMode true;
            
    t.mouseEnabled true;
            
    t.id i.toString();
            
    t.name "thumbButton" i.toString();
            
    trace(t.name);
            
    addChild(t);

            
    t.addEventListener(MouseEvent.MOUSE_OVERonMouseOver);
            
    t.addEventListener(MouseEvent.MOUSE_OUTonMouseOut);
            
    t.addEventListener(MouseEvent.CLICKonMouseClick);

            var 
    loaderThumb:Loader = new Loader();
            
    loaderThumb.load(new URLRequest(xmlFile.photo[i].thumbs));
            
    t.addChild(loaderThumb);
        }

        
    loader.load(new URLRequest(xmlFile.photo[0].url));
        
    loader.contentLoaderInfo.addEventListener(Event.COMPLETEonComplete);
        
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERRORioErrorHandler);
        
    text1.text xmlFile.photo[0].name;
        
    text2.text xmlFile.photo[0].desc;
    }

    function 
    onMouseOver(e:MouseEvent):void
    {
        
    e.currentTarget.alpha 0.5;
    }

    function 
    onMouseOut(e:MouseEvent):void
    {
        
    e.currentTarget.alpha 1;
    }

    function 
    onMouseClick(e:MouseEvent):void
    {
        
    gal.removeChild(loader);
        
    loader.load(new URLRequest(xmlFile.photo[e.currentTarget.id].url));
        
    text1.text xmlFile.photo[e.currentTarget.id].name;
        
    text2.text xmlFile.photo[e.currentTarget.id].desc;
    }

    function 
    ioErrorHandler(event:IOErrorEvent):void
    {
        
    trace("ioErrorHandler: " event);
    }

    function 
    onComplete(e:Event):void
    {
        
    trace("loaded");
        
    gal.addChild(loader);
        var 
    tweenIn:Tween = new Tween(loader,"alpha",null,0,1,10,false);


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center