AS3: Need to mask a 3d wall (dynamically added images) with gradient on the left and right sides

I have a custom 3d wall xml gallery that I was able to write the class for.  Now I would like to add a mask over the gallery to create the illusion that the gallery is fading as it is scrolled off of the stage as apposed to having a hard edge.  I have seen a few different forums on this but none are working.  Can someone tell me how to mask dynamically added images?  I am able to add an mc to the stage through as3 but it appears behind the image gallery...

I prefer not to reveal all of my class as people are charging upwards of $100 for the same app, so is there a simpler way to reveal this gallery through a gradient mask?

Thanks again for all the input...
cubical38Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rascalpantsCommented:

so is the problem with the the gradient not showing the soft edges, or with the gradient showing up behind the wall?

can't tell from your question...

rp / ZA

0
cubical38Author Commented:
well actually both...

Below is basically the code that added everything to the stage.  I have been trying all I know to add a mask over the gallery with no success.  Maybe you could look at this code and see something i am not...

I have a mc in the library called mask_mc with the gradient added.  I just need to add it and only have the images appear in that area...

Any thoughts?

Thanks
private function viewCarousel():void {
				viewport = new Viewport3D(stage.stageWidth, stage.stageHeight, false, true);
				addChild(viewport);
				//this.addChild(mask_mc);
				
				
				scene = new Scene3D();
				holder = new DisplayObject3D();
				camera = new Camera3D();
				camera.z = holder.z - 200;
 
 
 
 
				holder.z = 100;
				holder.y = -50;
				trace();
				renderer = new BasicRenderEngine();
				wallBlockCount = Math.round(imgNumber / WALL_BLOCK_IMAGE_COUNT);
				for (var currentWallBlock:int = 0; currentWallBlock < wallBlockCount; currentWallBlock++) {
					for (var i:int = 0; i < WALL_BLOCK_IMAGE_COUNT; i++) {
						if (i + ((currentWallBlock) * WALL_BLOCK_IMAGE_COUNT) < movieMaterialArray.length) {
							var thumb:MovieClip = new MovieClip();
							thumb.addChild(movieMaterialArray[i + ((currentWallBlock) * WALL_BLOCK_IMAGE_COUNT)].movie);
							var movieMaterial:MovieMaterial = new MovieMaterial(thumb, false, true);
							movieMaterial.interactive = true;
							movieMaterial.smooth = true;
							movieMaterial.tiled = true;
							primitive = new Plane(movieMaterial, 100, 70, 2, 2);
							primitive.y = currentWallBlock * (80);
							primitive.rotationY = 360 / (WALL_BLOCK_IMAGE_COUNT) * i;
							primitive.moveForward(200);
							if (currentWallBlock == 0) {
								var reflected:MovieClip = new MovieClip();
 
								var refMask:MovieClip = new masker() as MovieClip;
								reflected.addChild(refMask);
								refMask.y = -70;
								refMask.cacheAsBitmap = true;
 
								var bmpd:BitmapData = new BitmapData(thumb.width, thumb.height, true);
								bmpd.draw(thumb);
								var bmp:Bitmap = new Bitmap(bmpd);
								bmp.width = 100;
								bmp.height = 70;
								var bitmapHolder:MovieClip = new MovieClip();
								bitmapHolder.addChild(bmp);
								bitmapHolder.scaleY = -1;
								bitmapHolder.cacheAsBitmap = true;
 
								bitmapHolder.mask = refMask;
								reflected.addChild(bitmapHolder);
								reflected.alpha = .5;
								reflected.mouseEnabled = false;
 
								var refMat:MovieMaterial = new MovieMaterial(reflected, true, false);
								var reflectionPlane:Plane = new Plane(refMat, 100, 70, 5, 5);
 
								reflectionPlane.y = primitive.y - 70;
								reflectionPlane.rotationY = primitive.rotationY ;
								reflectionPlane.moveForward(200);
								holder.addChild(reflectionPlane);
							}
							var obj:Object = new Object ();
							obj.num = i;
							obj.block = currentWallBlock;
							obj.original = movieMaterialArray[i + ((currentWallBlock) * WALL_BLOCK_IMAGE_COUNT)].original;
							obj.material = movieMaterialArray[i + ((currentWallBlock) * WALL_BLOCK_IMAGE_COUNT)].movie;
							dict[primitive] = obj;
							primitive.name = "image" + currentWallBlock + i;
							holder.addChild(primitive);
							primitive.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, onImageClick);
							primitive.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, onImageOver);
							primitive.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, onImageOut);
						}
					}
				}
				scene.addChild(holder);
				holder.mask = mask_mc;
				trace("mask is here");
				addEventListener(Event.ENTER_FRAME, onEnterFrame);
				stage.addEventListener(KeyboardEvent.KEY_DOWN, _onKeyDown);
 
				holder.z = 200;
				Tweener.addTween(holder, { time:1 , z: 55, transition:"easeInOutQuad" } );
				viewport.alpha = 0;
				trace("viewport");
				Tweener.addTween(viewport, { time:1.6 , delay:.5, alpha:1, transition:"easeInOutQuad" } );
				scr = scroller;
				scr.addEventListener(MouseEvent.MOUSE_DOWN, onScrollMouseDown);
				scr.buttonMode = true;
			}

