var relativeSpherePosition1:Number3D = new Number3D( colorSphere1.x-(plane1.x-PLANE_SIZE*0.5), colorSphere1.y-(plane2.y-PLANE_SIZE*0.5), colorSphere1.z-(plane3.z-PLANE_SIZE*0.5) );And drawing spot on MovieMaterial. Thanks Andy Zupko for show easy way to get movie from material: Sprite(MovieMaterial(plane1.material).movie)
public var p3d:Plane3D; // just for hold plane orientation public var spot:Shape = new Shape(); public var spotColor:Number public var spotWidth:int public var spotHeight:int public var spotDepth:int public var sx:int public var sy:int public var sz:int public var movieFromMat:Sprite; public static const MIN_DISTANCE:uint = 400; public function ColorSpotCaster(plane3d:Plane3D, movieFromMaterial:Sprite, color:Number, width:int, height:int) { this.p3d = plane3d this.movieFromMat = movieFromMaterial this.spotColor = color this.spotWidth = width this.spotHeight = height this.spotDepth = width drawSpot(); } public function drawSpot():void { spot.name = "spot"; var gType:String = GradientType.RADIAL; var matrix:Matrix = new Matrix(); matrix.createGradientBox(spotWidth,spotHeight,0,-spotWidth*0.5, -spotHeight*0.5); var gColors:Array = [spotColor, 0x000000]; var gAlphas:Array = [1,0]; var gRatio:Array = [0,255]; var g:Graphics = spot.graphics g.beginGradientFill(gType,gColors,gAlphas,gRatio,matrix); g.drawRect(-spotWidth*0.5, -spotHeight*0.5, spotWidth, spotHeight); movieFromMat.addChild(spot) } public function updateSpotPositions(relativeColorThingPosition:Number3D, planeSize:uint, distance:uint):void { if (p3d.normal.y == 1) { spot.x = relativeColorThingPosition.x spot.y = planeSize-relativeColorThingPosition.z }else if (p3d.normal.z == 1) { spot.x = relativeColorThingPosition.x spot.y = planeSize-relativeColorThingPosition.y }else if (p3d.normal.x == 1) { spot.x = relativeColorThingPosition.z spot.y = planeSize-relativeColorThingPosition.y } spot.alpha = (MIN_DISTANCE - distance) / MIN_DISTANCE if(distance > MIN_DISTANCE*0.5) spot.scaleX = spot.scaleY =2+distance/100 else spot.scaleX = spot.scaleY =2+(MIN_DISTANCE-distance)/100 }
15.07.2008. 17:24
Thanks for posting this codings.
I try it and it's so nice.
Write a comment
* = required field