Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 6 of 6

Thread: bitmap smoothing

  1. #1

    bitmap smoothing

    hi

    this is my first time here so, hi to all!

    so, i'm having a problem with the smoothing bitmap property that's really getting my nerves. here's part of the code.

    Code:
    function imgLoad() {
        var img:MovieClip=new empty();
        var imgRequest:URLRequest=new URLRequest(unescape(infoXml.firstChild.childNodes[actImg].childNodes[0].childNodes.toString()));
        var imgIn:MovieClip=new empty();
        var imgLoader:Loader=new Loader();
        imgLoader.load(imgRequest);
        imgLoader.contentLoaderInfo.addEventListener('complete',imgLoaded);
        imgIn.addChild(imgLoader);
        img.imagePath=unescape(infoXml.firstChild.childNodes[actImg].childNodes[0].childNodes.toString());
        img.addChild(imgIn);
        img.x=pos;
        var over:MovieClip=new hover();
        over.x=-9;
        over.blendMode=BlendMode.OVERLAY;
        img.addChild(over);
        img.addEventListener(MouseEvent.ROLL_OVER,overBtn);
        img.addEventListener(MouseEvent.ROLL_OUT,outBtn);
        img.addEventListener(MouseEvent.CLICK,external,false, 0, true);
        img.buttonMode=true;
        placer_mc.addChild(img);
    }
    function imgLoaded(event:Event) {
        var imagem:Bitmap=event.currentTarget.content as Bitmap;
        imagem.smoothing=true;
        imagem.width=imagem.width/(imagem.height/99);
        imagem.height=99;
        imagem.smoothing=true;
        MovieClip(imagem.parent.parent.parent).getChildAt(1).width=imagem.width;
        MovieClip(imagem.parent.parent.parent).getChildAt(1).alpha=0;
        imagem.smoothing=true;
        pos+=imagem.width+1+MovieClip(imagem.parent.parent).x;
        actImg+=1;
        if (actImg<infoXml.firstChild.childNodes.length) {
            imgLoad();
        }
    }

    the thing is that my image isn't getting smoothed and i don't understand why
    i'm new to AS3 so, it's the first time i try to use the smoothing property here. before, with AS2, I used forceSmoothing to the _mc where the image was and it worked fine.
    as you can see, i'm trying to smooth the image several times so that i'm sure it stays "true" for the intire script( i googled in this subject and found something about this property, sometimes, turned to "false", when the some image properties were changed)

    so, if someone could help me i would very thankful

    (if someone could also tell me if my code is "AS3 good", it would be cool, since i'm learning it all by myself and i'm not sure if i'm doing everithing right)

    see ya and thank you all
    Last edited by _fenix_; February 6th, 2009 at 08:43 AM.

  2. #2
    pretty hard to read your code. parent.parent.parent...?

    this is the part you need:

    Code:
    var bitmap = new BitmapData (	Math.round (_loader.content.width),
    										Math.round (_loader.content.height)
    									);
    		
    		bitmap.draw ( _loader.content );
    		this.addChild ( new Bitmap (bitmap, PixelSnapping.AUTO, true) );
    Last edited by .ral:cr; February 6th, 2009 at 11:16 AM.

  3. #3
    thank you for your response

    unfortunately, it's still not doing it.
    i couldn't mix the code you wrote right with mine, but still, i made some tests and it still didn't work as i need it to work. the smoothing isn't working.

    about the parent.parent.parent
    i agree with you, i loose myself in it lots of times
    i will try to find a better way to do this kind of stuff next time

  4. #4
    the ideea is to get the loaded photo (in your code, imgLoader is _loader in mine), and to duplicate it with bitmap data.
    after the photo is loaded apply my code. you have too many movieclips, so be carefull where you attach it, and also remove the original photo.
    now you should be able to resize smoothly the photo.

  5. #5
    I usually just do it like this

    Code:
    if (event.target.content is Bitmap) {
    				Bitmap(event.target.content).smoothing = true;//turn on smoothing
    				addChild(event.target.content);
    			} else {
    				addChild(event.target.content);
    			}

  6. #6
    hi

    thank you for the support
    forgive me for not replying for so long, but a have been working in other projets in the meantime...

    as far as i undestood the problem, it happened because i was resizing images from 511px of height to 99px, and maybe this was too much. i tested this using smaller images and it worked fine.

    so, my solution will be to send 2 images and not just 1 to the flash. this shouldn't be a problem because site will have a backoffice, so, the resizing will be made by php, and we will still have 1 original image.

    here's the temporary html site
    http://www.vascodagamapastelarias.pt/index.html

    thank you once more
    see ya

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012