Open in new window

0
rascalpantsCommented:

I think your mask is the issue...  I will post something in a bit to get the gradient to work


rp / ZA
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

cubical38Author Commented:
Okay good, I need a break from this for a bit so I will wait patiently for your input...

Thanks again...
0
rascalpantsCommented:
okay...  so here is the secret recipe...

you need to set your mask and holder of your 3D wall to cacheAsBitmap = true;


mask_mc.cacheAsBitmap = true;
holder.cacheAsBitmap = true;

holder.mask = mask_mc;


then your mask can have a gradient as the fill color, and all of the magic of your 3D app should be masked properly...


rp / ZA
0
cubical38Author Commented:
Okay that makes all the sense in the world, but alas with the code below I receive:  

1119: Access of possibly undefined property cacheAsBitmap through a reference with static type org.papervision3d.objects:DisplayObject3D.
private function viewCarousel():void {
				viewport = new Viewport3D(stage.stageWidth, stage.stageHeight, false, true);
				addChild(viewport);
				//this.addChild(mask_mc);
				var mask_mc:Sprite = new Sprite();
				addChild(mask_mc);
				trace("mask_mc");
				scene = new Scene3D();
				holder = new DisplayObject3D();
				camera = new Camera3D();
				camera.z = holder.z - 200;
 
				mask_mc.cacheAsBitmap = true;
				holder.cacheAsBitmap = true;
				holder.mask = mask_mc;
 
 
				holder.z = 100;
				holder.y = -50;
				trace();
				renderer = new BasicRenderEngine();
				wallBlockCount = Math.round(imgNumber / WALL_BLOCK_IMAGE_COUNT);
				for (var currentWallBlock:int = 0; currentWallBlock < wallBlockCount; currentWallBlock++) {
					for (var i:int = 0; i < WALL_BLOCK_IMAGE_COUNT; i++) {
						if (i + ((currentWallBlock) * WALL_BLOCK_IMAGE_COUNT) < movieMaterialArray.length) {
							var thumb:MovieClip = new MovieClip();
							thumb.addChild(movieMaterialArray[i + ((currentWallBlock) * WALL_BLOCK_IMAGE_COUNT)].movie);
							var movieMaterial:MovieMaterial = new MovieMaterial(thumb, false, true);
							movieMaterial.interactive = true;
							movieMaterial.smooth = true;
							movieMaterial.tiled = true;
							primitive = new Plane(movieMaterial, 100, 70, 2, 2);
							primitive.y = currentWallBlock * (80);
							primitive.rotationY = 360 / (WALL_BLOCK_IMAGE_COUNT) * i;
							primitive.moveForward(200);
							if (currentWallBlock == 0) {
								var reflected:MovieClip = new MovieClip();
 
								var refMask:MovieClip = new masker() as MovieClip;
								reflected.addChild(refMask);
								refMask.y = -70;
								refMask.cacheAsBitmap = true;
 
								var bmpd:BitmapData = new BitmapData(thumb.width, thumb.height, true);
								bmpd.draw(thumb);
								var bmp:Bitmap = new Bitmap(bmpd);
								bmp.width = 100;
								bmp.height = 70;
								var bitmapHolder:MovieClip = new MovieClip();
								bitmapHolder.addChild(bmp);
								bitmapHolder.scaleY = -1;
								bitmapHolder.cacheAsBitmap = true;
 
								bitmapHolder.mask = refMask;
								reflected.addChild(bitmapHolder);
								reflected.alpha = .5;
								reflected.mouseEnabled = false;
 
								var refMat:MovieMaterial = new MovieMaterial(reflected, true, false);
								var reflectionPlane:Plane = new Plane(refMat, 100, 70, 5, 5);
 
								reflectionPlane.y = primitive.y - 70;
								reflectionPlane.rotationY = primitive.rotationY ;
								reflectionPlane.moveForward(200);
								holder.addChild(reflectionPlane);
							}
							var obj:Object = new Object ();
							obj.num = i;
							obj.block = currentWallBlock;
							obj.original = movieMaterialArray[i + ((currentWallBlock) * WALL_BLOCK_IMAGE_COUNT)].original;
							obj.material = movieMaterialArray[i + ((currentWallBlock) * WALL_BLOCK_IMAGE_COUNT)].movie;
							dict[primitive] = obj;
							primitive.name = "image" + currentWallBlock + i;
							holder.addChild(primitive);
							primitive.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, onImageClick);
							primitive.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, onImageOver);
							primitive.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, onImageOut);
						}
					}
				}
				scene.addChild(holder);
				addEventListener(Event.ENTER_FRAME, onEnterFrame);
				stage.addEventListener(KeyboardEvent.KEY_DOWN, _onKeyDown);
 
				holder.z = 200;
				Tweener.addTween(holder, { time:1 , z: 55, transition:"easeInOutQuad" } );
				viewport.alpha = 0;
 
 
 
 
 
 
				Tweener.addTween(viewport, { time:1.6 , delay:.5, alpha:1, transition:"easeInOutQuad" } );
				scr = scroller;
				scr.addEventListener(MouseEvent.MOUSE_DOWN, onScrollMouseDown);
				scr.buttonMode = true;
			}

