Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash








Help With BitmapData


Hi to all!

I'm somehow new to AS3, and recently I stumbled upon some problem that I just can't figure it out. So I have 2 classes wich produces a simple ripple effect. The thing is that I just can't put some image as background for the effect. Right now I'm out of ideas so any help is appritiated.
Here is the code itsfelf:
Ripples.as (main document class)

Code:
package
{
import flash.display.Sprite;
import flash.events.*;
import RippleCanvas;

public class Ripples extends Sprite {

private var subobj:RippleCanvas;

public function Ripples() {

trace("Ripples started..");
var subobj = new RippleCanvas();
this.addChild(subobj);

}
}
}
RippleCanvas.as (subclass of Ripple)

Code:
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.*;
import flash.geom.*;
import flash.filters.*;

public class RippleCanvas extends Sprite
{

internal var sourceBmp:BitmapData;
internal var paintBmpData:BitmapData;
internal var paintBmpData2:BitmapData;
private var buffer:BitmapData;
private var paintBmp:Bitmap;
private var output:Bitmap;
private var brush:Sprite;
private var logo:Sprite;
private var filter:BitmapFilter;
private var filter2:BitmapFilter;
//public var Mis:Boolean;
private var dispFilt:BitmapFilter;

private var outputBmpData:BitmapData;
private var surface:BitmapData;

internal var pt = new Point(0,0);
internal var matrix1 = new Matrix();

public function RippleCanvas()
{
paintBmpData = new BitmapData(128, 98, false, 0x40);
paintBmpData2 = new BitmapData(128, 98, false, 0x40);

logo = new Sprite();

brush = new Sprite();
brush.graphics.beginFill(0xFFFFFF,1);
brush.graphics.drawCircle(0,0,4);
trace ("RIppleCanvas started..");

surface = new BitmapData(128, 98, true, 0x000000);
surface.draw(logo);
//var ty:picture = new picture();
//var sourceBmp:Bitmap = new Bitmap(picture);
//addChild(sourceBmp);
sourceBmp = new BitmapData(128, 98, false, 0x40);
buffer = paintBmpData.clone();
outputBmpData = new BitmapData(128, 98, false, 0x40);
scaleX = 8.0;
scaleY = 8.0;
//this.addEventListener(MouseEvent.MOUSE_MOVE, this.moveHandler, false, 0, true);
this.addEventListener(MouseEvent.MOUSE_DOWN, this.downEvent, false, 0, true);
this.addEventListener(MouseEvent.MOUSE_UP, this.upEvent, false, 0, true);
this.addEventListener(Event.ENTER_FRAME, this.update, false, 0, true);
paintBmp = new Bitmap(paintBmpData);
var cmat:Array = [ 1, 1, 1,
1, 1, 1,
1, 1, 1 ] ;
filter = new ConvolutionFilter(3, 3, cmat, 9, 0);
filter2 = new BlurFilter(4,4);
output = new Bitmap(outputBmpData);
// output.blendMode = BlendMode.ADD;
//paintBmp.blendMode = BlendMode.ADD;
addChild(output);
addChild(paintBmp);
// var tf = new TextField();
// tf.text = "testing123";
// addChild(tf);
disp = new DisplacementMapFilter(paintBmpData2, new Point(), 4, 4, 48, 48, DisplacementMapFilterMode.IGNORE );

this.filters = new Array(new BlurFilter(16, 16));

}
function update(e:Event)
{
if(parent!=null) {
//&& Mis==true){
var localPt:Point = parent.globalToLocal(new Point(parent.mouseX*0.125, parent.mouseY*0.125));
var m:Matrix = new Matrix();
m.translate(localPt.x, localPt.y);
sourceBmp.draw(brush, m, null, 'invert');
}
//trace (localPt,Mis);
paintBmpData.applyFilter(sourceBmp, paintBmpData.rect, pt, filter);
paintBmpData.draw(paintBmpData, matrix1, null, 'add');
paintBmpData.draw(buffer, matrix1, null, 'difference');
paintBmpData.draw(paintBmpData, matrix1, new ColorTransform(0, 0, 0.98609374, 1, 0, 0, 2, 0));
paintBmpData2.draw(paintBmpData, matrix1);
outputBmpData.applyFilter(surface, outputBmpData.rect, pt, disp);
buffer = sourceBmp;
sourceBmp = paintBmpData.clone();

}
public function downEvent(e:Event)
{
if(e.stageX == 0 && e.stageY == 0)
return;
//trace("ok",Mis);
var curPt:Point = parent.globalToLocal(new Point(e.stageX, e.stageY));
//var Mis=true;
e.stopPropagation();
}

public function upEvent(e:Event)
{
//var Mis=false;
e.stopPropagation();
}
}
}
Code is a bit in a mess right now




KirupaForum > Flash > ActionScript 3.0
Posted on: 03-08-2008, 08:13 PM


View Complete Forum Thread with Replies

Sponsored Links:

BitmapData::draw(BitmapData) Doesn't Seem To Support Alpha Channels
Hi all,

I have a BitmapData object with alpha channels, bm1, and would like to draw it into another BitmapData object, bm2. While I can draw bm1 into bm2, alpha channels do not seem to work. Here is some code to illustrate what I'm trying to do:

// create an all-green but semi-transparent BitmapData object (all alphas are set to 0x80 in the constructor)
var bm1:BitmapData = new BitmapData(100, 100, true, 0x8000FF00);

// create an all-white BitmapData object and display it
var bm2:BitmapData = new BitmapData(100, 100, true);
addChild(new Bitmap(bm2));

// draw bm1 into bm2 in the onTimer() callback function
bm2.draw(bm1);

I would expect bm2 to be light-green, because it's semi-transparent, but it's 100% green, i.e., 0xFF00FF00.

I already tried all blend modes, but blend modes didn't make a difference.

Any ideas?

Btw, what I'm trying to do is to extract an arbitrary collection of pixels (as opposed to a rectangle) from a bitmap (bm1) by copying it into another bitmap (bm2) and using alphas of 0x00 and 0xff to select the pixels to be extracted. Is there a better way to do this? (or any way for that matter? ;-)

Thanks!


-Bernd

