Hi, Im breaking an image into a grid of separate clips with corresponding pixels using copyPixels but I'm getting gaps in between the clips. Also sometimes the image wont finish if the ratio between horz and vert clips is too high. Has anyone had this issue.
code below cheers, MaTT import flash.display.BitmapData; import flash.geom.Rectangle; import flash.geom.Point; class com.client.effects.ReformPixel extends MovieClip { private var horzDiv, vertDiv, clip_w, clip_h, cut_w, cut_h:Number; private var srcImg, srcBmd:BitmapData; private var clip, clip_2:MovieClip; private var aClips:Array; function ReformPixel() { // } public function _init(_horzDiv:Number, _vertDiv:Number, _img:String, _clip:MovieClip, _clip_2:MovieClip):Void { var _break:Boolean = false; aClips = []; horzDiv = _horzDiv; vertDiv = _vertDiv; clip = _clip; clip_2 = _clip_2; srcImg = BitmapData.loadBitmap(_img); clip.attachBitmap(srcImg, 1); clip_w = clip._width; clip_h = clip._height; cut_w = clip_w/horzDiv; cut_h = clip_h/vertDiv; srcBmd = new BitmapData(clip_w, clip_h, true, 0x00000000); srcBmd.draw(clip); clip._visible = false; for (var j:Number = 0; j <= _horzDiv; j++) { for (var i:Number = 0; i <= _vertDiv; i++) { var num:Number = (j * _horzDiv + i); if (num >= (_horzDiv*_vertDiv)) { _break = true; break; } var xPos:Number = i * (cut_w); var yPos:Number = j * (cut_h); var rect = new Rectangle(xPos, yPos, cut_w, cut_h); var point = new Point(0,0); var bmd:BitmapData = new BitmapData(cut_w, cut_h, true, 0x000000); bmd.copyPixels(srcBmd, rect, point); var destClip:MovieClip = aClips[i] = clip_2.createEmptyMovieClip('destClip_' + i, clip_2.getNextHighestDepth()); destClip.attachBitmap(bmd, destClip.getNextHighestDepth(), 'auto', true); destClip._x = xPos; destClip._y = yPos; //trace('destClip._x = ' + destClip._x + ' destClip._y = ' + destClip._y) destClip.tX = destClip._x; destClip.tY = destClip._y; destClip.tZ = 100; } } } } _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com