Open in new window

0
cubical38Author Commented:
1119: Access of possibly undefined property mask through a reference with static type org.papervision3d.objects:DisplayObject3D.
0
rascalpantsCommented:

you either need to use "as MovieClip" after the reference to the DisplayObject3D reference... probably the holder...

like this...

var clip:MovieClip = holder as MovieClip;
clip.cacheAsBitmap = true;

that or you can create a movieclip that holds everything, and then make that your holder...

rp / ZA
0
cubical38Author Commented:
Not sure where I am going wrong but with this code I still receive these errors:

1119: Access of possibly undefined property mask through a reference with static type org.papervision3d.objects:DisplayObject3D.
private function viewCarousel():void {
				viewport = new Viewport3D(stage.stageWidth, stage.stageHeight, false, true);
				addChild(viewport);
				//this.addChild(mask_mc);
				var mask_mc:Sprite = new Sprite();
				addChild(mask_mc);
				trace("mask_mc");
				scene = new Scene3D();
				holder = new DisplayObject3D();
				camera = new Camera3D();
				camera.z = holder.z - 200;
				var clip:MovieClip = holder as MovieClip;
				clip.cacheAsBitmap = true;
				mask_mc.cacheAsBitmap = true;
				holder.cacheAsBitmap = true;
				holder.mask = mask_mc;
				holder.z = 100;
				holder.y = -50;
				trace();
				scene.addChild(holder);
				addEventListener(Event.ENTER_FRAME, onEnterFrame);
				stage.addEventListener(KeyboardEvent.KEY_DOWN, _onKeyDown);
				holder.z = 200;
				Tweener.addTween(holder, { time:1 , z: 55, transition:"easeInOutQuad" } );
				viewport.alpha = 0;
				Tweener.addTween(viewport, { time:1.6 , delay:.5, alpha:1, transition:"easeInOutQuad" } );
				scr = scroller;
				scr.addEventListener(MouseEvent.MOUSE_DOWN, onScrollMouseDown);
				scr.buttonMode = true;
				renderer = new BasicRenderEngine();
				wallBlockCount = Math.round(imgNumber / WALL_BLOCK_IMAGE_COUNT);
				for (var currentWallBlock:int = 0; currentWallBlock < wallBlockCount; currentWallBlock++) {
					for (var i:int = 0; i < WALL_BLOCK_IMAGE_COUNT; i++) {
						if (i + ((currentWallBlock) * WALL_BLOCK_IMAGE_COUNT) < movieMaterialArray.length) {
							var thumb:MovieClip = new MovieClip();
							thumb.addChild(movieMaterialArray[i + ((currentWallBlock) * WALL_BLOCK_IMAGE_COUNT)].movie);
							var movieMaterial:MovieMaterial = new MovieMaterial(thumb, false, true);
							movieMaterial.interactive = true;
							movieMaterial.smooth = true;
							movieMaterial.tiled = true;
							primitive = new Plane(movieMaterial, 100, 70, 2, 2);
							primitive.y = currentWallBlock * (80);
							primitive.rotationY = 360 / (WALL_BLOCK_IMAGE_COUNT) * i;
							primitive.moveForward(200);
							if (currentWallBlock == 0) {
								var reflected:MovieClip = new MovieClip();
 
								var refMask:MovieClip = new masker() as MovieClip;
								reflected.addChild(refMask);
								refMask.y = -70;
								refMask.cacheAsBitmap = true;
 
								var bmpd:BitmapData = new BitmapData(thumb.width, thumb.height, true);
								bmpd.draw(thumb);
								var bmp:Bitmap = new Bitmap(bmpd);
								bmp.width = 100;
								bmp.height = 70;
								var bitmapHolder:MovieClip = new MovieClip();
								bitmapHolder.addChild(bmp);
								bitmapHolder.scaleY = -1;
								bitmapHolder.cacheAsBitmap = true;
 
								bitmapHolder.mask = refMask;
								reflected.addChild(bitmapHolder);
								reflected.alpha = .5;
								reflected.mouseEnabled = false;
 
								var refMat:MovieMaterial = new MovieMaterial(reflected, true, false);
								var reflectionPlane:Plane = new Plane(refMat, 100, 70, 5, 5);
 
								reflectionPlane.y = primitive.y - 70;
								reflectionPlane.rotationY = primitive.rotationY ;
								reflectionPlane.moveForward(200);
								holder.addChild(reflectionPlane);
							}
							var obj:Object = new Object ();
							obj.num = i;
							obj.block = currentWallBlock;
							obj.original = movieMaterialArray[i + ((currentWallBlock) * WALL_BLOCK_IMAGE_COUNT)].original;
							obj.material = movieMaterialArray[i + ((currentWallBlock) * WALL_BLOCK_IMAGE_COUNT)].movie;
							dict[primitive] = obj;
							primitive.name = "image" + currentWallBlock + i;
							holder.addChild(primitive);
							primitive.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, onImageClick);
							primitive.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, onImageOver);
							primitive.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, onImageOut);
						}
					}
				}
			}