View Replies !    View Related
[as3] Drawing BitmapData To Erase BitmapData
Hey there. I'm still working on my paint program, and I figured I'd try using the open source, raster-based drawing system from Bytearray.org to speed up drawing in some of my paint tools. The Raster class has some drawing functions that don't bother with anti-aliasing, so in some situations, implementing these methods results in faster code than relying on the Graphics package. I've gotten a nice speed boost from my rainbow paintbrush, which is pretty neat. Go open source!

Unfortunately, I can't get the eraser brush to work, even though its code is essentially the same as the other brushes'. And I've figured out why; the "erase" and "alpha" blend modes, which my vector-based eraser uses to erase the drawing surface, don't seem to work when you draw one BitmapData object onto another. I could put the BitmapData in a Bitmap object and draw that, but that's essentially converting raster data to vector, and then back to raster, which is far slower than any speed improvement I'd get from relying on the Raster class in the first place.

Has anyone here succeeded in using one BitmapData object to erase another, without "wrapping" the eraser BitmapData in a Bitmap object?

View Replies !    View Related
Bitmapdata
This works by creating a bitmap on the fly then loading 2 bitmaps with copypixels, but how do i work with a bitmap loaded in library from a file?

import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;

var bitmapData_1:BitmapData = new BitmapData(100, 80, false, 0x00CCCCCC);
var bitmapData_2:BitmapData = new BitmapData(100, 80, false, 0x00FF0000);

var mc_1:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc_1.attachBitmap(bitmapData_1, this.getNextHighestDepth());

var mc_2:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc_2.attachBitmap(bitmapData_2, this.getNextHighestDepth());
mc_2._x = 101;

mc_1.onPress = function() {
bitmapData_2.copyPixels(bitmapData_1, new Rectangle(0, 0, 50, 80), new Point(51, 0));
}

mc_2.onPress = function() {
bitmapData_1.copyPixels(bitmapData_2, new Rectangle(0, 0, 50, 80), new Point(51, 0));
}

//i want bitmap_data 1 and 2 to be the bitmaps from the library

View Replies !    View Related
[F8] BitmapData
Guys,

when I try to position the movieclip and check the color value, it returns 0x0 ...

I cannot leave the emptymovieclip in 0x, 0y positions

Can anybody help?

Below is my code.

the "mcColorGroup" is a movieclip which contains a bitmap of a color chart


Code:
var myBitmapData:BitmapData = new BitmapData (193, 193, false, 0x00ffffff);
var mc:MovieClip = this.createEmptyMovieClip ("test", this.getNextHighestDepth());
test.attachBitmap (myBitmapData, this.getNextHighestDepth());

myBitmapData.draw (mcColorGroup);


any help would be great.

I figured it out

View Replies !    View Related
[F8] Jpg To BitmapData
Hi,

I am trying to create a BitmapData object of a jpg that is loaded into a movieClip, so that I can then remove the jpg and have just the BitmapData of the image to manipulate. I have the original image loading into my temporary MC without any problems..and am using a listener to check to make sure that the image has been fully loaded before it moves onto creating an empty movie clip for the BitmapData... but for some reason the BitmapData isn't working as nothing shows up in my holderMC.. and it says the width of the holderMC is 0 when it should be something liek 367 for the 'surf.jpg' test image I am using. My code is below...I must be missing something stupid...can anyone spot what's wrong? Thanks! - b.


Code:
import flash.display.BitmapData;
stop();

_root.createEmptyMovieClip("tempMC", 1, {_alpha:0});

//set up MovieClipLoader
var theLoader:MovieClipLoader = new MovieClipLoader();
var theListener:Object = new Object();
theLoader.addListener(theListener);

theListener.onLoadStart = function(mc:MovieClip){
trace("started");
}

theListener.onLoadProgress = function(targetMC, lBytes, tBytes) {
trace("% "+Math.round((lBytes/tBytes)*100));
}

//init function as soon as image is loaded and ready to receive events
theListener.onLoadComplete = function(mc:MovieClip) {
trace("image loading into TempMC is complete!");

_root.createEmptyMovieClip("holderMC",_root.getNextHighestDepth());
bMap = new BitmapData(mc._width, mc._height);
bMap.draw(mc);
_root.holderMC.attachBitmap(bMap, _root.getNextHighestDepth());

_root.tempMC.removeMovieClip();
}

theLoader.loadClip("surf.jpg", _root.tempMC);

View Replies !    View Related
Bitmapdata
Hi

Lets say I have an image imported into flash of a character ( person ). I convert this to a movie symbol and call the instance "Character". I have the following code which creates a new bitmap movie clip:

import flash.display.BitmapData;

var NewBitmapData:BitmapData = new BitmapData(this.Character._width, this.Character._height, false, 0x00CCCCCC);

var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());

mc.attachBitmap(NewBitmapData, this.getNextHighestDepth());

This works great to create a grey box the same size as the character movie. But how do I then copy the the character image to the new clip area?

View Replies !    View Related
BitmapData Help
Is it possible to capture part of the screen within a Flash movie using the bitmapData and send the data to a server to be stored as a image e.g. jpeg

This would then be loaded back into Flash later.

The idea is that people can drag and drop items to a location within the movie (a storyboard) and this is then captured. Later they need to see a miniture version of this but cannot move or alter the original image created.

Anyone got any suggestions if this makes sense
thanks

View Replies !    View Related
Bitmapdata
This works by creating a bitmap on the fly then loading , but how do i work with a bitmap loaded in library from a file?

import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;

var bitmapData_1:BitmapData = new BitmapData(100, 80, false, 0x00CCCCCC);
var bitmapData_2:BitmapData = new BitmapData(100, 80, false, 0x00FF0000);

var mc_1:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc_1.attachBitmap(bitmapData_1, this.getNextHighestDepth());

var mc_2:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc_2.attachBitmap(bitmapData_2, this.getNextHighestDepth());
mc_2._x = 101;

mc_1.onPress = function() {
bitmapData_2.copyPixels(bitmapData_1, new Rectangle(0, 0, 50, 80), new Point(51, 0));
}

mc_2.onPress = function() {
bitmapData_1.copyPixels(bitmapData_2, new Rectangle(0, 0, 50, 80), new Point(51, 0));
}

