Stick Page Forums Archive

Some stupid codes [Flash][Actionscript]

Started by: Chaos | Replies: 64 | Views: 15,420

Chaos

Posts: 0
Joined: Jul 2025
Aug 23, 2005 6:10 PM #71
to make something follow your mouse, make something(duh) and convert to movie clip the add this:

onClipEvent(mouseMove){
if(hitTest(_root._xmouse,_root._ymouse,true)){
goforit = "yes";
}
}
onClipEvent(enterFrame){
if(goforit == "yes"){
_x -= (_x - _root._xmouse) / 6;
_y -= (_y - _root._ymouse) / 6;
}
}


o make a custom cursor, make object, then convert to movie clip, give instance name cursor, and add:

onClipEvent (load) {
startDrag("", true);
Mouse.hide(); }


to make a drag drop game, draw object, convert to button, and add:

on (press) {
startDrag("box1");
}
on (release) {
stopDrag();
}


to make a link to a URL, make button and add:

getURL("whatever.com", "_blank");


to make button, make object, convert to symbol, ad:

on (release) {
_root.play();
}

then on the first frame of movie, add:


stop();


to make something move with arrow keys, make object, convert to movie clip, and add:

onClipEvent(load){
moveSpeed=10;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._x+=moveSpeed;
} else if (Key.isDown(Key.LEFT)) {
this._x-=moveSpeed;
}
if (Key.isDown(Key.DOWN)) {
this._y+=moveSpeed;
} else if (Key.isDown(Key.UP)) {
this._y-=moveSpeed;
}
}

to change speed, Substitute the 10 in “movespeed=10:” with a higher or lower number.


To make a mouse trail, create object, give instaqnce name “orig”, and add:

onClipEvent(load){i=0;}
onClipEvent (mouseMove){
i++;
this.duplicateMovieClip("MC"+i, i+10);

_root["MC"+i]._x = _root._xmouse;
_root["MC"+i]._y = _root._ymouse;
}
onClipEvent (enterFrame) {
if (_name=="orig") {
this._visible=0;
}else{
_alpha-=2;
_xscale-=2;
_yscale-=2;
if(_alpha<=2) {removeMovieClip(this);}
}
}


to make fireworks, add:

ravity=30;
numsparks=100;
sparksize=2;

SW=Stage.width; SH=Stage.height; f=100;
C1=new Array("0xFF0000", "0xFFFFFF", "0xFFFF00", "0xFF9900", "0xFFCC33", "0xFFFFFF")

function makespark(rd){
_root.createEmptyMovieClip("spark", -7000);
with(spark){
lineStyle(0, 0xFFFFFF, 0);
beginFill(0xFFFFFF);
moveTo(0, -rd);
curveTo(rd*1.5, 0, 0, rd);
curveTo(-rd*1.5, 0, 0, -rd);
endFill();
_visible=0;
}
}

function makeback(){
_root.createEmptyMovieClip("back", 1);
with(back){
beginFill(0x000000, 100);
moveTo(0, 0);
lineTo(SW, 0);
lineTo(SW, SH);
lineTo(0, SH);
lineTo(0, 0);
endFill();
}

back.onPress=function(){
f+= numsparks+10;
for(z=f; z<(f+numsparks); z++){
duplicateMovieClip("spark", "spark"+z, z)
with(_root["spark"+z]){
_x=_root._xmouse;
_y=_root._ymouse;
}
_root["spark"+z].vx= ((random(400)-200)/35);
_root["spark"+z].vy= ((random(200)-150)/35);

_root["spark"+z].onEnterFrame=function(){
new Color(this).setRGB(C1[random(C1.length)]);
this._x+=this.vx*0.6;
this._y+=this.vy*1;
this._alpha-=1;
down=random(gravity)/100;
this.vy+=down;
if(this._y>SH || this._alpha<0){
this.removeMovieClip();
}
}
}
}
}

makeback()
makespark(sparksize)


To make a 3D cube, add this:

this.createEmptyMovieClip("center", 0);
center._x = Stage.width/2;
center._y = Stage.height/2;
focalLength = 400;
cube = {};
cube.vertexList = [];
cube.vertexList.push({x:-50, y:-50, z:50});
cube.vertexList.push({x:50, y:-50, z:50});
cube.vertexList.push({x:50, y:-50, z:-50});
cube.vertexList.push({x:-50, y:-50, z:-50});
cube.vertexList.push({x:-50, y:50, z:50});
cube.vertexList.push({x:50, y:50, z:50});
cube.vertexList.push({x:50, y:50, z:-50});
cube.vertexList.push({x:-50, y:50, z:-50});
cube.side = [];
cube.side.push([0,1,2,3]);
cube.side.push([2,1,5,6]);
cube.side.push([1,0,4,5]);
cube.side.push([5,4,7,6]);
cube.side.push([0,3,7,4]);
cube.side.push([3,2,6,7]);
render = function(model) {
if (transformMatrix) {
for (var i = 0; i < model.vertexList.length; i++) {
var vert = model.vertexList;
var x = transformMatrix.a*vert.x + tr
ansformMatrix.b*vert.y + transformMatrix.c*vert.z;
var y = transformMatrix.d*vert.x + transformMatrix.e*vert.y + transformMatrix.f*vert.z;
var z = transformMatrix.g*vert.x + transformMatrix.h*vert.y + transformMatrix.i*vert.z;;
vert.x = x;
vert.y = y;
vert.z = z;
}
delete transformMatrix;
}
center.clear();
center.lineStyle(2, 0, 100);
verts2D = [];
depthArray = [];
for (var i = 0; i < model.side.length; i++) {
var zDepth = 0;
for (var j = 0; j < model.side.length; j++) {
var whichVert = model.s
ide[j];
if (verts2D[whichVert] == undefined) {
verts2D[whichVert] = {};
var scale = focalLength/(focalLength - model.vertexList[whichVert].z);
verts2D[whichVert].x = model.vertexList[whichVert].x * scale;
verts2D[whichVert].y = model.vertexList[whichVert].y * scale;
}
zDepth += model.vertexList[whichVert].z;
}
depthArray.push([model.side[i], zDepth]);
}
depthArray.sort(function
(a,b) { return a[1] > b[1] });
for (var i = 0; i < depthArray.length; i++) {
var sideVerts = depthArray[i][0];
center.moveTo(verts2D[sideVerts[0]].x, verts2D[sideVerts[0]].y);
center.beginFill(0x666666, 100);
for (var j = 1; j < sideVerts.length; j++) {
center.lineTo(verts2D[sideVerts[j]].x, verts2D[sideVerts[j]].y);
}
center.lineTo(verts2D[sideVerts[0]].x, verts2D[sideVerts[0]].y);
center.endFill();
}
}
rotateX = function(model, degree) {
var rad = degree*Math.PI/180;
var sin = Math.sin(rad);
var cos = Math.cos(rad);
var matrix = {a:1, b:0, c:0, d:0, e:cos, f:sin, g:0, h:-sin, i:cos};
transform(matrix, model);
}
rotateY = function(model, degree) {
var rad = degree*Math.PI/180;
var sin = Math.sin(rad);
var cos = Math.cos(rad);
var matrix = {a:cos, b:0, c:-sin, d:0, e:1, f:0, g:sin, h:0, i:cos};
transform(matrix, model);
}
rotateZ = function(model, degree) {
var rad = degree*Math.PI/180;
var sin = Math.sin(rad);
var cos = Math.cos(rad);
var matrix = {a:cos, b:sin, c:0, d:-sin, e:cos, f:0, g:0, h:0, i:1};
transform(matrix, model);
}
scale = function(model, percent) {
var rad = degree*Math.PI/180;
var matrix = {a:percent, b:0, c:0, d:0, e:percent, f:0, g:0, h:0, i:percent};
transform(matrix, model);
}
transform = function(matrix, model) {
if (transformMatrix) {
var a = matrix.a*transformMatrix.a + matrix.b*transformMatrix.d + matrix.c*transformMatrix.g;
var b = matrix.a*transformMatrix.b + matrix.b*transformMatrix.e + matrix.c*transformMatrix.h;
var c = matrix.a*transformMatrix.c + matrix.b*transformMatrix.f + matrix.c*transformMatrix.i;
var d = matrix.d*transformMatrix.a + matrix.e*transformMatrix.d + matrix.f*transformMatrix.g;
var e = matrix.d*transformMatrix.b + matrix.e*transformMatrix.e + matrix.f*transformMatrix.h;
var f = matrix.d*transformMatrix.c + matrix.e*transformMatrix.f + matrix.f*transformMatrix.i;
var g = matrix.g*transformMatrix.a + matrix.h*transformMatrix.d + matrix.i*transformMatrix.g;
var h = matrix.g*transformMatrix.b + matrix.h*transformMatrix.e + matrix.i*transformMatrix.h;
var i = matrix.g*transformMatrix.c + matrix.h*transformMatrix.f + matrix.i*transformMatrix.i;
transformMatrix = {a:a, b:b, c:c, d:d, e:e, f:f, g:g, h:h, i:i};
} else {
transformMatrix = matrix
}
}
center.onEnterFrame = function() {
rotateX(cube, 3);
rotateY(cube, 6);
rotateZ(cube, 10);
render(cube);
};