Open in new window

0
cubical38Author Commented:
Sorry my comments keep getting cut out:

1119: Access of possibly undefined property cacheAsBitmap through a reference with static type org.papervision3d.objects:DisplayObject3D.
private function viewCarousel():void {
				viewport = new Viewport3D(stage.stageWidth, stage.stageHeight, false, true);
				addChild(viewport);
				//this.addChild(mask_mc);
				var mask_mc:Sprite = new Sprite();
				addChild(mask_mc);
				trace("mask_mc");
				scene = new Scene3D();
				holder = new DisplayObject3D();
				camera = new Camera3D();
				camera.z = holder.z - 200;
				var clip:MovieClip = holder as MovieClip;
				clip.cacheAsBitmap = true;
				mask_mc.cacheAsBitmap = true;
				holder.cacheAsBitmap = true;
				holder.mask = mask_mc;
				holder.z = 100;
				holder.y = -50;
				trace();
				scene.addChild(holder);
				addEventListener(Event.ENTER_FRAME, onEnterFrame);
				stage.addEventListener(KeyboardEvent.KEY_DOWN, _onKeyDown);
				holder.z = 200;
				Tweener.addTween(holder, { time:1 , z: 55, transition:"easeInOutQuad" } );
				viewport.alpha = 0;
				Tweener.addTween(viewport, { time:1.6 , delay:.5, alpha:1, transition:"easeInOutQuad" } );
				scr = scroller;
				scr.addEventListener(MouseEvent.MOUSE_DOWN, onScrollMouseDown);
				scr.buttonMode = true;
				renderer = new BasicRenderEngine();
				wallBlockCount = Math.round(imgNumber / WALL_BLOCK_IMAGE_COUNT);
				for (var currentWallBlock:int = 0; currentWallBlock < wallBlockCount; currentWallBlock++) {
					for (var i:int = 0; i < WALL_BLOCK_IMAGE_COUNT; i++) {
						if (i + ((currentWallBlock) * WALL_BLOCK_IMAGE_COUNT) < movieMaterialArray.length) {
							var thumb:MovieClip = new MovieClip();
							thumb.addChild(movieMaterialArray[i + ((currentWallBlock) * WALL_BLOCK_IMAGE_COUNT)].movie);
							var movieMaterial:MovieMaterial = new MovieMaterial(thumb, false, true);
							movieMaterial.interactive = true;
							movieMaterial.smooth = true;
							movieMaterial.tiled = true;
							primitive = new Plane(movieMaterial, 100, 70, 2, 2);
							primitive.y = currentWallBlock * (80);
							primitive.rotationY = 360 / (WALL_BLOCK_IMAGE_COUNT) * i;
							primitive.moveForward(200);
							if (currentWallBlock == 0) {
								var reflected:MovieClip = new MovieClip();
 
								var refMask:MovieClip = new masker() as MovieClip;
								reflected.addChild(refMask);
								refMask.y = -70;
								refMask.cacheAsBitmap = true;
 
								var bmpd:BitmapData = new BitmapData(thumb.width, thumb.height, true);
								bmpd.draw(thumb);
								var bmp:Bitmap = new Bitmap(bmpd);
								bmp.width = 100;
								bmp.height = 70;
								var bitmapHolder:MovieClip = new MovieClip();
								bitmapHolder.addChild(bmp);
								bitmapHolder.scaleY = -1;
								bitmapHolder.cacheAsBitmap = true;
 
								bitmapHolder.mask = refMask;
								reflected.addChild(bitmapHolder);
								reflected.alpha = .5;
								reflected.mouseEnabled = false;
 
								var refMat:MovieMaterial = new MovieMaterial(reflected, true, false);
								var reflectionPlane:Plane = new Plane(refMat, 100, 70, 5, 5);
 
								reflectionPlane.y = primitive.y - 70;
								reflectionPlane.rotationY = primitive.rotationY ;
								reflectionPlane.moveForward(200);
								holder.addChild(reflectionPlane);
							}
							var obj:Object = new Object ();
							obj.num = i;
							obj.block = currentWallBlock;
							obj.original = movieMaterialArray[i + ((currentWallBlock) * WALL_BLOCK_IMAGE_COUNT)].original;
							obj.material = movieMaterialArray[i + ((currentWallBlock) * WALL_BLOCK_IMAGE_COUNT)].movie;
							dict[primitive] = obj;
							primitive.name = "image" + currentWallBlock + i;
							holder.addChild(primitive);
							primitive.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, onImageClick);
							primitive.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, onImageOver);
							primitive.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, onImageOut);
						}
					}
				}
			}