//i want bitmap_data 1 and 2 to be the bitmaps from the library

View Replies !    View Related
BitmapData
I'm hoping somebody can explain why this would work locally, but not online:

Code:
import flash.display.BitmapData;
this.createEmptyMovieClip("holder_mc",this.getNextHighestDepth());
loader = new MovieClipLoader();
loader.addListener(this);
loader.loadClip("photos/Sample1.jpg",holder_mc);
function onLoadInit() {
myBitmap = new BitmapData(holder_mc._width, holder_mc._height,true,0x00FFFFFF);
myBitmap.draw(holder_mc);
holder_mc.attachBitmap(myBitmap,this.getNextHighestDepth);
}
And yes, the image is properly placed on the server.

View Replies !    View Related
BitMapData
can anyone help out, duplicating mClips and bitmapdata. cant seem to get it to work when im making multiple movieclips

for (var i:Number = 0; i < $parsedObject.section[0].pic.length; i++)
{
var mHolder:MovieClip = b1.duplicateMovieClip("mClip_"+i,_root.getNextHigh estDepth());
var mHolderBMdata:MovieClip = b2.duplicateMovieClip("mClipBMdata_" + i, _root.getNextHighestDepth());


b1._visible = false;

oListener.onLoadInit = function(mHolder:MovieClip):Void
{
bmap = new flash.display.BitmapData(mHolder._width, mHolder._height, true, _root.getNextHighestDepth());
bmap.draw(mHolder);

mHolderBMdata.attachBitmap(bmap,300+2*i);
//mHolderBMdata._y = mHolderBMdata._x = 160;

mLoader.unloadClip(mHolder);
//img._alpha = 10;
mHolderBMdata._x = i*-33;
//mHolder._visible = false;

}
}

View Replies !    View Related
Example About Bitmapdata?
First of all, i am drawing a box with graphics api.....that is moveTo, lineTo,...

The top coordinates of the box are dependent on the distance from mouse thereby making it increase or decrease in size. Now the problem is i want to fill the shape/box/square with a bitmap, so i tried using beginBitmapFill(), but the problem is i don't know how can i make the bitmap always stretch/skew to fill the shape perfectly? That's why i am asking for a example, code, or theory/hint on how to fit the bitmap perfectly within the ever-changing shape! Please help!

View Replies !    View Related
BitmapData Help
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Matrix;
import flash.geom.ColorTransform;

myColorTransform = new ColorTransform();
myMatrix = new Matrix();
//area=new Rectangle(0,40,50,50);
myBitmap = new BitmapData(20,20,true,0x00FFFFFF);
var xRect:Number = 0;
// animation_mc is 400 x 200. i am just tring to get the first row of blocks
for(i=0;i<20;i++) {
var area:Rectangle = new Rectangle(0,xRect,20,20);
trace(area);
var t:MovieClip = this.createEmptyMovieClip("holder_mc"+i,this.getNextHighestDepth());

t.attachBitmap(myBitmap, 1);
myBitmap.draw(animation_mc,myMatrix,myColorTransform,"normal",area);
t._visible = true;
//trace(this["holder_mc"+i]);

t._x = xRect;
t._y =20;
xRect += 20;
}
stop();

--------------------------------------------------------------------------------------------------------------
I have a movieclip "animation_mc" that i want to manipulate by slicing up the movieclip into individual movieclips. I am using the bitmapdata class to do this but when i run this, the "t" movieclip only slices the first square and then repeats itself. I am using the rectangle class to incremently move this slice over but it does not work. Any ideas? Thanks





























Edited: 10/12/2007 at 05:54:51 PM by edHPU

View Replies !    View Related
Get BitmapData From Jpg
hey everyone, how are you? :)

so if i does this right:

loader = new Loader();
var request:URLRequest = new URLRequest( "/path/to/bunny.jpg" );
loader.load(request);

then i gets me a nicde little bunny jpg. now presumably that jpg has a BitmapData object. all i wanna do is: get it.

so how do i do that? :)

View Replies !    View Related
BitmapData
Hello everybody.. I have a problem with the new BitmapData class

I have a BitmapData object(used for copying a mc) but I want the rectangle associated to start from a different value than 0, 0. Is there any other way to change this rather than changing the coordinates of the movie clip it will copy?

I use the .draw method to copy from the source mc

Thanks

View Replies !    View Related
Help With BitmapData
Hi everyone, I need some help

I've managed to texture a geosphere without mayor cpu usage and perforance loss, but tehre are still more ways to improve it

I need a good tutorial on Flash's bitmapData from the basics, because masking duplicated movie clips is way slower than that

can anyone recommend me some related urls? I only found pixel transmition ones, but they are a bit complicated to start with when you are unfamiliar with bitmapData

thanks in advance

View Replies !    View Related
Flv And BitmapData
Hello !

I try to make a simple copy of a flv video in a new MovieClip using the BitmapData class.
Here is my code :

Code:
var video1:MovieClip = this.attachMovie("mcVideo","videoMC",1);
var objVideo = video1.v;

var _nc:NetConnection = new NetConnection();
_nc.connect(null);
var _ns:NetStream = new NetStream(_nc);
objVideo.attachVideo(_ns);
_ns.play("vid6.flv");

var bmd:BitmapData = new BitmapData(320,256);
video1._visible = false;

//video copy container
var mc:MovieClip = this.createEmptyMovieClip("try1",this.getNextHighestDepth());
mc._x = 400;
mc._y = 300;

this.onEnterFrame = function(){//make copy
bmd.draw(objVideo);
mc.attachBitmap(bmd,1);
}
The problem is that the "mc" movieClip show a half-sized video !!!
I don't understand... Does someone has an idea ?

Thanks

View Replies !    View Related
BitmapData To Png
All i want is a png file with pixels with the same value as the ones from my BitmapData,Is there any way?Its just for my personal use, so i cant relly on a server with php to do it...but i can try if its my only choice...cant some air application do this?Thanks

View Replies !    View Related
Bitmapdata
can any one sujjest a tutorial for bitmap data for beginners

kind regard

surf

