9 Replies - 1052 Views - Last Post: 13 March 2011 - 11:41 AM

#1 rboyart  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 12-March 11

antialias when scaling thumbs?

Posted 12 March 2011 - 10:08 AM

Hi there,

i'm trying to make a photo gallery but when i try to scale them, i get this distortions in the thumbs....
i try to find how to fix this problem, searching in google, i found that i have to convert them to bitmap, but i can't make it work.

i found this :

var imageLoader:Loader = new Loader();
imageLoader.load(URLReq);

imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadBit);
imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressBit);

function loadBit(e:Event):void
{
	//trace(imageLoader.content);
myBitmap = Bitmap(imageLoader.content);
myBitmap.smoothing = true;
addChild(bitMov);
bitMov.addChild(myBitmap);

}



i think the problem is that i'm using a URLLoader and i can't access to "contentLoaderInfo".

can someone unblock my mind ? :)

If you have the time to take a look into my project i'll be grateful.


thanks already,

Rodrigo

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: antialias when scaling thumbs?

#2 chinchang  Icon User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 725
  • Joined: 22-December 08

Re: antialias when scaling thumbs?

Posted 12 March 2011 - 11:03 AM

Are you having some problem running your program or is it running but you are not able to achieve smoothness ?
Was This Post Helpful? 0
  • +
  • -

#3 rboyart  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 12-March 11

Re: antialias when scaling thumbs?

Posted 12 March 2011 - 11:21 AM

View Postchinchang, on 12 March 2011 - 11:03 AM, said:

Are you having some problem running your program or is it running but you are not able to achieve smoothness ?


my gallery works but i can't achieve to apply smoothness ( i think) because the code exemples i have found in the net use
"imageLoader.content" but my photos are loaded by a XML with URLLoader and i can't access to "imageLoader.content" with it, so im stuck there....

and thanks!
Was This Post Helpful? 0
  • +
  • -

#4 chinchang  Icon User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 725
  • Joined: 22-December 08

Re: antialias when scaling thumbs?

Posted 12 March 2011 - 12:00 PM

You can do the same thing with URLLoader as well.

Add a COMPLETE event listener to your URLLoader object.
In the listener function, get your bitmap and turn smoothing ON.

It should work.
Was This Post Helpful? 0
  • +
  • -

#5 rboyart  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 12-March 11

Re: antialias when scaling thumbs?

Posted 12 March 2011 - 12:48 PM

View Postchinchang, on 12 March 2011 - 12:00 PM, said:

You can do the same thing with URLLoader as well.

Add a COMPLETE event listener to your URLLoader object.
In the listener function, get your bitmap and turn smoothing ON.

It should work.




well, i try it and it doesn't work, there is an error with contentLoaderInfo

Scene 1, Layer 'Layer 1', Frame 1, Line 16 1119: Access of possibly undefined property content through a reference with static type flash.net:URLLoader.
Scene 1, Layer 'Layer 1', Frame 1, Line 10 1119: Access of possibly undefined property contentLoaderInfo through a reference with static type flash.net:URLLoader.
Scene 1, Layer 'Layer 1', Frame 1, Line 11 1119: Access of possibly undefined property contentLoaderInfo through a reference with static type flash.net:URLLoader.



the code:

var myBitmap:Bitmap = new Bitmap();
var bitMov:MovieClip = new MovieClip();
var URLReq:URLRequest = new URLRequest("http://www.imalliance.fr/test/BIG/1.jpg");
var imageLoader:URLLoader = new URLLoader();
imageLoader.load(URLReq);

imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadBit);
imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressBit);

function loadBit(e:Event):void
{
	//trace(imageLoader.content);
myBitmap = Bitmap(imageLoader.content);
myBitmap.smoothing = true;
addChild(bitMov);
bitMov.addChild(myBitmap);

}

function progressBit(e:ProgressEvent):void
{
	//trace("Loading");

trace("Loading..." + Math.ceil(e.bytesLoaded * 100 / e.bytesTotal) + "%");



}

Was This Post Helpful? 0
  • +
  • -

