ok..maybe you gents can help me on a problem I've had off and on..
 
project summary:
 

*       load in a dynamic image 

*       trace/create a lineTo object/fill on a layer above this loaded image


*       click a button to create an inversed mask of this above created
lineTo object 

*       effect is the part you drew/colored is not 'cropped' out of the
loaded image (revealing whatever content below)

laymen's terms:
 
load in a image, using the mouse you draw an shape/object 'on' the loaded
image clip, click a button.. it crops it out (thats the effect).. so if you
load an image of a face..you draw a shape/object around the teeth/eye
(whatever) it will 'knock it out'..revealing whatever objects/clips are
underneath the loaded image clip..
 
project layout:
 
contentConainer: 
 
a clips called faceContainer..  inside faceContainer is a clip called
centeredContainer 
 
I load the image into faceContainer.centeredContainer (an offset/center the
centeredContainer inside faceContainer) so that if/when I scale/rotate
faceContainer clip..is scales/rotates form the center point..  (make sense?)
 
so:
 
parent.parent clip (contentContainer)
---parent clip (faceContainer)--
------lineContainer (holds the shape/object I'm using for my source of the
inverse mask
------maskContainer (empty clip to hold the dynamically created clip from
the inverse mask method above)
------centeredContainer (the place where the dynamically loaded image gets
loaded into, and is 'masked' by the inversedMask method)

everything actually works FINE.... until I load in a BIG image.. if I load
an image that DOES not (originally) go -0 (before resize) or is smaller that
the display area..it works fine.. if I load in a HUGE image, something has
an _x value of less than 0 (zero).. it doesnt work..  (FYI: on the
movieClipLoader.onLoadInit() I do resize/scale the movieClip...but
again..for images that are originally very BIG before re-size..the
inversedmask effect does NOT work)
 
I'm fairly certain it has to do with the matrix.translate or maybe I need to
add to it?  but no matter what I've tried.. I cant seem to get it to
work..or possible the threshold portion??
 
ok..onto the problem/question...
 
code snippets..
 
here is the resize code/check I do once the movieClip initializes
 
RE-SIZE:
 
// if height is too big then resize to fit height
 if (target_mc._parent._height > max_height) {
      target_mc._parent._height = max_height;
      target_mc._parent._xscale = target_mc._parent._yscale;
 // if height is too small then resize to fit height
 }else if(target_mc._parent._height < max_height) {
      target_mc._parent._height = max_height;
      target_mc._parent._xscale = target_mc._parent._yscale;
 } 
 
 
INVERSED MASK: ( mc = contentContainer.faceContainer.lineContainer)
 
//--------------------- [reverse mask code] --------------------- //
function inverseMask(mc:MovieClip) {
     contentContainer.faceContainer.centeredContainer.cacheAsBitmap = true;
     var _BMP:BitmapData = new
BitmapData(contentContainer.faceContainer.centeredContainer._width,
contentContainer.faceContainer.centeredContainer._height, true, 0xFFFFFFFF);
     var invert:ColorTransform = new ColorTransform(0, 0, 0, 1);
     var matrix:Matrix = new Matrix(); 
     matrix.translate(0, 0);
     //matrix.translate(mc._x, mc._y);  //doesnt work
     //matrix.translate(contentContainer.faceContainer.centeredContainer._x,
contentContainer.faceContainer.centeredContainer._y); //doesnt work
     //matrix.identity();
 
//matrix.scale(contentContainer.faceContainer.centeredContainer._xscale,
contentContainer.faceContainer.centeredContainer._yscale);
     _BMP.draw(mc, matrix, invert);
     _BMP.threshold(_BMP, new Rectangle(0, 0, Stage.width, Stage.height),
new Point(0, 0), "<", 0xFFFFFFFF, 0x00FF0000);
     var BMP:BitmapData = _BMP.clone();
     var maskMC:MovieClip =
contentContainer.faceContainer.maskContainer.createEmptyMovieClip("invertedM
ask", contentContainer.faceContainer.maskContainer.getNextHighestDepth());
     maskMC.attachBitmap(BMP,
contentContainer.faceContainer.maskContainer.getNextHighestDepth());
     maskMC.cacheAsBitmap = true;
     mc._visible = false;
     return maskMC;
}

 
anybody good with matrix stiff and bitmap class??
 
I've tried doing/changing everything I can....  but it hasn't seemed to
work..
 
again to re-cap.. everything works..  if the image I load is 'around' the
470x410 dimension..(or smaller) it works fine..
 
I've tested it on a 550c462 image..and it works..however.... when I load in
an image 1500x1500 for example.. the inversed mask DOES NOT work..
 
it ONLY seems to work in the upper, left hand most corner....
 
I guess my 'thoughts' on this are:
 
since the image is centered, and being that it is 1500x1500.. the _x of the
'faceContainer' is less than zero (0)...and somehow this is affecting where
inversedMask function is applied?.. which is why I think it could be the
Matrix...OR, possible even the threshold portion of the code?
 
 
Thanks
 
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to