View Replies !    View Related
BitmapData Is Just So Fun.
I have a bunch of random tests I've done, and they're just fun to make. This is one of 'em, and I'll post code in the morning when I have it in front of me. Nothing fancy, but I think it's fun.

http://ragonadesign.com/avoid_grid_A...dGrid_AS3.html

Make sure to run your mouse through the particles at the bottom of the graphic to play with it.

Everyone post your fun BMD experiments, there must be a ton out there.


ActionScript Code:
package  {    import flash.display.Bitmap;    import flash.display.BitmapData;    import flash.display.Stage;    import flash.display.Sprite;    import flash.display.MovieClip;    import flash.filters.BlurFilter;    import flash.filters.ColorMatrixFilter;    import flash.geom.Point;    import flash.geom.Rectangle;        import flash.events.Event;            /**    * ...    * @author rragona    */    public class Main extends Sprite    {                private var mStage:Sprite = new Sprite();        private var sObjects:Array = new Array();                private var minDist:Number = new Number(70);        private var f:Number = new Number(0.6);        private var k:Number = new Number(0.15);                private var bmd:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0xFFFFFF);                private var bf:BlurFilter = new BlurFilter(2, 2, 3);        private var cmf:ColorMatrixFilter = new ColorMatrixFilter([1.3, 0, 0, 0, 0,                                                                   0, 1.1, 0, 0, 0,                                                                   0, 0, 1, 0, 0,                                                                   0, 0 ,0 ,0.97 ,0])        private var bm:Bitmap = new Bitmap(bmd);                                public function Main()         {            init();        }                private function init():void        {            initBM();            initStage();            initGrid();        }                private function initBM():void        {            addChild(bm);            addEventListener(Event.ENTER_FRAME, bmdLoop);        }                private function initStage():void        {            addChild(mStage);                        mStage.x = stage.stageWidth / 2 - 25;            mStage.y = stage.stageHeight  - 200;        }                        private function bmdLoop(e:Event):void        {            bmd.draw(this);            bmd.applyFilter(bmd, bmd.rect, new Point(0, 0), bf);            bmd.applyFilter(bmd, bmd.rect, new Point(0, 0), cmf);            bmd.scroll(2, -25);        }                private function initGrid():void        {            for (var z:int = 0; z < 15; z ++)            {                for (var q:int = 0; q < 15; q ++)                {                    var myCirc:MovieClip = new MovieClip();                                        myCirc.graphics.lineStyle(1, 0x222222);                    myCirc.graphics.drawCircle(0, 0, 0.5);                                        myCirc.x = z * 5;                    myCirc.y = q * 5;                                        myCirc.startX = myCirc.x;                    myCirc.startY = myCirc.y;                    myCirc.vx = 0;                    myCirc.vy = 0;                                        myCirc.addEventListener(Event.ENTER_FRAME, avoidMouse);                                        mStage.addChild(myCirc);                    sObjects.push(myCirc);                }            }        }                private function avoidMouse(e:Event):void        {            var curClip:Object = e.target;                        var difX:Number = new Number();            var difY:Number = new Number();            var v2:Number = new Number();                        difX = mStage.mouseX - e.target.x;            difY = mStage.mouseY - e.target.y;                        v2 = Math.sqrt(difX * difX + difY * difY);                        if (v2 < minDist)             {                curClip.vx -= (difX/v2)*minDist*k;                curClip.vy -= (difY/v2)*minDist*k;            }                        curClip.vx += (e.target.startX - e.target.x) * k;            curClip.vy += (e.target.startY - e.target.y) * k;                        e.target.x += curClip.vx;            e.target.y += curClip.vy;                        curClip.vx *= f;            curClip.vy *= f;        }                    }    }

View Replies !    View Related
Can Anyone Help Me With Bitmapdata?
hello,

i have a sprite which is dragable. after draging i would like to extrat a part of this sprite into a new bitmapdata but somehow it takes allways the same part. this is the part to create a new bitmapdata.

_sBmp is the dragable sprite and _maske is a rectangle to indicate the size i want to cut. can anyone give me a hint?


Code:

var myResponder:Responder = new Responder (onStatusErrorP, onSuccess);               
      
            var myBitmapSource:BitmapData = new BitmapData ( 250, 250, false, 0x000000 );
            
               myBitmapSource.draw ( _sBmp, null, null, null, _maske, true) ;               
               
               var qualityValue:Number = 50;
               
               // create the encoder with the appropriate quality
               var myEncoder:JPEGEncoder = new JPEGEncoder( qualityValue );

View Replies !    View Related
BitmapData
Hi all, i'd like loading a image and separate all your pixels. I'm trying using BitmapData and a ByteArray for hold all image pixels, but i can't move this pixels. How i can do this? It change the position of the pixels.

View Replies !    View Related
BitmapData And Web Cam
Ok, guys. I finally made my way back to GTAL.

Anyhow, I have a problem with my webcam App.

First off, here's the source.
I havent uploaded it to a server yet so you need 2 things on the stage. An empty movieclip called "holder". And a new video object called "cam".

My issue is with RAM and the BitmapData objects.

Essentially, what my code does, is take bitmapdata screenshots of the video playing in real time. It creates an array, and stores X amount of frames inside that array. Then as it plays, it attaches each of those bitmapdata images to the stage on top of the original video and sets their transparency to be 100/X. This creates an afterimage, referred to in photography, as Mutliple exposure.

My major issue is with RAM usage. The app uses waay too much RAM... Sometimes exceeding 60% of the processor. I believe the reason is present in the bitmapdata area, but im not entirely sure how to bypass using bitmapdata objects for this project.

If theres anything that doesnt make sense, please post and let me know, i'll try to better explain.

Code:

import flash.display.BitmapData;
import flash.geom.ColorTransform;

var cMode:Boolean;
var frames:Number = 5;
var arrFilter:Array = new Array;
var i:Number = 0;

active_cam = Camera.get();
cam.myVideoObject.attachVideo(active_cam);
active_cam.setMotionLevel(10, 500);
cam.cacheAsBitmap = true;
active_cam.smoothing = true;

active_cam.onActivity = function(mode)
{
    cMode = mode;
   if(cMode)
   {
      onEnterFrame = process;
      trace("Started");
   }
   else
   {
      delete onEnterFrame;
      trace("Stopped.");
      
   }
}

