Re: [Flashcoders] Dynamic upload of bunch of images with automaticsmooth.

2008-02-04 Thread Irene Johansson
Thank you for replies BUT. :)

If i use mr. Muzaks code, i dont know how can i add my new image into right
movieclip

I need to add child to walkerMc.figure.head.imgholder.

The handleComplete is triggered when an image is loaded.
I am parsing the XML file, looping through nodes, some have images, some
dont, some pictures are bigger(load slower), some smaller(load faster).
How can i add the new child to right target?

Hope you can understand what i am talking about :)

Thanks Irene






for(var k:Number=1; k<=itemNr; k++){
usrNr++;
var walker1:MovieClip = new walker();
walker1.x = k*150+ Math.random()*40;
//walker1.y = Math.random()*5;
walker1.name = "walker"+k;
walker1.i = i;
walker1.k = k;
this["row"+i].addChild(walker1);
var walkerMc:MovieClip = this["rad"+i].getChildByName("walker"+k) as
MovieClip;
if(xml..epic[usrNr-1].text()!= undefined){
//upload picture
var loader:Loader = new Loader();
walkerMc.figure.head.imgholder.addChild(loader);

loader.load(new URLRequest(theURL+"img/"+xml..epic[usrNr-1].text()));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleComplete,
false, 0, true);
}else{
//show random face
walkerMc.figure.head.faces.gotoAndStop(xml..spic[brukerNr-1].text());
}

}



function handleComplete(event:Event){
var ldr:Loader = LoaderInfo(event.currentTarget).loader as Loader;
ldr.contentLoaderInfo.content.width=43;
ldr.contentLoaderInfo.content.height=43;


var image:Bitmap = Bitmap(ldr.contentLoaderInfo.content);
image.smoothing = true;

}


On 2/4/08, EECOLOR <[EMAIL PROTECTED]> wrote:
>
> Another problem here may be the quality property on the object/embed tag.
> If
> it is auto high it might for some cases switch to non-smoothing to benefit
> the performance. This will change if you set the property to high.
>
>
> Greetz Erik
>
> On 2/3/08, Muzak <[EMAIL PROTECTED]> wrote:
> >
> > Check the example in the docs.
> > You need to create a copy of the original (loaded) image, add it to the
> > display list and remove the (original) loaded image
> >
> >
> >
> http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Bitmap.html
> >
> > Here's an example of loading an image and displaying a copy next to it:
> >
> > import flash.display.Loader;
> > import flash.net.URLRequest;
> > import flash.display.Bitmap;
> >
> > var loader:Loader;
> > var req:URLRequest;
> > var orig_mc:MovieClip;
> > var copy_mc:MovieClip;
> >
> > function loaderCompleteHandler(evt:Event) {
> > var ldr:Loader = evt.currentTarget.loader as Loader;
> > var origImg:Bitmap = (ldr.content as Bitmap)
> > origImg.width = 200;
> > origImg.height = 150;
> >
> > var image:Bitmap = new Bitmap(origImg.bitmapData, "auto", true);
> > image.width = 200;
> > image.height = 150;
> > copy_mc.addChild(image);
> > }
> >
> > loader = new Loader();
> > req = new URLRequest("2.jpg");
> > loader.load(req);
> > loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
> > loaderCompleteHandler);
> >
> > orig_mc = new MovieClip();
> > orig_mc.addChild(loader);
> > addChild(orig_mc);
> >
> > copy_mc = new MovieClip();
> > copy_mc.x = 210;
> > addChild(copy_mc);
> >
> >
> > regards,
> > Muzak
> >
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Dynamic upload of bunch of images with automaticsmooth.

2008-02-04 Thread EECOLOR
Another problem here may be the quality property on the object/embed tag. If
it is auto high it might for some cases switch to non-smoothing to benefit
the performance. This will change if you set the property to high.


Greetz Erik

