muratcdemirci
🏆Pro Tasarımcı🏆
Uygulama:
1- Flash programını açın 6 adet aynı ebadlardaki resmi kütüphaneye alın.(Sahne boş kalacak) .Her resmin üzerine sırası ile sağ klik yapıp linkage seçeneğini işaretleyin.Açılan panelde 1. ve 3. kutucukları işaretleyip en üstteki ID alanına image0 ve sırası ile image1,...........,image5 yazın. Bu isimler kodlarda daha sonra dizi içine alınarak kullanılacaktır.
2- Sahne hala boştur. Buraya hiçbir eklenti yapılmayacak. Sadece 1. kareye alttaki kodları yazmanız yeterli olacaktır.
import flash.geom.Matrix;
import flash.geom.Point;
Stage.scaleMode = 'noScale';
var oRotations:Object = {x:0, y:0, z:0};
var nUnit:Number = 100/2;
var boxPoints_array:Array = new Array();
boxPoints_array.push({x:-nUnit, y:-nUnit, z:-nUnit});
boxPoints_array.push({x:nUnit, y:nUnit, z:-nUnit});
boxPoints_array.push({x:-nUnit, y:nUnit, z:-nUnit});
boxPoints_array.push({x:-nUnit, y:-nUnit, z:nUnit});
boxPoints_array.push({x:nUnit, y:-nUnit, z:nUnit});
boxPoints_array.push({x:nUnit, y:nUnit, z:nUnit});
var faces_array:Array = new Array();
faces_array.push([2, 0, 3]);
faces_array.push([5, 1, 2]);
faces_array.push([0, 2, 1]);
faces_array.push([4, 3, 0]);
faces_array.push([3, 4, 5]);
faces_array.push([1, 5, 4]);
var images_array:Array = ["image0", "image1", "image2", "image3", "image4", "image5"];
var my_mc:MovieClip = this.createEmptyMovieClip("scene_mc", this.getNextHighestDepth());
my_mc._x = Stage.width/2;
my_mc._y = Stage.height/2;
var nSensitivity:Number = 1/1000;
xInitializeBox();
xCreateBox();
my_mc.onEnterFrame = xCreateBox;
function xInitializeBox() {
var nLength:Number = faces_array.length;
for (var i:Number = 0; i<nLength; ++i) {
var image_str:String = images_array;
var _mc:MovieClip = my_mc.createEmptyMovieClip(image_str, i);
faces_array.push(_mc);
var contents_mc:MovieClip = _mc.createEmptyMovieClip("contents", i);
contents_mc.attachBitmap(flash.display.BitmapData.loadBitmap(image_str), 1, "auto", true);
}
}
function xCreateBox() {
oRotations.x -= this._ymouse*nSensitivity;
oRotations.y += this._xmouse*nSensitivity;
var points2d:Array = xTransformPoints(boxPoints_array, oRotations);
var nLength:Number = faces_array.length;
for (var i:Number = 0; i<nLength; ++i) {
var face_array:Array = faces_array;
var n0:Number = face_array[0];
var n1:Number = face_array[1];
var n2:Number = face_array[2];
var _mc:MovieClip = face_array[3];
xTransformMovieClipPoints(_mc, points2d[n0], points2d[n1], points2d[n2]);
}
}
function xTransformPoints(points_array:Array, oRotations:Object):Array {
var points2D_array:Array = new Array();
var nSin_x:Number = Math.sin(oRotations.x);
var nCos_x:Number = Math.cos(oRotations.x);
var nSin_y:Number = Math.sin(oRotations.y);
var nCos_y:Number = Math.cos(oRotations.y);
var nSin_z:Number = Math.sin(oRotations.z);
var nCos_z:Number = Math.cos(oRotations.z);
var nLength:Number = points_array.length;
for (var i:Number = 0; i<nLength; ++i) {
var nX:Number = points_array.x;
var nY:Number = points_array.y;
var nZ:Number = points_array.z;
var nYx:Number = nCos_x*nY-nSin_x*nZ;
var nZx:Number = nSin_x*nY+nCos_x*nZ;
var nZy:Number = nCos_y*nZx-nSin_y*nX;
var nXy:Number = nSin_y*nZx+nCos_y*nX;
var nXz:Number = nCos_z*nXy-nSin_z*nYx;
var nYz:Number = nSin_z*nXy+nCos_z*nYx;
points2D_array = new Point(nXz, nYz);
}
return points2D_array;
}
function xTransformMovieClipPoints(_mc:MovieClip, point0oint, point1oint, point2oint):Void {
if (_mc._visible=xIsVisible(point0, point1, point2)) {
var myMatrix:Matrix = _mc.transform.matrix;
var contents_mc:MovieClip = _mc.contents;
var nWidth:Number = contents_mc._width;
var nHeight:Number = contents_mc._height;
var point1_0oint = point0.subtract(point1);
var point1_2oint = point2.subtract(point1);
myMatrix.tx = point1.x;
myMatrix.ty = point1.y;
myMatrix.a = (point1_0.x)/nWidth;
myMatrix.b = (point1_0.y)/nWidth;
myMatrix.c = (point1_2.x)/nHeight;
myMatrix.d = (point1_2.y)/nHeight;
_mc.transform.matrix = myMatrix;
}
}
function xIsVisible(point0oint, point1oint, point2oint):Boolean {
var point0_1oint = point1.subtract(point0);
var point0_2oint = point2.subtract(point0);
var nX0_1:Number = point0_1.x;
var nY0_1:Number = point0_1.y;
var nX0_2:Number = point0_2.x;
if (!nX0_1) {
return ((0>nY0_1) != (nX0_2>0));
}
var nY0_2:Number = point0_2.y;
if (!nX0_2) {
return ((0>nY0_2) != (nX0_1<0));
}
return ((nY0_1/nX0_1<nY0_2/nX0_2) == (0<nX0_1 == 0>nX0_2));
}
1- Flash programını açın 6 adet aynı ebadlardaki resmi kütüphaneye alın.(Sahne boş kalacak) .Her resmin üzerine sırası ile sağ klik yapıp linkage seçeneğini işaretleyin.Açılan panelde 1. ve 3. kutucukları işaretleyip en üstteki ID alanına image0 ve sırası ile image1,...........,image5 yazın. Bu isimler kodlarda daha sonra dizi içine alınarak kullanılacaktır.
2- Sahne hala boştur. Buraya hiçbir eklenti yapılmayacak. Sadece 1. kareye alttaki kodları yazmanız yeterli olacaktır.
import flash.geom.Matrix;
import flash.geom.Point;
Stage.scaleMode = 'noScale';
var oRotations:Object = {x:0, y:0, z:0};
var nUnit:Number = 100/2;
var boxPoints_array:Array = new Array();
boxPoints_array.push({x:-nUnit, y:-nUnit, z:-nUnit});
boxPoints_array.push({x:nUnit, y:nUnit, z:-nUnit});
boxPoints_array.push({x:-nUnit, y:nUnit, z:-nUnit});
boxPoints_array.push({x:-nUnit, y:-nUnit, z:nUnit});
boxPoints_array.push({x:nUnit, y:-nUnit, z:nUnit});
boxPoints_array.push({x:nUnit, y:nUnit, z:nUnit});
var faces_array:Array = new Array();
faces_array.push([2, 0, 3]);
faces_array.push([5, 1, 2]);
faces_array.push([0, 2, 1]);
faces_array.push([4, 3, 0]);
faces_array.push([3, 4, 5]);
faces_array.push([1, 5, 4]);
var images_array:Array = ["image0", "image1", "image2", "image3", "image4", "image5"];
var my_mc:MovieClip = this.createEmptyMovieClip("scene_mc", this.getNextHighestDepth());
my_mc._x = Stage.width/2;
my_mc._y = Stage.height/2;
var nSensitivity:Number = 1/1000;
xInitializeBox();
xCreateBox();
my_mc.onEnterFrame = xCreateBox;
function xInitializeBox() {
var nLength:Number = faces_array.length;
for (var i:Number = 0; i<nLength; ++i) {
var image_str:String = images_array;
var _mc:MovieClip = my_mc.createEmptyMovieClip(image_str, i);
faces_array.push(_mc);
var contents_mc:MovieClip = _mc.createEmptyMovieClip("contents", i);
contents_mc.attachBitmap(flash.display.BitmapData.loadBitmap(image_str), 1, "auto", true);
}
}
function xCreateBox() {
oRotations.x -= this._ymouse*nSensitivity;
oRotations.y += this._xmouse*nSensitivity;
var points2d:Array = xTransformPoints(boxPoints_array, oRotations);
var nLength:Number = faces_array.length;
for (var i:Number = 0; i<nLength; ++i) {
var face_array:Array = faces_array;
var n0:Number = face_array[0];
var n1:Number = face_array[1];
var n2:Number = face_array[2];
var _mc:MovieClip = face_array[3];
xTransformMovieClipPoints(_mc, points2d[n0], points2d[n1], points2d[n2]);
}
}
function xTransformPoints(points_array:Array, oRotations:Object):Array {
var points2D_array:Array = new Array();
var nSin_x:Number = Math.sin(oRotations.x);
var nCos_x:Number = Math.cos(oRotations.x);
var nSin_y:Number = Math.sin(oRotations.y);
var nCos_y:Number = Math.cos(oRotations.y);
var nSin_z:Number = Math.sin(oRotations.z);
var nCos_z:Number = Math.cos(oRotations.z);
var nLength:Number = points_array.length;
for (var i:Number = 0; i<nLength; ++i) {
var nX:Number = points_array.x;
var nY:Number = points_array.y;
var nZ:Number = points_array.z;
var nYx:Number = nCos_x*nY-nSin_x*nZ;
var nZx:Number = nSin_x*nY+nCos_x*nZ;
var nZy:Number = nCos_y*nZx-nSin_y*nX;
var nXy:Number = nSin_y*nZx+nCos_y*nX;
var nXz:Number = nCos_z*nXy-nSin_z*nYx;
var nYz:Number = nSin_z*nXy+nCos_z*nYx;
points2D_array = new Point(nXz, nYz);
}
return points2D_array;
}
function xTransformMovieClipPoints(_mc:MovieClip, point0oint, point1oint, point2oint):Void {
if (_mc._visible=xIsVisible(point0, point1, point2)) {
var myMatrix:Matrix = _mc.transform.matrix;
var contents_mc:MovieClip = _mc.contents;
var nWidth:Number = contents_mc._width;
var nHeight:Number = contents_mc._height;
var point1_0oint = point0.subtract(point1);
var point1_2oint = point2.subtract(point1);
myMatrix.tx = point1.x;
myMatrix.ty = point1.y;
myMatrix.a = (point1_0.x)/nWidth;
myMatrix.b = (point1_0.y)/nWidth;
myMatrix.c = (point1_2.x)/nHeight;
myMatrix.d = (point1_2.y)/nHeight;
_mc.transform.matrix = myMatrix;
}
}
function xIsVisible(point0oint, point1oint, point2oint):Boolean {
var point0_1oint = point1.subtract(point0);
var point0_2oint = point2.subtract(point0);
var nX0_1:Number = point0_1.x;
var nY0_1:Number = point0_1.y;
var nX0_2:Number = point0_2.x;
if (!nX0_1) {
return ((0>nY0_1) != (nX0_2>0));
}
var nY0_2:Number = point0_2.y;
if (!nX0_2) {
return ((0>nY0_2) != (nX0_1<0));
}
return ((nY0_1/nX0_1<nY0_2/nX0_2) == (0<nX0_1 == 0>nX0_2));
}