function process()
{
   trace("processing...");
   i++;
   var bmd:BitmapData = new BitmapData(640,480,true);   
   bmd.draw(cam);
   arrFilter.push(bmd);

   if(arrFilter.length == frames+1){
      bitIMG = arrFilter.shift();
      holder.createEmptyMovieClip("bitIMG_"+i,i);
      holder["bitIMG_"+i].attachBitmap(bitIMG,i);
      holder["bitIMG_"+i]._alpha = 100/arrFilter.length;
      holder["bitIMG_"+(i-frames)].removeMovieClip();
   }
}

View Replies !    View Related
BitmapData Doubt
well you know when you use the threshold you can replace the value that matches the condition, but i dont want to replace it(because my condition is to select those which dont match the color range given), i just want to take those pixels and generate a new image but keeping the same pixels so i can get a new image with the same colors...
by the way... why is it that i cant use the generated bitmap to mask another object?

View Replies !    View Related
Tint Bitmapdata HELP
Hi,
i have a bitmap that is tiled to fill the background.
How would i 'tint' the tile gradually with the press of a button.
eg. entering a certain section of the site gradually changes the tile shade to another color so that you can still see the picture on the tile
This is the code for the filling that works fine

import flash.display.BitmapData;

Stage.scaleMode = "noScale"
Stage.align = "TL";

var tile:BitmapData = BitmapData.loadBitmap("tile");

function fillBG() {
this.beginBitmapFill(tile);
this.moveTo(0,0);
this.lineTo(Stage.width,0);
this.lineTo(Stage.width,Stage.height);
this.lineTo(0,Stage.height);
this.lineTo(0,0);
this.endFill();
}

fillBG();

var stageL:Object = new Object();
stageL.onResize = function() {
fillBG();
}

Stage.addListener(stageL);
stageL.onResize();


i've tried the

import flash.geom.ColorTransform;

and attached the bitmap to an MC and then used

tile.colorTransform(tile.rectangle, new ColorTransform(1, 0, 0, 1, 255, 0, 0, 0));
but this colors the whole tile completely where the pattern dissapears(and not gradually)

Any ideas

Thanks

Trinitee

View Replies !    View Related
BitmapData = CopyScreen?
Hello

Is there any way I can use BitmapData to copy my stage or a movieclip then 'paste' it into another one?

Thanks

Kaan.

View Replies !    View Related
Using BitmapData Object
What I need to do is use the BitmapData object to duplicate the below code, basically I need to use the clone() method to make copies of the image after I have loaded it the first time instead of loading it 6 times. I have noticed that even though flash has image cache sometimes it doesn't cache the image and has to load it all 6 times. A possible reason for it not being cached is because the image is loading from non cacheable ASPX pages

thumbPaint is a string which contains the path to the thumb being loaded, I need to replicate the code below using BitmapData so the image is only loaded once.

_root.thumbContainer.paint1.loadMovie(thumbPaint);
_root.thumbContainer.paint2.loadMovie(thumbPaint);
_root.thumbContainer.paint3.loadMovie(thumbPaint);
_root.thumbContainer.paint4.loadMovie(thumbPaint);
_root.thumbContainer.paint5.loadMovie(thumbPaint);
_root.thumbContainer.paint6.loadMovie(thumbPaint);

View Replies !    View Related
[f8] BitmapData Problem
Why this dosen't work?


Code:
import flash.display.BitmapData;

class Engine.Game.ImageLoader
{
//-------------------------------------------------------------------------
// Constructor
//-------------------------------------------------------------------------
public function ImageLoader(fp_sUrl:String)
{
trace ("[DBG] ImageLoader::Class created");
var bmp:BitmapData = new BitmapData(300,300,true,0x00FFFFFF);
}
//-------------------------------------------------------------------------
}
I get this error message
"The class or interface 'flash.display.BitmapData' could not be loaded."

View Replies !    View Related
BitmapData Empty
I have some code that continually requires redrawing the BitmapData to present onscreen. However, I can't find anyway to make the existing BitmapData to wipe itself clean to an empty state so that I can use copyPixels() on it like a new BitmapData should.
My current method is to reassign the variable to a new BitmapData, which just plains leaves a lot of BitmapData's floating around for the garbage collector. So, is there anyway to empty an existing filled BitmapData? Thank you in advance.

View Replies !    View Related
Problem With BitmapData
Ok so I'm having problems with the bitmap data class. I am creating a marquee of images and duplicating them using the draw method. This works fine locally, but when uploaded it does nothing. I figure it has something to do with the fact the I have all my media on a separate server, but I thought I had all the security settings right to have it work. I have the domain allowed in the security settings. I have the cross domain policy file in place on the media server and loaded. Any ideas? Right now I have it jury rigged using the load clip method, but if someone leaves their browser on the page the flash with just eat bandwidth.

View Replies !    View Related
Flash 8 BitmapData
I'm using Flash 8, with this code in the first frame:

import flash.display.BitmapData;

rissa._x=Stage.width/2;
rissa._y=Stage.height/2;


var plaid:BitmapData.loadBitmap("plaid");

function fillBG(){
this.beginBitmapFill("plaid");
this.moveTo(0,0);
this.lineTo(Stage.width,0);
this.lineTo(Stage.width,Stage.height);
this.lineTo(0,Stage.height);
this.lineTo(0,0);
this.endFill(0,0);
}

var StageL:Object=new Object();
StageL.onResize= function(){
fillBG();

rissa._x=Stage.width/2;
rissa._y=Stage.height/2;
}
Stage.addListener(StageL);

When I publish the file, I'm getting the following error message in the Output panel:

**Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 7: The class or interface 'BitmapData.loadBitmap' could not be loaded.
var plaid:BitmapData.loadBitmap("plaid");

Total ActionScript Errors: 1 Reported Errors: 1



Any answers to why this error message is appearing? Any assistance is immensely appreciated....

View Replies !    View Related
Transform BitmapData To 1-bit?
I need to transform a Bitmap object to 1-bit, basically in photoshop terms convert it to grayscale with 100% contrast resulting only in white and black pixels. I'm pretty sure it can be done with the BitmapData.colorTransform method but I can not wrap my tiny brain around the flash.geom.ColorTransform object, it's got me totally baffled. Any pointers?