On 2/3/08, Muzak <[EMAIL PROTECTED]> wrote:
>
> Check the example in the docs.
> You need to create a copy of the original (loaded) image, add it to the
> display list and remove the (original) loaded image
>
>
> http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Bitmap.html
>
> Here's an example of loading an image and displaying a copy next to it:
>
> import flash.display.Loader;
> import flash.net.URLRequest;
> import flash.display.Bitmap;
>
> var loader:Loader;
> var req:URLRequest;
> var orig_mc:MovieClip;
> var copy_mc:MovieClip;
>
> function loaderCompleteHandler(evt:Event) {
> var ldr:Loader = evt.currentTarget.loader as Loader;
> var origImg:Bitmap = (ldr.content as Bitmap)
> origImg.width = 200;
> origImg.height = 150;
>
> var image:Bitmap = new Bitmap(origImg.bitmapData, "auto", true);
> image.width = 200;
> image.height = 150;
> copy_mc.addChild(image);
> }
>
> loader = new Loader();
> req = new URLRequest("2.jpg");
> loader.load(req);
> loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
> loaderCompleteHandler);
>
> orig_mc = new MovieClip();
> orig_mc.addChild(loader);
> addChild(orig_mc);
>
> copy_mc = new MovieClip();
> copy_mc.x = 210;
> addChild(copy_mc);
>
>
> regards,
> Muzak
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Dynamic upload of bunch of images with automaticsmooth.

2008-02-03 Thread Muzak

Check the example in the docs.
You need to create a copy of the original (loaded) image, add it to the display 
list and remove the (original) loaded image

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Bitmap.html

Here's an example of loading an image and displaying a copy next to it:

import flash.display.Loader;
import flash.net.URLRequest;
import flash.display.Bitmap;

var loader:Loader;
var req:URLRequest;
var orig_mc:MovieClip;
var copy_mc:MovieClip;

function loaderCompleteHandler(evt:Event) {
var ldr:Loader = evt.currentTarget.loader as Loader;
var origImg:Bitmap = (ldr.content as Bitmap)
origImg.width = 200;
origImg.height = 150;

var image:Bitmap = new Bitmap(origImg.bitmapData, "auto", true);
image.width = 200;
image.height = 150;
copy_mc.addChild(image);
}

loader = new Loader();
req = new URLRequest("2.jpg");
loader.load(req);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, 
loaderCompleteHandler);

orig_mc = new MovieClip();
orig_mc.addChild(loader);
addChild(orig_mc);

copy_mc = new MovieClip();
copy_mc.x = 210;
addChild(copy_mc);


regards,
Muzak

- Original Message - 
From: "Irene Johansson" <[EMAIL PROTECTED]>

To: 
Sent: Sunday, February 03, 2008 7:43 PM
Subject: [Flashcoders] Dynamic upload of bunch of images with automaticsmooth.



Hello all you fine people!
I have a big problem with uploading smooth images.

What I do is, i load XML file, parse it loop through it, create movieclips,
and load images into thos movieclips (if image is specified in xml)

for(var k:Number=1; k<=itemNr; k++){
usrNr++;
var walker1:MovieClip = new walker();
walker1.x = k*150+ Math.random()*40;
//walker1.y = Math.random()*5;
walker1.name = "walker"+k;
walker1.i = i;
walker1.k = k;
this["row"+i].addChild(walker1);
var walkerMc:MovieClip = this["rad"+i].getChildByName("walker"+k) as
MovieClip;
if(xml..epic[usrNr-1].text()!= undefined){
//upload picture
var loader:Loader = new Loader();
walkerMc.figure.head.imgholder.addChild(loader);

loader.load(new URLRequest(theURL+"img/"+xml..epic[usrNr-1].text()));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleComplete,
false, 0, true);
}else{
//show random face
walkerMc.figure.head.faces.gotoAndStop(xml..spic[brukerNr-1].text());
}

}



function handleComplete(event:Event){
var ldr:Loader = LoaderInfo(event.currentTarget).loader as Loader;
ldr.contentLoaderInfo.content.width=43;
ldr.contentLoaderInfo.content.height=43;


var image:Bitmap = Bitmap(ldr.contentLoaderInfo.content);
image.smoothing = true;

}



I get to load images, but they are not allways smooth :(
What am i doing wrong :(

Thanks in advance
Irene
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders