dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [RESOLVED] I keep getting this error

  1. #1
    Senior Member
    Join Date
    Jan 2006
    Location
    Mount Joy, Pa
    Posts
    117

    resolved [RESOLVED] I keep getting this error

    Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.

    I think the original was AS2. (I F%#KED UP and saved it as AS3 by accident)

    Code:
    //this is the loader that will load our XML document
    var xmlLoader:URLLoader = new URLLoader();
    //and this is our XML object -- it will contain the loaded XML data
    var xmlData:XML = new XML;
    
    //this function is called to handle all the XML loading duties -- it receives the XML's location
    //as a string from a call to loadXml(...) below
    function loadXml(xmlFile:String):void {
    	//we add an event listener to check when the XML has finished loading
    	//once it has, we fire the xmlLoaded function
    	xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
    	//we also add an error-catching listener, which will tell us if there's a problem loading the XML
    	xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, xmlLoadFail);
    	//lastly, we load the XML by telling our URLLoader (above) to load the XML file
    	xmlLoader.load(new URLRequest(xmlFile));
    }
    //load the XML file
    loadXml("slideshow.xml");
    
    //this function is fired if there is an error loading the XML file
    function xmlLoadFail(event:IOErrorEvent):void {
    	trace("There's been an error loading the XML.  Try back in a moment.");
    }
    
    //if the data loads correctly, this function is called
    function xmlLoaded(e:Event):void {
    	//we define our xmlData object (from above) as the data of e.target, which in this case is xmlLoader
    	xmlData = XML(e.target.data);
    	loadThumbs();//call the thumbs loading function
    }
    
    
    //-------------------LOADING IMAGES------------------\\
    var padding:Number = 3; // this number is how much vertical space you want between thumbs
    var p:int = 0;//increment value
    var child:MovieClip;//var for empty movieClip that hold our thumbs
    //generic empty loader object
    var loader:Loader;
    //and a loader for our thumbnails
    var thumbLoader:Loader;
    //this function gets called if the XML loads without any problems
    function loadThumbs():void {
    	//we create a new instance of thumbLoader each time this is called
    	thumbLoader = new Loader();
    	//we add an event listener to its contentLoaderInfo (which contains loading data)
    	//this listener fires when the loading has completed (INIT = "initialized," or fully loaded & accessible)
    	thumbLoader.contentLoaderInfo.addEventListener(Event.INIT, thumbLoaded);
    	//and, last, we tell the Loader object to load the thumbnail as per our XML's <thumbnail> tag
    	thumbLoader.load(new URLRequest(String(xmlData.pic.thumb[p])));//access the thumbnails
    }
    
    //this function is fired once loading of a thumbnail has completed
    function thumbLoaded(e:Event):void {
    	//we create a new MovieClip
    	child = new MovieClip();
    	//add the content of our loader to the movie clip (so the movie clip is now the thumbnail)
    	child.addChild(thumbLoader.content);
    	//add an event listener to the movie clip which fires when it is clicked -- it loads the full-size image
    	child.addEventListener(MouseEvent.CLICK, loadBigImage);
    	//we tell the movie clip to behave as a button, which makes the mouse use the "hand cursor" when it is hovered over
    	child.buttonMode = true;
    	//here we set a variable INSIDE our new movie clip, which contains the URL of its full-size version
    	//we'll use this when loading the full-size image
    	child.largeimg = xmlData.pic.largeimg[p];
    	//once finished, add the movie clip to thumbnails_mc (which contains all the thumbs) so we can see it
    	thumbnails_mc.addChild(child);
    	/*And now we position it. Since it's a vertical scroller, we use the y property of the MovieClip.
    	We determine this new location by figuring out the height of this thumbnail (since they're all the same height),
    	adding a padding value to it (to space them a little), and multiplying that by p, which is the number corresponding
    	to the current section of XML we're working on.*/
    	child.y = (e.target.content.height+padding)*p;//set the x pos of the thumb to the changex var
    	//now we just check if p+1 is greater than the length of xmlData.pic (the individual pic entries in the XML)
    	//if it is not greater, we know we can call the loadThumbs function again, because there is at least one more thumb to load
    	if (++p<xmlData.pic.length()) {
    		loadThumbs();//create loop
    	}
    }
    //this is the function called by clicking a thumb
    //it simply tells myLoader (the UILoader Component on the Stage) to load its corresponding large image
    //the path to this large image is determined by the largeimg variable which we stored in each thumbnail above
    function loadBigImage(e:MouseEvent):void {
    	myLoader.load(new URLRequest(e.target.largeimg));
    }
    
    //------------------SCROLLING--------------------------\\
    //this adds a listener to thumbnails_mc, which will be used for scrolling
    thumbnails_mc.addEventListener(Event.ENTER_FRAME, scrollMe);
    //and this variable will hold the y position of the mouse -- it will also be used to scroll
    var lastMouse:Number = 0;
    
    //this is the scrolling function
    function scrollMe(e:Event):void {
    	//first we check to see if the mouse is near the pictures
    	//the math I've done basically just makes the "hot area" include all the space to the right
    	//of where the thumbnails begin -- since they're right on the edge, that is their whole area
    	if (mouseX>thumbnails_mc.x) {
    		//this variable stores the mouse's position once per frame
    		//we're storing this in an outside variable in order to produce smooth deceleration
    		//if the mouse moves outside of the "hot area" -- if we made this an INTERNAL variable,
    		//which would only update if the mouse was in the "hot area," the thumbnails would come to an immediate stop
    		//once rolled off of, which just isn't too attractive
    		lastMouse = mouseY;
    		//now, this is an easing formula
    		//it takes the difference between where the target is and where we want it to be
    		//then, it divides that number by a value which is called our "easing value"
    		//in this case, that value is the 5 at the end of each line of code (a larger number makes a slower transition)
    		//then we continually subtract this difference from our target's ACTUAL value
    		//this produces a nice smooth slide transition
    		thumbnails_mc.y -= (thumbnails_mc.y-padding-((thumbMask_mc.height-(thumbnails_mc.height+padding*2))/thumbMask_mc.height*lastMouse))/7;
    	} else {
    		//if the mouse is not in the "hot area," the transition continues to the last recorded value of "lastMouse,"
    		//which is the variable we were using above to store the mouse position
    		//since it is not updated in this case, it just slows to a stop instead of stopping immediately
    		thumbnails_mc.y -= (thumbnails_mc.y-padding-((thumbMask_mc.height-(thumbnails_mc.height+padding*2))/thumbMask_mc.height*lastMouse))/7;
    	}
    }
    The XML.
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    
    <images>
    
    	<pic>
    
            <thumb>images/thumbs/small_alien_brains.jpg</thumb>
    
            <largeimg>images/large/big_alien_brains.jpg</largeimg>
    
        </pic>
    
    	<pic>
    
            <thumb>images/thumbs/small_alien_metal.jpg</thumb>
    
            <largeimg>images/large/big_alien_metal.jpg</largeimg>
    
        </pic>
    
    	<pic>
    
            <thumb>images/thumbs/small_alien_planet.jpg</thumb>
    
            <largeimg>images/large/big_alien_planet.jpg</largeimg>
    
        </pic>
    
    	<pic>
    
            <thumb>images/thumbs/small_alien_water.jpg</thumb>
    
            <largeimg>images/large/big_alien_water.jpg</largeimg>
    
        </pic>
    
    	<pic>
    
            <thumb>images/thumbs/small_badland.jpg</thumb>
    
            <largeimg>images/large/big_badland.jpg</largeimg>
    
        </pic>
    
    	<pic>
    
            <thumb>images/thumbs/small_beerRun.jpg</thumb>
    
            <largeimg>images/large/big_beerRun.jpg</largeimg>
    
        </pic>
    
    	<pic>
    
            <thumb>images/thumbs/small_binHidden.jpg</thumb>
    
            <largeimg>images/large/big_binHidden.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_bloody_ripple.jpg</thumb>
    
            <largeimg>images/large/big_bloody_ripple.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_burns.jpg</thumb>
    
            <largeimg>images/large/big_burns.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_burnt_land.jpg</thumb>
    
            <largeimg>images/large/big_burnt_land.jpg</largeimg>
    
        </pic>
        
        
        <pic>
    
            <thumb>images/thumbs/small_castle.jpg</thumb>
    
            <largeimg>images/large/big_castle.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_chocpunkt.jpg</thumb>
    
            <largeimg>images/large/big_chocpunkt.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_cove.jpg</thumb>
    
            <largeimg>images/large/big_cove.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_drinksWithFruit.jpg</thumb>
    
            <largeimg>images/large/big_drinksWithFruit.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_foreclosure.jpg</thumb>
    
            <largeimg>images/large/big_foreclosure.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_goneformore.jpg</thumb>
    
            <largeimg>images/large/big_goneformore.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_green_blob.jpg</thumb>
    
            <largeimg>images/large/big_green_blob.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_ionation.jpg</thumb>
    
            <largeimg>images/large/big_ionation.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_milkMan.jpg</thumb>
    
            <largeimg>images/large/big_milkMan.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_mountainRuins.jpg</thumb>
    
            <largeimg>images/large/big_mountainRuins.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_oldFarmHouse.jpg</thumb>
    
            <largeimg>images/large/big_oldFarmHouse.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_pscTrainning.jpg</thumb>
    
            <largeimg>images/large/big_pscTrainning.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_red_fabric.jpg</thumb>
    
            <largeimg>images/large/big_red_fabric.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_redLight.jpg</thumb>
    
            <largeimg>images/large/big_redLight.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_RoadunnerRacing.jpg</thumb>
    
            <largeimg>images/large/big_RoadunnerRacing.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_spline.jpg</thumb>
    
            <largeimg>images/large/big_spline.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_stage2.jpg</thumb>
    
            <largeimg>images/large/big_stage2.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_the_feeding.jpg</thumb>
    
            <largeimg>images/large/big_the_feeding.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_theMini.jpg</thumb>
    
            <largeimg>images/large/big_theMini.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_twomanywindows.jpg</thumb>
    
            <largeimg>images/large/big_twomanywindows.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_volcanoLake.jpg</thumb>
    
            <largeimg>images/large/big_volcanoLake.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_waterfall.jpg</thumb>
    
            <largeimg>images/large/big_waterfall.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_winePress-c-Truck.jpg</thumb>
    
            <largeimg>images/large/big_winePress-c-Truck.jpg</largeimg>
    
        </pic>
        
        <pic>
    
            <thumb>images/thumbs/small_winePress.jpg</thumb>
    
            <largeimg>images/large/big_winePress.jpg</largeimg>
    
        </pic>
    
    </images>
    Last edited by sunReedr; 03-16-2009 at 12:32 PM.

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    You've got 3 loaders in there and you're only catching IO_ERRORs on one of them - use the same setup you've got on xmlLoader on thumbLoader and myLoader.

    [EDIT] you should also include the event message in your trace function - there are a lot of reasons you could getting an IO exception.

  3. #3
    Senior Member
    Join Date
    Jan 2006
    Location
    Mount Joy, Pa
    Posts
    117
    Quote Originally Posted by neznein9 View Post
    You've got 3 loaders in there and you're only catching IO_ERRORs on one of them - use the same setup you've got on xmlLoader on thumbLoader and myLoader.

    [EDIT] you should also include the event message in your trace function - there are a lot of reasons you could getting an IO exception.
    I'm new to as3 so sorry i don't understand what you mean.

    gallery

    when I get the error is when I mouse over the thumbs, also not all the thumbs are showing. only 24 of 34 are shown for some reason ?
    Last edited by sunReedr; 03-16-2009 at 12:41 PM. Reason: added url to gallery

  4. #4
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Try adding this into your loadThumbs function:

    PHP Code:
        thumbLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function(e:IOErrorEvent):void{
            
    trace("There's been an error loading a thumbnail: " e.text);
        }); 

  5. #5
    Senior Member
    Join Date
    Jan 2006
    Location
    Mount Joy, Pa
    Posts
    117
    Thats it.

    Thanks a Million.

    I owe you a cup of coffee.

  6. #6
    Senior Member
    Join Date
    Jan 2006
    Location
    Mount Joy, Pa
    Posts
    117
    OK I have another problem I need this gallery to have the scrolling thumbs at the bottom of the loader( moving x instead of y) instead of having it on the right side. I had tried this by converting everything thats marked x to y and y to x but I get the following error and can't figure out why.

    TypeError: Error #1006: value is not a function.
    at gallery_fla::MainTimeline/thumbLoaded()

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