Home » Actionscripts library » Movieclip Object
|
3D (Camera & Scene)
cubeData = [{colour:0xff9900, // Bottom
Sides:[
{x:-50, y:50, z:50}, // UL
{x:-50, y:50, z:-50}, // OL
{x:50, y:50, z:-50}, // OR
{x:50, y:50, z:50} // UR
]},
{colour:0xff9900, // Top
Sides:[
{x:-50, y:-50, z:-50}, // UL
{x:-50, y:-50, z:50}, // OL
{x:50, y:-50, z:50}, // OR
{x:50, y:-50, z:-50} // UR
]},
{colour:0xff8800, // Right
Sides:[
{x:50, y:-50, z:50}, // OR
{x:50, y:50, z:50}, // UR
{x:50, y:50, z:-50}, // UL
{x:50, y:-50, z:-50} // OL
]},
{colour:0xff8800, // Left
Sides:[
{x:-50, y:-50, z:-50}, // OR
{x:-50, y:50, z:-50}, // UR
{x:-50, y:50, z:50}, // UL
{x:-50, y:-50, z:50} // OL
]},
{colour:0xffaa00, // Front
Sides:[
{x:-50, y:50, z:-50}, // UL
{x:-50, y:-50, z:-50}, // OL
{x:50, y:-50, z:-50}, // OR
{x:50, y:50, z:-50} // UR
]},
{colour:0xffaa00, // Back
Sides:[
{x:50, y:50, z:50}, // UL
{x:50, y:-50, z:50}, // OL
{x:-50, y:-50, z:50}, // OR
{x:-50, y:50, z:50} // UR
]}
];
Objekt3d = function (data3d) {
this.data3d = data3d;
this.move3d = function(x, y, z) {
var k = 0;
while (k<this.data3d.length) {
var i = 0;
while (i<this.data3d[k].Sides.length) {
this.data3d[k].Sides[i].x = this.data3d[k].Sides[i].x+x;
this.data3d[k].Sides[i].y = this.data3d[k].Sides[i].y+y;
this.data3d[k].Sides[i].z = this.data3d[k].Sides[i].z+z;
i++;
}
k++;
}
};
this.scale3d = function(x, y, z) {
var k = 0;
while (k<this.data3d.length) {
var i = 0;
while (i<this.data3d[k].Sides.length) {
this.data3d[k].Sides[i].x = this.data3d[k].Sides[i].x*x;
this.data3d[k].Sides[i].y = this.data3d[k].Sides[i].y*y;
this.data3d[k].Sides[i].z = this.data3d[k].Sides[i].z*z;
i++;
}
k++;
}
};
this.rotate3d = function(xa, ya) {
var rad = Math.PI/180;
var px;
var py;
var pz;
var sin_xa;
var sin_ya;
var cos_xa;
var cos_ya;
var tempz;
var k = 0;
while (k<this.data3d.length) {
var i = 0;
while (i<this.data3d[k].Sides.length) {
px = this.data3d[k].Sides[i].x;
py = this.data3d[k].Sides[i].y;
pz = this.data3d[k].Sides[i].z;
cos_ya = Math.cos(ya*rad);
sin_ya = Math.sin(ya*rad);
cos_xa = Math.cos(xa*rad);
sin_xa = Math.sin(xa*rad);
tempz = (pz*cos_ya)-(px*sin_ya);
this.data3d[k].Sides[i].x = (pz*sin_ya)+(px*cos_ya);
this.data3d[k].Sides[i].y = (py*cos_xa)-(tempz*sin_xa);
this.data3d[k].Sides[i].z = (py*sin_xa)+(tempz*cos_xa);
i++;
}
k++;
}
};
};
Kamera3d = function (Objekt3d, distance, angle, loc) {
this.Objekt3d = Objekt3d;
this.distance = distance;
this.angle = angle;
this.loc = loc;
this.mc = this.create();
};
Kamera3d.prototype.create = function() {
return (this.loc.createEmptyMovieClip("camMC"+Stage.camNum, Stage.camNum++));
};
Kamera3d.prototype.render = function() {
this.mc.clear();
var z;
var pers;
var sx;
var sy;
var tx;
var ty;
var polygon;
var k = 0;
while (k<this.Objekt3d.data3d.length) {
polygon = [];
var i = 0;
while (i<this.Objekt3d.data3d[k].Sides.length) {
z = this.Objekt3d.data3d[k].Sides[i].z+this.distance;
pers = this.angle/z;
sx = this.Objekt3d.data3d[k].Sides[i].x*pers;
sy = this.Objekt3d.data3d[k].Sides[i].y*pers;
polygon.push({sx:sx, sy:sy});
i++;
}
z = ((polygon[1].sx-polygon[0].sx)*(polygon[2].sy-polygon[0].sy))-((polygon[1].sy-polygon[0].sy)*(polygon[2].sx-polygon[0].sx));
if (z>0) {
this.mc.beginFill(this.Objekt3d.data3d[k].colour, this.Objekt3d.data3d[k].colour);
this.mc.moveTo(polygon[0].sx, polygon[0].sy);
this.mc.lineTo(polygon[1].sx, polygon[1].sy);
this.mc.lineTo(polygon[2].sx, polygon[2].sy);
this.mc.lineTo(polygon[3].sx, polygon[3].sy);
this.mc.lineTo(polygon[0].sx, polygon[0].sy);
}
k++;
}
};
Cube3d = new Objekt3d(cubeData);
Szene3D = new Kamera3d(Cube3d, 200, 400, _root);
Szene3D.render();
Szene3D.mc._x = 275;
Szene3D.mc._y = 175;
_root.onEnterFrame = function() {
Cube3d.rotate3d((this._xmouse+100)/100, (this._ymouse+200)/100);
Szene3D.render();
};
Posted by: Matthias Kannengiesser | website http://www.flashstar.de |
|
//All Movieclips have properties such as the x position: _x //This code overwrites some of the Movieclip objects predefined //Methods and replace them with new ones. //The new property is: anymovieclipname._depth //This code will only work correctly if you use the duplicateMovieClip, //attachMovie methods of the Movieclip object:
anymovieclip.duplicateMovieClip("newname",depth)
anymovieclip.attachMovie("linkage","newname",depth)Posted by: Flashguru | website http://www.flashguru.co.uk |
////////////////////////////////////////////////
// Bounce Function
// In German I call it wabber :)
///////////////////////////////////////////////
movieclip.prototype.wabber = function(multiplikator, xskal, yskal, ratio) {
sX = Number(sX * multiplikator) + Number((xskal - _xscale) * ratio);
sY = Number(sY * multiplikator) + Number((yskal - _yscale) * ratio);
_xscale += sX;
_yscale += sY;
}
//You have to add this on your mc - it's just an example:
onClipEvent (enterFrame) {
wabber(.9, 150, 150, .3);
}
Posted by: Matthias Kannengiesser | website http://www.flashstar.de |
/* ... place this 2D pie chart like percentage preloader script by www.advance-media.com on a movieClip on frame 1, your movie begins on frame 2, Flash MX ... The piece of pie grows with the percentage loaded. Add a dynamic text field for the variable "digit" to display the percentage value. By changing a few lines you get a circular time countdown effect, look (---) */ onClipEvent (load) { _root.stop(); radius = 175; step = 1; // step is the accuracy of drawing the circular line. circle_pi = Math.PI/180; b_total = _root.getBytesTotal(); // --- for the time countdown use the next 2 lines instead of the previous line --- //begin = getTimer(); //duration = 4; // 4 seconds } onClipEvent (enterFrame) { degree = 0; b_loaded = _root.getBytesLoaded(); // --- for the time countdown use the next line instead of the previous line --- //elapse = getTimer(); if (ratio>=360) { // circle completed, preload done _root.play(); } _root.digit = parseInt(b_loaded/b_total*100); ratio = b_loaded/b_total*360; // --- for the time countdown use the next 2 lines instead of the previous 2 lines --- //_root.digit = duration-parseInt((elapse-begin)/1000); //ratio = (elapse-begin)/(1000*duration)*360; with (this) { // drawing the growing piece of pie clear(); lineStyle(0, 0x00FFFF, 0); beginFill(0x00FFFF, 100); lineTo(0, -radius); } while (degree-step>=(-ratio)) { degree -= step; x = -radius*Math.sin(degree*circle_pi); y = -radius*Math.cos(degree*circle_pi); this.lineTo(x, y); } // 2004 by www.advance-media.com this.endFill(); } Posted by: Folko Langner | website http://www.advance-media.com |
//currently visible on http://www.lelab.net/tonearea/tone.asp?id=28 //the sound function was Posted by: Michael Tapson on actionscript.org s1 = new Sound(); s1.attachSound("dotsound1"); var intervalID; maxlevel = 80; minlevel = 0; fadespeed = 10; function fadeup() { clearInterval(intervalID); intervalID = setInterval(upOne, fadespeed); } function fadedown() { clearInterval(intervalID); intervalID = setInterval(downOne, fadespeed); } function upOne() { varSnd = s1.getVolume(); if (varSnd Posted by: adrien | website http://www.e-mergency.net |

