Results 1 to 6 of 6

Thread: Cannot get image smoothing to work with my AS3 script

  1. #1
    Join Date
    Jun 2008
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Cannot get image smoothing to work with my AS3 script

    Hey guys, been trying different tutorials but not getting
    anywhere here.

    Below is my actionscript, UILoader loads an external image
    from an XML file and shrinks it down to fit into the 205x205
    box. But it makes the images look funky and distorted.

    Can anyone tell me what I am doing wrong here. I am a
    beginner to AS3, got this to work via a few found tuts
    scattered around online.

    Code:
    var imageLoader:Loader;
    var xml:XML;
    var xmlList:XMLList;
    var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.load(new URLRequest("previews.xml"));
    
    xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
    
    import fl.containers.UILoader; 
    
    
    function xmlLoaded(event:Event):void
    {
    	xml = XML(event.target.data);
    	xmlList = xml.children();
    
    	var aLoader:UILoader = new UILoader(); 
    	aLoader.load(new URLRequest(xmlList[0].attribute("image"))); 
    	aLoader.width = 205;
    	aLoader.height = 205;
    	aLoader.x = 0;
    	aLoader.y = 0;
    	
    	
    	var link:URLRequest = new URLRequest("home.html");
    	
    	aLoader.buttonMode = true;
    	aLoader.addEventListener(MouseEvent.CLICK, gooo);
    	
    	function gooo(event:MouseEvent):void {
    	navigateToURL(link, '_self');
    	}
    	
    	var border:DropShadowFilter = new DropShadowFilter();
    	border.blurX = 0;
    	border.blurY = 0;
    	border.distance = 0;
    	border.strength = 0;
    	border.inner = true;
    	border.color = 0xFFFFFF;
    	border.alpha = 1;
    	
    	aLoader.filters = [border];
    	addChild(aLoader);
    
    }

  2. #2
    Join Date
    Jun 2008
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Wow, I figured it was something simple, but if 50 something people don't know then I don't feel so bad.

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    To be honest, few users here are experts with flash. A few know it very well, but perhaps have never had this problem. Also, many of the "views" for the thread may be search engine bots, not users.
    You may get a better answer for this at a flash-only forum, while you'll usually get a good answer here for questions about Javascript/HTML/CSS/PHP/etc.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Jun 2008
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well appreciate you letting me know. I'll try another forum.

  5. #5
    Join Date
    Oct 2006
    Location
    New York, NY, USA
    Posts
    262
    Thanks
    42
    Thanked 24 Times in 24 Posts

    Default aspect ratio?

    Have not had time to digest that complicated script. Suspect the distortion has sosmething to do with the image aspect ratio.

    This from Adobe for Flash CS3:
    http://www.adobe.com/livedocs/flash/...=00000480.html
    The UILoader component is a container that can display SWF, JPEG, progressive JPEG, PNG, and GIF files. You can use a UILoader whenever you need to retrieve content from a remote location and pull it into a Flash application. For example, you could use a UILoader to add a company logo (JPEG file) to a form. You could also use the UILoader component in an application that displays photos. Use the load() method to load content, the percentLoaded property to determine how much content has loaded, and the complete event to determine when loading is finished. You can scale the contents of the UILoader or resize the UILoader itself to accommodate the size of the contents. By default, the contents are scaled to fit the UILoader. You can also load content at run time and monitor loading progress (although after content has been loaded once it is cached, the progress jumps to 100% quickly). If you specify a location when loading content in the UILoader, you must specify the location (X and Y coordinates) as 0, 0.

  6. #6
    Join Date
    Nov 2010
    Posts
    1
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Found this AS
    http://bknr.net/svn/trunk/thirdparty...ndAndBorder.as

    Making the "example":

    Code:
    var imageLoader:Loader;
    var xml:XML;
    var xmlList:XMLList;
    var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.load(new URLRequest("previews.xml"));
    
    xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
    
    import fl.containers.UILoader; 
    
    
    function xmlLoaded(event:Event):void
    {
    	xml = XML(event.target.data);
    	xmlList = xml.children();
    
    	var aLoader:UILoader = new UILoader(); 
    	aLoader.load(new URLRequest(xmlList[0].attribute("image"))); 
            // new line of code
            aLoader.addEventListener(Event.COMPLETE, onComplete);
            //
    	aLoader.width = 205;
    	aLoader.height = 205;
    	aLoader.x = 0;
    	aLoader.y = 0;
    	
    	
    	var link:URLRequest = new URLRequest("home.html");
    	
    	aLoader.buttonMode = true;
    	aLoader.addEventListener(MouseEvent.CLICK, gooo);
    	
    	function gooo(event:MouseEvent):void {
    	navigateToURL(link, '_self');
    	}
    	
    	var border:DropShadowFilter = new DropShadowFilter();
    	border.blurX = 0;
    	border.blurY = 0;
    	border.distance = 0;
    	border.strength = 0;
    	border.inner = true;
    	border.color = 0xFFFFFF;
    	border.alpha = 1;
    	
    	aLoader.filters = [border];
    	addChild(aLoader);
    
    }
    
    //new function
    function onComplete(e:Event):void 
    		{
    			trace("onComplete " + e);
    			trace("e.currentTarget.content "+e.currentTarget.content);
    			if(e.currentTarget.content is Bitmap)
    			{
    				Bitmap(e.currentTarget.content).smoothing = true;
    			}
    		}
    I Hope this helps. It works for me.

  7. The Following User Says Thank You to BenDeJo For This Useful Post:

    auntnini (11-08-2010)

Bookmarks

Posting Permissions

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