Open in new window

0
cubical38Author Commented:
Sorry my comments keep getting cut out:

1119: Access of possibly undefined property cacheAsBitmap through a reference with static type org.papervision3d.objects:DisplayObject3D.
0
rascalpantsCommented:

okay...  i assumed holder was the movieclip that had all of the 3D stuff in it...  I now see that it references:

holder = new DisplayObject3D();


okay...    so you would need to create a movieclip... lets call it..  "theClip"  then you would just do...

theClip.addChild( holder );
theClip.cacheAsBitmap = true;
mask_mc.cacheAsBitmap = true;

theClip.mask = mask_mc;


cacheAsBitmap only works with a movieclip... I dont' know what holder is, so just put holder or what ever you want to mask in a clip and then mask THAT clip...

rp / ZA
 
0
cubical38Author Commented:
I took a break from this for a bit to work on another project, but alas I am still not getting it to work.  I am going to send you the entire class as I cant get the mask in the correct spot.  Please let me know if you can get it to work.  Hopfully all of the files get transferred...  Im sure you know but you need to remove all of the .txt extensions...

Let me know if it doesn't go through...

Thanks again!


Archive.zip.txt
0
rascalpantsCommented:

I looked at your example, and I don't see any mask that is being created that has a tranparent gradient.  

If it were me, I would put all of your interface items in the FLA in a main_mc movieclip, and then have that movieclip call the carousel class.  but within the main_mc, is where I would put the gradient, which is in a layer above the loader clip.