hope this helps. reppage, please if it helps
Slick Vick

Posts: 0
Joined: Jul 2025
Aug 23, 2005 6:34 PM #72
Very good tutioral just no proof that it will work, Which some people need.
TheCheez

Posts: 0
Joined: Jul 2025
Aug 23, 2005 7:00 PM #76
cool tute, i already knew the fireworks one and it's already in my sig, but ya that helped me, rep for you.
Slick Vick

Posts: 0
Joined: Jul 2025
Aug 23, 2005 8:26 PM #79
Lol te cheez, I was massing fire works, And it almost crashed my computer O.o Anyways. I'm gonna get started on some action scripting.
vanquish

Posts: 0
Joined: Jul 2025
Aug 23, 2005 8:58 PM #80
thnx for the tutorial.

That was helpful
2-D

Posts: 0
Joined: Jul 2025
Aug 23, 2005 11:19 PM #81
this totally went on my favorites list.
Admin

Posts: 0
Joined: Jul 2025
Aug 23, 2005 11:23 PM #82
Maybe you could comment your code so we know how it works...
StickFu

Posts: 5
Joined: Aug 2005
Rep: 29

View Profile
Aug 23, 2005 11:27 PM #83
Make examples of whaT THEY DO. tHATD BE COOL. sry bout the caps.
Chaos

Posts: 0
Joined: Jul 2025
Aug 24, 2005 6:00 PM #99
my flash trial is dead... anyone know where to get free flash???? if i got flash again, id show you what they do
F-Zero
2

Posts: 132
Joined: Aug 2005
Rep: 178

View Profile
Aug 24, 2005 6:18 PM #100
this is what i use for my website. its really cool. reppage if you use it. look at my profile and go to my site. look at it at my site :D

Nicol3

Posts: 0
Joined: Jul 2025
Aug 24, 2005 6:39 PM #101
These codes are juicier than a 3 foot Po'Boy sandwich. Bookmark'd.
Chaos

Posts: 0
Joined: Jul 2025
Aug 24, 2005 6:42 PM #102
please rep me!!





character limit
Lambi

Posts: 0
Joined: Jul 2025
Aug 24, 2005 7:13 PM #104
yay I learned something! maybe not. but I know where to find it, rep for you : D
F-Zero
2

Posts: 132
Joined: Aug 2005
Rep: 178

View Profile
Aug 24, 2005 7:23 PM #105
Pop-up code-




also put near top of text block.

rep me if it helped. i use these two codes in my site. Animotions.tk
Death Cool

Posts: 0
Joined: Jul 2025
Aug 26, 2005 6:22 PM #162
Yo chaos,
You know anymore codes?
Theyre pretty good!
Website Version: 1.0.4
© 2025 Max Games. All rights reserved.