A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [RESOLVED] Rookie bitmap help as3

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    28

    resolved [RESOLVED] Rookie bitmap help as3

    Hello,
    I have this tutorial code from AS3 Cookbook, fog like effect on Bitmap data
    Code:
     import flash.display.Sprite;
        import flash.display.Bitmap;
        import flash.display.BitmapData;
        import flash.events.Event;
        import flash.geom.Point;
    
     var offset:int=0;
     var bitmap:BitmapData = new BitmapData(330, 100,true,0x0);
    
                var image:Bitmap = new Bitmap(bitmap);
                addChild(image);
                image.x=0;
                image.y=190;
                
                addEventListener(Event.ENTER_FRAME, onEnter);
           function onEnter(event:Event):void {
                offset++;
                var point:Point = new Point(0, offset);
    
               
                bitmap.perlinNoise(150, 100, 5, 500, false, true,
                                8, true, [point, point]);
            }
    and interested in blending it on some background.It needs to be on the bottom of movie clip, but without that bitmaps border showing around the noise effect..Threshold? Gradient?How is that achieved?
    Heres fla.
    Attached Files Attached Files

  2. #2
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    i'm not clear on what you want to achieve... do you want a gradient mask so it appears to gradually fade across the y axis?

  3. #3
    Junior Member
    Join Date
    Feb 2010
    Posts
    28
    Quote Originally Posted by moagrius View Post
    i'm not clear on what you want to achieve... do you want a gradient mask so it appears to gradually fade across the y axis?
    Thats right! I did some masking with setMask but it didnt do..Always geting that top of bitmaps border visible. I know thats either with treshold of bitmap, or some gradient masking, but just cant get that bitmap transparency right..
    Anyway You got my point, so, HOW?
    Thanx in advance!
    Last edited by duchman; 11-20-2010 at 06:46 AM. Reason: Better explanation

  4. #4
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    you create a shape, add a gradient fill, and mask the bitmap with that shape. both object need to have cacheAsBitamp set to true.

    PHP Code:
    var offset:int=0;
    var 
    bitmap:BitmapData = new BitmapData(330100,true,0x0);

    var 
    container:Sprite = new Sprite();
    container.x=0;
    container.y=190;
    addChild(container);

    var 
    image:Bitmap = new Bitmap(bitmap);
    image.cacheAsBitmap true;
    container.addChild(image);

    var 
    matrix:Matrix = new Matrix();
    matrix.createGradientBox(330100Math.PI 2);

    var 
    masker:Shape = new Shape();
    masker.cacheAsBitmap true;
    masker.graphics.beginGradientFill("linear", [00], [01], [0255], matrix);
    masker.graphics.drawRect(00330100);
    masker.graphics.endFill();
    container.addChild(masker);

    image.mask masker;

    addEventListener(Event.ENTER_FRAMEonEnter);
    function 
    onEnter(event:Event):void {
        
    offset++;
        var 
    point:Point = new Point(0offset);
        
    bitmap.perlinNoise(1501005500falsetrue8true, [pointpoint]);

    you can play with the ratios - [0, 255] - to define the position and degree of graduation

  5. #5
    Junior Member
    Join Date
    Feb 2010
    Posts
    28

    Resolved

    Oh thanx my friend, its so simple, (and thus perfect) meanwhile I actually did the code but it looks more like Ben Hur scenario..
    3months of beginers as3 course is still nothing..
    Yes, this is it,
    THANX for Tut, and May The Code Be With You!

  6. #6
    ___________________
    Join Date
    May 2004
    Posts
    3,174

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