then in your code, you can use what I gave you above, but instead of using the holder as the items being masked, you can use the loader itself...  if I am understanding the affect you want.


rp / ZA
0
cubical38Author Commented:
Would it work if I loaded this swf into another fla and masked that loader?
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
 
function startLoad() {
	var mLoader:Loader = new Loader();
	var mRequest:URLRequest = new URLRequest("carousel.swf");
	mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
	mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
	mLoader.load(mRequest);
	}
 
function onCompleteHandler(loadEvent:Event) {
	addChild(loadEvent.currentTarget.content);
}
function onProgressHandler(mProgress:ProgressEvent) {
	var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
	trace(percent);
}
startLoad();

Open in new window

0
rascalpantsCommented:
I would assume so, but you need to make sure to use "as Movieclip" with the loader reference, cause you can't mask a loader i don't believe...

but I would use the Event.INIT not the Event.COMPLETE  properties for the callback...  init is when the loader object is ready to be used in code...

but basically, you use the above code I gave you to mask one movieclip over the other...


rp / ZA
0
cubical38Author Commented:
Okay, round 16...
I am receiving this error when loading the original swf (containing carousel.as) into another.  I have placed the loader into a movieclip as you can see in the code below...
1067: Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject.
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
 
var MC:mask_mc = new mask_mc();//mc_mask in the library
addChildAt(MC, 0);
MC.cacheAsBitmap = true;
 
var MCload:MovieClip = new MovieClip();
MCload.cacheAsBitmap = true;
 
var mLoader:Loader = new Loader();
MCload.addChild(mLoader);
MCload.mask = mask_mc;
 
var mRequest:URLRequest = new URLRequest("carousel.swf");//contains carousel.as
mLoader.contentLoaderInfo.addEventListener(Event.INIT, onCompleteHandler);
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
mLoader.load(mRequest);
 
function onCompleteHandler(loadEvent:Event) {
	addChild(loadEvent.currentTarget.content);
}
function onProgressHandler(mProgress:ProgressEvent) {
	var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
	trace(percent);
}

Open in new window

0
cubical38Author Commented:
Thanks for all the help thus far, you've earned your points...
0
rascalpantsCommented:
I think so too :)

you are getting that error, because you are trying to load a mask_mc, which is a class instead of a movieclip... so again, you can try to use "as MovieClip" for the parameter that you pass for addChild...

var MC:mask_mc = new mask_mc();//mc_mask in the library
var clip:MovieClip = MC as MovieClip;
addChildAt(clip, 0);
clip.cacheAsBitmap = true;

do that for any time you use addChild()...  because addChild() accepts a MovieClip...

try that out...


rp / ZA


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cubical38Author Commented:
Im at a loss...  No errors but still no gradient mask.  I even added cacheAsBitmap to everything that is contained in the class...
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
 
var MC:mask_mc = new mask_mc();//mc_mask in the library
var clip:MovieClip = MC as MovieClip;
addChildAt(clip, 0);
clip.cacheAsBitmap = true;
MC.cacheAsBitmap = true;
 
var MCload:MovieClip = new MovieClip();
MCload.cacheAsBitmap = true;
 
var mLoader:Loader = new Loader();
MCload.addChild(mLoader);
MCload.mask = clip;
 
var mRequest:URLRequest = new URLRequest("carousel.swf");//contains carousel.as
mLoader.contentLoaderInfo.addEventListener(Event.INIT, onCompleteHandler);
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
mLoader.load(mRequest);
 
function onCompleteHandler(loadEvent:Event) {
	addChild(loadEvent.currentTarget.content);
}
function onProgressHandler(mProgress:ProgressEvent) {
	var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
	trace(percent);
}

Open in new window

0
cubical38Author Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.