View Replies !    View Related
[F8] BitmapData + Transparency
Hi,

I am trying to load in a png that contains transparency into a movieclip, which I then 'replicate' into a BitmapData version, and erase the original png... I have all of it working properly, except that the section that is supposed to be transparent is showing up white... is there a way around this?

Thanks!
-b.

View Replies !    View Related
BitmapData Question
Once I have drawn from a loaded image to a BitmapData instance, is there any way of converting the BitmapData back to an image so that I can then dispose of the Bitmap?

Thanks

View Replies !    View Related
Problem With BitmapData
Hi,

I've started writing this class that draws a stripe of random color across the stage within certain parameters. I'm calling an instance of this class and then calling it's newLine() method 25 times in a loop with greater x coords passed in each time, to draw these stripes across the stage.

Sometimes it completely works, no errors, but often it will stop after a seemingly random number of cycles through the loop and give me this error:

ArgumentError: Error #2015: Invalid BitmapData.
at flash.display::BitmapData()
at LineMaker/newLine()
at lineMaker_test_fla::MainTimeline/frame1()

Here's the class code:


PHP Code:



package
{
    
import flash.display.MovieClip;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.DisplayObject;
import flash.geom.Rectangle;
    
public class LineMaker
    {

    private var lineCount:Number = 0;
    private var target_mc:MovieClip;
    private var bgWidth:Number;
    private var BMPD:BitmapData;
    private var BMP:Bitmap;
    
    //constructor
    public function LineMaker(target:MovieClip, bgWidth:Number)
        {
        this.target_mc = target;
        this.bgWidth = bgWidth;
        }
    
    //create a bitmap line
    public function newLine(wMax:Number, h:Number, xInterval:Number, xPos:Number, yPos:Number)
        {
        var w:Number = Math.random() * wMax;
        var xPosition:Number = xPos + Math.random() * xInterval;
        var thisColor:Number = getRandomColor();
        this.BMPD = new BitmapData(w, h, false, thisColor);
        this.BMP = new Bitmap(this.BMPD);
        var BMPref:DisplayObject = this.target_mc.stage.addChildAt(this.BMP, 0);
        BMPref.x = xPos;
        }
    
    private function getRandomColor(): Number
        {
        var color:Number = Math.random() * 0xFFFFFF;
        return color;
        }
    
    }
}




Can anyone explain why I might be getting this error? I thought it might have something to do with the way I'm getting my random color value, but the error doesn't seem to be at all correlated to the color value at the time of failure...

Many thanks!

View Replies !    View Related
[as3]please Tell Me How To Get BitmapData For A Moviclip?
Code:
var bmdH1 = new BitmapData(150,128);
bmdH1.draw(bBack);
var bmd = new Bitmap(bmdH1);


I tried doing the following code, where "bBack" is the linkage name of a movieclip in my library. but i am getting the following error:-


Code:
1067: Implicit coercion of a value of type Class to an unrelated type flash.display:IBitmapDrawable.


Any suggestions??

View Replies !    View Related
Creating New Bitmapdata
What i am trying to do is to create new bitmap objects from externally loaded png's in AS2, the way i am trying to do it is to first create empty MC's loading the png's into them, then copy these MC's into new Bitmapdata objects but it isn't working.


Code:
var images = ["img1.png","img2.png"]
var imagesBMP:Array = new Array();
var home = this;

//load Images listed in images array into new MC's
function loadImages(){
for(i=0;i<images.length;i++){
var t = home.createEmptyMovieClip("holder"+i, i);
loadMovie("images/"+images[i], "holder"+i);
}
}

//create Bitmap copies of the MC's passed into function
function createBitmap(mc1){
mcBMP = new BitmapData(mc1._width, mc1._height, true, 0x00000000);
mcBMP.draw(mc1);
imagesBMP.push(mcBMP)
}

loadImages();

//if the images have been loaded pass the new MC's containing the Images to createBitmap function
this.onEnterFrame = function(){
if(home["holder0"]._width){
for(i=0;i<images.length;i++){
var t = home["holder"+i];
createBitmap(t)
}
delete this.onEnterFrame;
}
}


I would love some help if anyone knows whats wrong with this?

cheers

View Replies !    View Related
Bitmapdata Problem
i don't know why my line width doesn't decrease after my fertig flag is set to 1

here's what it looks like:
http://ize.badne.ws/meh/worm.swf

and the fla:
http://ize.badne.ws/meh/worm.fla

if thickness is above 70 it sets the fertig flag to 1 and then SHOULD decrease the line width again... it doesn't though.... i have no idea why because the thickness variable IS decreased

the (crappy) code:

Code:
//when fertig is 1 and thickness is still over 10 it should decrease the width again...
//it doesn't tho :(

var worm:Sprite = new Sprite();
addChild(worm);
worm.graphics.lineStyle(3,0xff0000);
worm.x=300;
worm.y=0;

var ypos:int=0;
var xpos:int=0;
var thickness:Number=1;

var bmap=new flash.display.BitmapData(600,400,true,0x00000000);

var fertig:Boolean=0;

var myMatrix:Matrix = new Matrix ();

var tempBitmap:Bitmap=new Bitmap(bmap);
stage.addChild(tempBitmap);

myMatrix.translate(300-(thickness/2),0);

var myRandom:Number;

stage.addEventListener(Event.ENTER_FRAME, gameloop);
function gameloop(myevent:Event):void {
myRandom=5*Math.random();
worm.cacheAsBitmap=true;
tempBitmap.cacheAsBitmap=true;
if (fertig!=1) {
worm.graphics.lineStyle(2,0x00ffff);
worm.graphics.lineTo(xpos+thickness+myRandom,ypos);

thickness+=0.5;
trace(thickness);
bmap.draw(worm,myMatrix);
myMatrix.translate(-myRandom+2.25,0);
bmap.scroll(0,1);
} else {
if (thickness>10) {
trace(thickness)
worm.graphics.lineStyle(2,0x00ff00);
worm.graphics.lineTo(xpos+thickness+myRandom,ypos);
thickness-=0.5;
bmap.draw(worm,myMatrix);
myMatrix.translate(-myRandom+2.25,0);
bmap.scroll(0,1);
} else {
tempBitmap.y+=1;
}
}

if (thickness>70) {
fertig=1;
}

worm.graphics.clear();
}

View Replies !    View Related
Colorizing With BitmapData?
I have a grasp on the bitmapData API and how it's used, but I'm trying to figure out how to dynamically colorize an external image (loaded into a MC) at run-time.

For instance, I have an image of a white flower with the background removed. I'd like to be able to change it from white (the original color) to a pre-defined Red, Green, Blue, etc., and preferrably even let the user choose from a palette of colors (i.e. they may or may not be known at run-time).

Any programmatic approaches to this? TIA for any advice.

Ciao,

-Jei.

View Replies !    View Related
Bitmapdata Conflict
I posted this over at the adobe forums, but I get the distinct impression that no one has any idea what they're doing over there.

So I was working on a small program to load up and view photos, but I'm getting some really weird conflicts.

I can load my image fine, and I also have a Stage listener set to put the photo in the middle on resize. All of this works fine until I drop in a UI Component or import the code for it. Then I get one copy of the bitmap data just sitting at (0,0), but on the top level, and another that goes where it's supposed to (centering on resize) below it. If anyone has any clues as to what about the UIObject class is messing with me, I'd love some help.

http://www.neverwake.net/image_error.html (visit that, then resize your window a little. There shouldn't be two images.

I've included the FLA and everything. I've done everything I know to do. Please help

View Replies !    View Related
BitmapData Problem
I have a problem trying to save a movieclip as jpg, the movie clip that I need to save is a complex movieclip with a deep hierarchical tree of embedded movieclips, I'm using the BitmapData class, but it asppears to have a bug, when I try to capture a section or the entire movie because it only saves an incomplete snapshot, it occurs always, also I saw that that class have problems when there are elements with negative positions.

View Replies !    View Related
BitmapData _x, _y Postion
Does any one know how to set a new _x and _y position to BitmapData that has been attached or loaded into a MovieClip?

I loaded a BitmapData from the library and attached it inside of a MovieClip. The BitmapData is 100 wide by 100 tall. I want to center the BitmapData to the center of the MovieClip so that it's center point will be in the middle of the MovieClip. BitmapData _x = -50, _y = -50.


Code:
var test_bmp:BitmapData = BitmapData.loadBitmap("libraryBitmap");
this.test_mc.attachBitmap(test_bmp, 1);
test_bmp.rectangle.x = -50;
test_bmp.rectangle.y = -50;

View Replies !    View Related
Is It Possible To Print Out BitmapData?
Hi,

I have bitmapData from a camera which is attached to a movieclip. Does anyone know if it is possible to print out the bitmapData in flash using the print command? Any examples you know of?

Thanks!

-Dan

View Replies !    View Related
BitmapData, Textfield And CSS
Hola people!

Here is my dillema. I need to present articles in Flash. It needs to show pullquotes as "div" inserts... So, the text would wrap around the block of text so that it looks like the magazines do.

See sample here

Those pullquotes are images. I don't want them to be (More work in terms of PHP to create those thumbnails)...
I was thinking - Is it possible to use the BitmapData class and add text to it dynamically, and then put that into the textfield? something like... <img src="myBitmap">?

Can anone shed some light on this for me? Am I wasting my time? ANy direction would be greatly appreciated.

Thanks in advance.

View Replies !    View Related
BitmapData.threshold
Hi there, I've been having real problems with BitmapData.threshold. I'm simply trying to turn white pixels -> transparent, but I just can't seem to achieve this.

Documentation for this is also lacking and I therefore plead fo someone's help. Is driving my bananas!

Here is my current code:


Code:
mask_bmp.threshold( soil_bmp, new Rectangle( 0, 0, soil_bmp.width, soil_bmp.height ), new Point( 0, 0 ), ">=", (30/100)*0xFFFFFF, 0xFFFFFF,0xFFFFFF, false );

View Replies !    View Related
BitmapData And Scale9Grid
Hi all,

I've been trying to use the scale9Grid property with BitmapData.

I know that scale9Grid doesn't work with child Movieclips, but does this relate to BitmapData Objects aswell?

What I'm doing is taking an imported images (convert to BitmapData), and combining it to form one image. this is then attached to the movieclip via attachBitmap().

Is there a way to use scale9Grid with an attached Bitmap?

If anyone knows of a way, help would be appreciated

Cheers.

View Replies !    View Related
BitmapData Draw
I am using the BitmapData object and its draw method on a movieClip that has a textfield inside it. When I try to animate it after it has been drawn it is jumpy if animated at anything longer than a second, Sometimes even shorter than a second it gets jumpy. I have tried so many things to try and stop this but it just keeps happening. Has anyone had this problem and might know how to solve it. If I use just a solid it seems to work ok but with text it becomes jumpy. At 1 second animation sliding across the screen it jumps into place when it comes to its final position. I'm using the same Penner ease equations that I have always used.

Please anyone out there that can help, this is really doing my head in after 2 days of trying to get it to work.

Here is how i'm creating my bitmapData object.

Code:

private function createBitmapData(source, containerName:String):MovieClip{

var bitmapHolder:MovieClip=mcHolder.createEmptyMovieClip(containerName,mcHolder.getNextHighestDepth());
var bmpData = new BitmapData(source._width, source._height, true, 0x00FFFFFF);
bmpData.draw(source);
bitmapHolder.attachBitmap(bmpData, 1, "never", true);
return bitmapHolder;
}

View Replies !    View Related
BitmapData Altering...
Ok, I should try and explain what I'm trying to do first. I have the core functions pretty much worked out and now I just need help tweaking some of the things...

I'm making a file that displays a picture and you can click your mouse and drag and it will erase the picture, displaying those parts erased in the background. Basically, I load a bitmap and change the alpha of individual pixels as you mouse over it. I have this part working. (And I'll display the code down below...).

I have 2 questions --

1. After the mouse is released, I need the script to use gotoAndPlay(x) to show a different movie clip then come back to the original beginning but still have the updated bitmap file (with the different alpha channels and all....). But when I recall the same frame it just reloads my bitmap in its entirety. Basically i need to find out a way to pass the updated bitmap and recall it when i come back to that frame after displaying another movieclip after the mouse is released.

2. this one isn't really important. i'm just trying to figure out a way to save space. i'm using the function loadbitmapData.... and these images I can make in flash as a graphic symbol... is there a way to do all my coding with just the graphic symbol instead of importing an actual image file. for example, i can't use the linkage ID for a graphic symbol in loadbitmap (i assume because it's not rasterized and it's a vector).

here's the code with everything working...


Code:
Stage.scaleMode = 'noScale';

var tool; // used to determine the current tool
var toolsize = 40; // size used for tools (width = height)
var tooloffset = toolsize/2; // offset for cursor placement in using tool
var basepoint = new flash.geom.Point(0, 0); // 0,0 point

// two bitmaps are used with the image being manipulated
// the first, origbmp contains the original image, unaltered
// the second, drawbmp is the working image seen and
// altered on the screen
var origbmp = flash.display.BitmapData.loadBitmap("linkage_ID_HERE");

var drawbmp = new flash.display.BitmapData(origbmp.width, origbmp.height, true, 0);
// drawbmp starts with a copy of the original
drawbmp.draw(origbmp);

// a bitmap is used for erasing
var erasebmp = new flash.display.BitmapData(toolsize, toolsize, true, 0);

// create a movie clip, image_mc, to hold the
// image being erased
this.createEmptyMovieClip("image_mc",2);
// position the image to the left
image_mc._x = 0;
image_mc._y = 0;

// attach the drawing bitmap data object to image_mc
image_mc.attachBitmap(drawbmp, 1);

// -------------------------------------


function setEraseShape(eraseShape_mc){

// erasebmp needs to be transparent where it is supposed to
// be erasing drawbmp. First fill it with solid white
erasebmp.fillRect(erasebmp.rectangle,0xFFFFFFFF);
// then draw the shape (black) into the bitmap
erasebmp.draw(eraseShape_mc);
// copyChannel is used to convert the shape of the tool
// just added into erasebmp into its alpha channel
erasebmp.copyChannel(erasebmp,erasebmp.rectangle,basepoint,1,8);

}

// -------------------------------------

// WORKING WITH IMAGE

// pressing image to erase or redraw
image_mc.onPress = function(){
//or you can use (for touch screen ONLY)
//image_mc.onMouseMove = function(){

// assign onMouseMove event handler
this.onMouseMove = useEraserMouseMove;

// initiate onMouseMove handler to work with onPress
this.onMouseMove();
}

// releasing after erase
image_mc.onRelease = image_mc.onReleaseOutside = function(){

// remove onMouseMove handler
delete this.onMouseMove;

}

// onMouseMove event handler for erasing
function useEraserMouseMove(){

// devise an offset based on the mouse's
// position in image_mc and tooloffset
var offset = new flash.geom.Point(image_mc._xmouse - tooloffset, image_mc._ymouse - tooloffset);

// devise a drawing rectangle the size of the
// the drawing tools at the offset's location
var drawRect = new flash.geom.Rectangle(offset.x, offset.y, toolsize, toolsize);

// next, copy pixels from the drawbmp back onto itself
// (makes for no change) but use erasebmp as the alphaBitmap
// this will add the alpha channel information from erasebmp
// into drawbmp erasing pixels from drawbmp in the shape of erasebmp
drawbmp.copyPixels(drawbmp, drawRect, offset, erasebmp, basepoint, false);
finalbmp.copyPixels(drawbmp, drawRect, offset, erasebmp, basepoint, false);

// update after each mouse movement
updateAfterEvent();
}


// -------------------------------------

// initialize
setEraseShape(eraseShape_mc);
stop();
thanks for any help and i hope i was clear enough as to what i needed...

View Replies !    View Related
Bitmapdata Smoothing
I don't know if anyone here can help me. Most forums haven't been able to. I'll assume you guys know how to smooth an image using the bitmapdata class then redrawing the image.

I have an image that fills the background of my flash site and the image resizes, centers and is smoothed using bitmapdata when the stage resizes. The problem is bitmapdata draws a white edge on the image when it resizes. This changes the width and height of the image making my algorithms to center and resize the image useless. Does anyone here think they can help? If so I'll send you my code to take a look at.

Thanks.

View Replies !    View Related
BitmapData Class To JPG
I'm making a flash application that accepts a user's input and outputs a JPEG. Having some trouble with the pieces in between.

The app allows the user to select a few MovieClips, which are just imported Illustrator files. The user changes the color, position, and so on.

Now onto the JPG export...the JPG export libraries I've seen (like as3corelib and BitmapExporter) accept BitmapData as an input. But I don't understand how to translate my collection of MovieClips into a BitmapData format. I just want to take a snapshot of the screen, make that a JPG, and pass it onto the user.

I'm missing something that's probably elementary, and I know this has been solved before, just can't find where - can someone give me an assist?

View Replies !    View Related
Scrolling Bitmapdata
Hi there,

I am trying to mimick the scrolling that this site shows at the top of the page

http://www.skinsfootwear.com/skinsbiz/

The images that I am loading into the scroller are dynamically specified so what I am doing is loading them all onto a movieClip and then using the Reflect class to make the reflection underneath. So once all my images are loaded I am left with a BitmapData object that is how I want it to look.

This part I am happy with.

However, when I start scrolling it my CPU level jumps up to 50%. Now I think I am scrolling correctly, basically I have a backbuffer which I scroll to the left with BitmapData.scroll (-2, 0);

Then I copy some pixels from the original image to the back buffer to bring in the area that left the screen on the left to the right hand side of the image.

Rinse and Repeat.

It all works, but its not as smooth as the version on the specified site. Does anyone have any other ideas?

Thanks,

Nathan

View Replies !    View Related
Dynamically Using BitmapData
I have 10 BitmapData objects in my fla library Back1...10. And different objects load one of these ten randomly.

so basically
var bitmap:Bitmap = new Bitmap(new Back1..10(widht, height));

But how do i load a bitmapdata intot the bitmap class when i don't know the name of the class(whether it's Back2 or Back5 for example?).

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved