 |
Featured jobs
Featured template
View more templates
 |
 |


Next 5
Flashstar Bots Function
 |
 |
Here we have a little function to generate little bots.
/////////////////////////////////////////////////////////
//Bots Funktion Version 2.0
//By Matthias Kannengiesser
/////////////////////////////////////////////////////////
movieclip.prototype.bot = function (links,rechts,oben,unten) {
if (signal == 1) {
posx = _x;
posy = _y;
zufall = random(2);
b = _rotation;
if (zufall == 0) {
zufall = -1;
}
delta = delta_wert*zufall;
b = b+delta;
w = (b*Math.PI)/180;
new_x = posx+(s*Math.cos(w));
new_y = posy+(s*Math.sin(w));
_rotation = b;
if ((new_x>links) && (new_x<rechts)) {
_x = new_x;
} else {
b = 180-b;
}
if ((new_y>oben) && (new_y<unten)) {
_y = new_y;
} else {
b = -b;
}
_rotation = b;
}
}
/////////////////////////////////////////////////////////
//Klone Funktion Version 1.0
/////////////////////////////////////////////////////////
Movieclip.prototype.klone = function (anzahl) {
for (i =1; i < anzahl; i++) {
duplicateMovieClip (klon, "klon"+i, -i);
}
}
klone(15);
//You need an mc with an instancname: klon
//On your mc you need the following script (it's just an example):
onClipEvent (load) {
delta_wert = 10;
signal = 1;
s = 3;
}
onClipEvent (enterFrame) {
bot(7.5,400,7.5,400);
}
Posted by: Matthias Kannengiesser | website
http://www.flashstar.de
|
 |
 |
 |
FS Explosion
 |
 |
/*
Explosions Methoden v1.0
von Matthias Kannengiesser
*/
Movieclip.prototype.preinit = function (wBereich) {
x = Math.sin(_rotation%36)*random(wBereich);
y = Math.cos(_rotation%36)*random(wBereich);
}
Movieclip.prototype.initexpo = function (anzahl) {
_x = _root._xmouse;
_y = _root._ymouse;
for (i=1; i<anzahl; i++) {
this.duplicateMovieClip("n"+i, i);
_rotation += 360/anzahl;
_rotation %= 360;
_xscale += 100/anzahl;
_xscale %= 100;
_yscale += 100/anzahl;
_yscale %= 100;
}
}
Movieclip.prototype.expo = function (divX,divY,gravitation,fadeTempo,faktor,objekt) {
if (_name != objekt) {
_x -= x/divX;
_y -= y/divY;
x *= faktor;
y -= gravitation;
ny = Math.abs(_y-_root[objekt]._y);
nx = Math.abs(_x-_root[objekt]._x);
_rotation -= Math.sqrt(nx*nx+ny*ny);
_alpha -= fadeTempo;
if (_alpha<0) {
this.removeMovieClip();
}
}
}
movieclip.prototype.sfx = function (sobj) {
obj = new Sound(this)
obj.attachSound(sobj)
obj.start(0,1);
}
Call it like that:
onClipEvent (load) {
preinit(5);
}
onClipEvent (mouseUp) {
initexpo(50);
}
onClipEvent (enterFrame) {
expo(1,1,0,3,1,"mc");
}
onClipEvent (mouseUp) {
sfx("boom");
}
Posted by: Matthias Kannengiesser | website
http://www.flashstar.de
|
 |
 |
 |
2 decimal places
 |
 |
//set number to 2 decimal places
//You can set this anywhere in your timeline and use as you need anywhere in
your movie.
Math.__proto__.dec2 = function (num){
valor = String (Math.round(num * 100) / 100);
dot = valor.indexOf(".");
if(dot == -1){
valor += ".0";
}
temp = valor.split(".");
addDecimals = 2 - temp[1].length;
for(i=1; i<= addDecimals; i++){
valor += "0";
}
return valor;
};
a = 0.5;
b = 0.8;
z = Math.dec2(5);//if you trace thism, z will display "5.00"
z = Math.dec2(a + b);//if you trace thism, z will display "1.30"
Posted by: LordAlex Leon | website
http://www.lordalex.com
|
 |
 |
 |
Advanced Calculator in Flash 5.0
 |
 |
//Implementing Calculator In Flash 5.0
//Design a gui in flash and buttons also and name the buttons as 1,2,3....
//+,-,*,/,= Etc, as needed to design the calculator
// Here in this tutorial on(release) is related with the anu button that u clicked
//go through the tutorial thoroughly if any doubts and for source fla contact me
//on my mail "arunark7@indiatimes.com" or log on to "http://www.javaguru.koolhost.com"
//"res" is a flash input text field to take input and display the output
//************ Code Starts From Here *******************
// ** action for Button 1 starts from Here***
//intially
status=0;
res=0;
status1=1;
status2=0;
op=0;
q=10;
on (release, keyPress "1") {
if ((status == 0) && (status2 != 1)) {
res = res*10;
res = res+1;
}
if ((status1 == 0) && (status2 != 1)) {
res = 0;
res = res*10;
res = res+1;
status1 = 1;
status = 0;
}
if ((status == 0) && (status2 == 1)) {
res = res+(1/q);
q = q*10;
}
if ((status1 == 0) && (status2=1)) {
res = 0;
res = res+(1/q);
q = q*10;
status1 = 1;
status = 0;
}
}
// ** action for Button 1 Ends Here***
// ** action for Button 2 starts Here***
on (release , keyPress "2") {
if((status==0) && (status2!=1))
{
res=res*10;
res=res+2;
}
if((status1==0)&&(status2!=1))
{
res=0;
res=res*10;
res=res+2;
status1=1;
status=0;
}
if((status==0)&&(status2==1))
{
res=res+(2/q);
q=q*10;
}
if((status1==0)&&(status2=1))
{
res=0;
res=res+(2/q);
q=q*10;
status1=1;
status=0;
}
}
// ** action for Button 2 Ends Here***
// ** action for Button 3 starts Here***
on (release , keyPress "3")
{
if ((status == 0) && (status2 != 1)) {
res = res*10;
res = res+3;
}
if ((status1 == 0) && (status2 != 1)) {
res = 0;
res = res*10;
res = res+3;
status1 = 1;
status = 0;
}
if ((status == 0) && (status2 == 1)) {
res = res+(3/q);
q = q*10;
}
if ((status1 == 0) && (status2=1)) {
res = 0;
res = res+(3/q);
q = q*10;
status1 = 1;
status = 0;
}
}
// ** action for Button 3 Ends Here***
// ** action for Button 4 starts Here***
on (release , keyPress "4") {
if ((status == 0) && (status2 != 1)) {
res = res*10;
res = res+4;
}
if ((status1 == 0) && (status2 != 1)) {
res = 0;
res = res*10;
res = res+4;
status1 = 1;
status = 0;
}
if ((status == 0) && (status2 == 1)) {
res = res+(4/q);
q = q*10;
}
if ((status1 == 0) && (status2=1)) {
res = 0;
res = res+(4/q);
q = q*10;
status1 = 1;
status = 0;
}
}
// ** action for Button 4 Ends Here***
// ** action for Button 5 starts Here***
on (release , keyPress "5")
{
if ((status == 0) && (status2 != 1)) {
res = res*10;
res = res+5;
}
if ((status1 == 0) && (status2 != 1)) {
res = 0;
res = res*10;
res = res+5;
status1 = 1;
status = 0;
}
if ((status == 0) && (status2 == 1)) {
res = res+(5/q);
q = q*10;
}
if ((status1 == 0) && (status2=1)) {
res = 0;
res = res+(5/q);
q = q*10;
status1 = 1;
status = 0;
}
}
// ** action for Button 5 Ends Here***
// ** action for Button 6 starts Here***
on (release , keyPress "6")
{
if ((status == 0) && (status2 != 1)) {
res = res*10;
res = res+6;
}
if ((status1 == 0) && (status2 != 1)) {
res = 0;
res = res*10;
res = res+6;
status1 = 1;
status = 0;
}
if ((status == 0) && (status2 == 1)) {
res = res+(6/q);
q = q*10;
}
if ((status1 == 0) && (status2=1)) {
res = 0;
res = res+(6/q);
q = q*10;
status1 = 1;
status = 0;
}
}
// ** action for Button 6 Ends Here***
// ** action for Button 7 starts Here***
on (release , keyPress "7")
{
if ((status == 0) && (status2 != 1)) {
res = res*10;
res = res+7;
}
if ((status1 == 0) && (status2 != 1)) {
res = 0;
res = res*10;
res = res+7;
status1 = 1;
status = 0;
}
if ((status == 0) && (status2 == 1)) {
res = res+(7/q);
q = q*10;
}
if ((status1 == 0) && (status2=1)) {
res = 0;
res = res+(7/q);
q = q*10;
status1 = 1;
status = 0;
}
}
// ** action for Button 7 Ends Here***
// ** action for Button 8 starts Here***
on (release , keyPress "8")
{
if ((status == 0) && (status2 != 1)) {
res = res*10;
res = res+8;
}
if ((status1 == 0) && (status2 != 1)) {
res = 0;
res = res*10;
res = res+8;
status1 = 1;
status = 0;
}
if ((status == 0) && (status2 == 1)) {
res = res+(8/q);
q = q*10;
}
if ((status1 == 0) && (status2=1)) {
res = 0;
res = res+(8/q);
q = q*10;
status1 = 1;
status = 0;
}
}
// ** action for Button 8 Ends Here***
// ** action for Button 9 starts Here***
on (release , keyPress "9")
{
if ((status == 0) && (status2 != 1)) {
res = res*10;
res = res+9;
}
if ((status1 == 0) && (status2 != 1)) {
res = 0;
res = res*10;
res = res+9;
status1 = 1;
status = 0;
}
if ((status == 0) && (status2 == 1)) {
res = res+(9/q);
q = q*10;
}
if ((status1 == 0) && (status2=1)) {
res = 0;
res = res+(9/q);
q = q*10;
status1 = 1;
status = 0;
}
}
// ** action for Button 9 Ends Here***
// ** action for Button 0 starts Here***
on (release, keyPress "0") {
if ((status == 0) && (status2 != 1)) {
res = res*10;
res = res+0;
}
if ((status1 == 0) && (status2 != 1)) {
res = 0;
res = res*10;
res = res+0;
status1 = 1;
status = 0;
}
if ((status == 0) && (status2 == 1)) {
res = res+(0/q);
q = q*10;
}
if ((status1 == 0) && (status2=1)) {
res = 0;
res = res+(0/q);
q = q*10;
status1 = 1;
status = 0;
}
}
// ** action for Button 0 Ends Here***
// ** action for Button "." starts Here***
on (release , keyPress ".") {
status2=1;
}
// ** action for Button "." Ends Here***
// ** action for Button "+" starts Here***
on (release , keyPress "+") {
status=1;
status1=0;
status2=0;
a1=res;
op=1;
q=10;
}
// ** action for Button "+" Ends Here***
// ** action for Button "-" starts Here***
on (release , keyPress "-") {
status = 1;
status1 = 0;
status2=0;
a1 = res;
op = 2;
q=10;
}
// ** action for Button "-" Ends Here***
// ** action for Button "*" starts Here***
on (release , keyPress "*") {
status = 1;
status1 = 0;
a1 = res;
status2=0;
op = 3;
q=10;
}
// ** action for Button "*" Ends Here***
// ** action for Button "/" starts Here***
on (release , keyPress "/") {
status = 1;
status2=0;
status1 = 0;
a1 = res;
op = 4;
q=10;
}
// ** action for Button "/" Ends Here***
// ** action for Button "c" starts Here***
on (release , keyPress "c") {
status=0;
status1=1;
status2=0;
op=0;
res=0;
q=10;
}
// ** action for Button "c" Ends Here***
// ** action for Button "+/-" starts Here***
on(release)
{
res=res*(-1);
}
// ** action for Button "+/-" Ends Here***
// ** action for Button "=" starts Here***
on (release, keyPress "<Enter>") {
if (op == 1) {
res = a1+res;
}
if (op == 2) {
res = a1-res;
}
if (op == 3) {
res = a1*res;
}
if (op == 4) {
res = a1/res;
}
status = 1;
status1 = 0;
status2 = 0;
q = 10;
}
// ** action for Button "=" Ends Here***
Posted by: H.G.Arunkumar | website
http://www.javaguru.koolhost.com
|
 |
 |
 |
AI: rotate towards target
 |
 |
_global.smartRotation = function(currentRotation, targetRotation, rotationAmount){
if(Math.abs(currentRotation-targetRotation)<=rotationAmount){
currentRotation = targetRotation;
}else
if(currentRotation != targetRotation){ if(currentRotation >= 0 && targetRotation >= 0){ if(currentRotation > targetRotation){
currentRotation -= rotationAmount;
}else
if(currentRotation < targetRotation){
currentRotation += rotationAmount;
}
}else
if(currentRotation < 0 && targetRotation < 0){ if(currentRotation > targetRotation){
currentRotation -= rotationAmount;
}else
if(currentRotation < targetRotation){
currentRotation += rotationAmount;
}
}else
if(currentRotation < 0 && targetRotation >= 0){ if((Math.abs(currentRotation) + Math.abs(targetRotation)) <= 180){
currentRotation += rotationAmount;
}else
if((Math.abs(currentRotation) + Math.abs(targetRotation)) > 180){
currentRotation -= rotationAmount;
}
}else
if(currentRotation >= 0 && targetRotation < 0){ if((Math.abs(currentRotation) + Math.abs(targetRotation)) < 180){
currentRotation -= rotationAmount;
}else
if((Math.abs(currentRotation) + Math.abs(targetRotation)) >= 180){
currentRotation += rotationAmount;
}
}
}
return currentRotation;
}
_global.getAngle = function(x1,x2,y1,y2){
getAngle_delta_x = x1-x2;
getAngle_delta_y = y1-y2;
getAngle_rotation = -Math.atan2(getAngle_delta_x, getAngle_delta_y)/(Math.PI/180);
return getAngle_rotation;
}
onClipEvent(load){
turnSpeed=5;
}
onClipEvent(enterFrame){
targetRotation = getAngle(_x,player_mc._x,_y,player_mc._y);
smartRotation(_rotation, targetRotation, turnSpeed);
}
Posted by: abeall | website
http://abeall.com
|
 |
 |
 |
Next
5
|  |
Search Entire Site
Advertisements
Latest New Articles
- Set up a simple IIS Server for Flash
by Peter McBride - Day 1 at FITC Toronto 2008
by Anthony Pace - Simple reflection effect with AS2
by Jean André Mas - ActionScript.org Meets Josh Tynjala (aka dr_zeus)
by ActionScript.org Staff - Rapidly Create Online Flash Movies to Help Users Market, Sell and Support Software and Hardware
by Sabrina F
|
 |