#6 chinchang  Icon User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 725
  • Joined: 22-December 08

Re: antialias when scaling thumbs?

Posted 12 March 2011 - 02:43 PM

That is not the way you attach listeners to URLLoader object.

var imageLoader:URLLoader = new URLLoader();
imageLoader.addEventListener(Event.COMPLETE, loadBit);

imageLoader.load(URLReq);

function loadBit(e:Event):void
{

myBitmap = imageLoader.data as Bitmap;
myBitmap.smoothing = true;
addChild(bitMov);
bitMov.addChild(myBitmap);

}

This post has been edited by chinchang: 12 March 2011 - 02:44 PM

Was This Post Helpful? 0
  • +
  • -

#7 rboyart  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 12-March 11

Re: antialias when scaling thumbs?

Posted 12 March 2011 - 03:16 PM

View Postchinchang, on 12 March 2011 - 02:43 PM, said:

That is not the way you attach listeners to URLLoader object.

var imageLoader:URLLoader = new URLLoader();
imageLoader.addEventListener(Event.COMPLETE, loadBit);

imageLoader.load(URLReq);

function loadBit(e:Event):void
{

myBitmap = imageLoader.data as Bitmap;
myBitmap.smoothing = true;
addChild(bitMov);
bitMov.addChild(myBitmap);

}




oh thanks! :) but did you try it yourself cause when i try, i have this error

Error #1009: Cannot access a property or method of a null object reference.

at convertMC_fla::MainTimeline/loadBit()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()


:/
Was This Post Helpful? 0
  • +
  • -

#8 chinchang  Icon User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 725
  • Joined: 22-December 08

Re: antialias when scaling thumbs?

Posted 13 March 2011 - 05:28 AM

View Postrboyart, on 13 March 2011 - 03:46 AM, said:

View Postchinchang, on 12 March 2011 - 02:43 PM, said:

That is not the way you attach listeners to URLLoader object.

var imageLoader:URLLoader = new URLLoader();
imageLoader.addEventListener(Event.COMPLETE, loadBit);

imageLoader.load(URLReq);

function loadBit(e:Event):void
{

myBitmap = imageLoader.data as Bitmap;
myBitmap.smoothing = true;
addChild(bitMov);
bitMov.addChild(myBitmap);

}




oh thanks! :) but did you try it yourself cause when i try, i have this error

Error #1009: Cannot access a property or method of a null object reference.

at convertMC_fla::MainTimeline/loadBit()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()


:/



Always show us your updated code when you change it.
Most probably bitMov is undefined and is giving error on using it.

Show us your full code. That might help us better to see whats wrong.
Was This Post Helpful? 0
  • +
  • -

#9 rboyart  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 12-March 11

Re: antialias when scaling thumbs?

Posted 13 March 2011 - 07:17 AM

i'm just trying a simple code before i added to my thumbs gallery.
and i have the #1009 error

the code:

var myBitmap:Bitmap = new Bitmap();
var bitMov:MovieClip = new MovieClip();
var URLReq:URLRequest = new URLRequest("http://www.imalliance.fr/test/BIG/1.jpg");
var imageLoader:URLLoader = new URLLoader();
imageLoader.load(URLReq);


imageLoader.addEventListener(Event.COMPLETE, loadBit);
imageLoader.addEventListener(ProgressEvent.PROGRESS, progressBit);

function loadBit(e:Event):void
{

myBitmap = imageLoader.data as Bitmap;
myBitmap.smoothing = true;
addChild(bitMov);
bitMov.addChild(myBitmap);

}

function progressBit(e:ProgressEvent):void
{

trace("Loading..." + Math.ceil(e.bytesLoaded * 100 / e.bytesTotal) + "%");

}


always thanks!
Was This Post Helpful? 0
  • +
  • -

#10 chinchang  Icon User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 725
  • Joined: 22-December 08

Re: antialias when scaling thumbs?

Posted 13 March 2011 - 11:41 AM

Actually you need to load only your xml file with URLLoader and for your images use Loader class.

The syntax is the same like you found on the web.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1