A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: flash 8 smoothing workaround = endless problem

  1. #1

    flash 8 smoothing workaround = endless problem

    Hello, I am hoping some kind soul will look at the code below and tell me how to get this working correctly. It's quite simple probably.

    I have an XML photogallery. But the flash movie that the gallery lives in is scaleable so I needed to apply a redraw bitmap data workaround so that I can turn smoothing on. Annoying that flash 8 wont make this easier to do. Anyway, I can't figure out how to unload the bitmap data before redrawing another one. As a result when the user clicks on the next button, the image alpha's off and then fades back in immediately, then when then new image is loaded it comes into view. It's because my if loaded == filesize thinks the _mc picture is loaded because the draw bitmap script keeps the data in the mc... Is this enough info?



    function loadXML(loaded) {
    if (loaded) {
    xmlNode = this.firstChild;
    image = [];
    description = [];
    total = xmlNode.childNodes.length;
    for (i=0; i<total; i++) {
    image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
    description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
    }
    firstImage();
    } else {
    content = "file not loaded!";
    }
    }
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    xmlData.load(_parent._parent.productsLoad);
    /////////////////////////////////////
    listen = new Object();
    listen.onKeyDown = function() {
    if (Key.getCode() == Key.LEFT) {
    prevImage();
    } else if (Key.getCode() == Key.RIGHT) {
    nextImage();
    }
    };
    Key.addListener(listen);
    previous_btn.onRelease = function() {
    prevImage();
    };
    next_btn.onRelease = function() {
    nextImage();
    };
    /////////////////////////////////////
    p = 0;
    this.onEnterFrame = function() {
    filesize = picture.getBytesTotal();
    loaded = picture.getBytesLoaded();
    preloader._visible = true;
    if (loaded != filesize) {
    preloader.preload_bar._xscale = 100*loaded/filesize;
    } else {
    preloader._visible = false;
    if (picture._alpha<100) {
    picture._alpha += 10;
    }
    }
    };
    function nextImage() {
    if (p<(total-1)) {
    p++;
    if (loaded == filesize) {
    //picture.unloadMovie();
    picture._alpha = 0;
    //picture.loadMovie(image[p], 1);
    loadBitmapSmoothed(image[p], picture);
    desc_txt.text = description[p];
    picture_num();
    }
    }
    }
    function prevImage() {
    if (p>0) {
    p--;
    picture._alpha = 0;
    //picture.loadMovie(image[p], 1);
    loadBitmapSmoothed(image[p], picture);
    desc_txt.text = description[p];
    picture_num();
    }
    }
    function firstImage() {
    if (loaded == filesize) {
    picture._alpha = 0;
    //picture.loadMovie(image[0], 1);
    loadBitmapSmoothed(image[0], picture);
    desc_txt.text = description[0];
    picture_num();
    }
    }
    function picture_num() {
    current_pos = p+1;
    pos_txt.text = current_pos+" / "+total;
    }
    stop();


    import flash.display.*;

    function loadBitmapSmoothed(url:String, target:MovieClip) {
    //bmc.unloadMovie();
    // Create a movie clip which will contain our unsmoothed bitmap
    var bmc:MovieClip = target.createEmptyMovieClip("bmc",target.getNextHi ghestDepth());

    // Create a listener which will notify us when the bitmap loaded successfully
    var listener:Object = new Object();
    // Track the target
    listener.tmc = target;

    // If the bitmap loaded successfully we redraw the movie into
    // a BitmapData object and then attach that BitmapData to the target
    // movie clip with the smoothing flag turned on.
    listener.onLoadInit = function(mc:MovieClip) {
    mc._visible = false;
    var bitmap:BitmapData = new BitmapData(mc._width, mc._height, true);
    this.tmc.attachBitmap(bitmap, 1,"auto", true);
    bitmap.draw(mc);
    };

    // Do it, load the bitmap now
    var loader:MovieClipLoader = new MovieClipLoader();
    loader.addListener(listener);
    loader.loadClip(url, bmc);
    }

  2. #2
    still hoping someone can help...

  3. #3
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    If I understand correctly:
    var bmc:MovieClip = target.createEmptyMovieClip ("bmc", target.getNextHighestDepth ());

    you are creating continously new MovieClips, when the function is evoked. Replace target.getNextHighestDepth () with a number like 1.
    - The right of the People to create Flash movies shall not be infringed. -

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