00:00
00:00
Newgrounds Background Image Theme

Breakfast-Crow just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Response to As: Api 2005-07-13 20:02:39


Practice.

Many, many days/weeks/months of messing around with Flash and dissecting/reconstructing public flas/code.


- - Flash - Music - Images - -

BBS Signature

Response to As: Api 2005-07-13 20:13:45


public flash codes?

Response to As: Api 2005-07-13 20:19:32


At 7/13/05 08:13 PM, PiconjosLover wrote: public flash codes?

Yeah, like the snippets that people post in forums - like this thread, for example, or EviLudy's.

Bung them into Flash, tweak them until they work, play with them until comprehension of HOW they work occurs. Once that happens, you're well on your way to fully understanding AS.


- - Flash - Music - Images - -

BBS Signature

Response to As: Api 2005-07-13 21:46:57


At 7/13/05 08:51 PM, -cherries- wrote: just guessing denvish but was this your throw code?

Nope, it looks nothing like that. The actual throwing code is:

ball.onPress=function(){
if(this._x<edge.xMax*0.66){
heldr=0;
this.pressed=1;
this.duplicateMovieClip("eb", 7100)
new Color(_root.eb).setRGB(0xFFFFFF);
_root.eb._alpha=30;
}
}
ball.onRelease= ball.onReleaseOutside= function(){
this.pressed=0;
heldr=0;
_root.eb.removeMovieClip()
if(this.vx<0.1 && this.vx>-0.1){
this.vx=1.1;
}
}

The onEnterFrame code for the ball has too much other junk (checking highscores, checking boundaries defined elsewhere, etc) in it to post without cleaning some of the irrelevant crap out, but it's not anything like what you posted.


- - Flash - Music - Images - -

BBS Signature

Response to As: Api 2005-07-13 21:58:31


been trying to create a ball like yours and I think I got it

function makeball (rd) {
_root.createEmptyMovieClip("ball",7000)
with (ball) {
lineStyle (0,16776960,30)
beginFill (16737792)
moveTo (rd,0)
am = 0.414213562373095
for ( var angle = 45; angle <= 360; angle = angle + 45){
var endx = rd * Math.cos(angle * Math.PI / 180)
var endy = rd * Math.sin(angle * Math.PI / 180)
var cx = endx + rd * am * Math.cos((angle - 90) * Math.PI / 180)
var cy = endy + rd * am * Math.sin((angle - 90) * Math.PI / 180)
curveTo (cx,cy,endx,endy)
}
endFill ()
beginFill (16777215)
moveTo (3,-7)
curveTo (10,-4,7,1.5)
curveTo (5,-6,3,-7)
endFill ()
_x = _width / 2
_y = SH - _height / 2 - 50
}
ball.vx = 2
ball.vy = 0
ball.ocount = 0
ball.otarget = random(100) + 10
}

It looks pretty much the same as the one in the game

Response to As: Api 2005-07-13 22:03:32


At 7/13/05 09:58 PM, SpittingImage wrote: been trying to create a ball like yours and I think I got it
It looks pretty much the same as the one in the game

Haha, nice job decompiling my game there. If you'd written that yourself, the colour values would look like this: 0x897754, not 8-digit numbers. I just set swf decompiler on the swf of Throw It!, and the AS code it produces is exactly what you pasted.

In other words, don't claim credit for ripped code


- - Flash - Music - Images - -

BBS Signature

Response to As: Api 2005-07-13 22:16:11


Someone needs to make a AS: 3D API topic!! SO we can learn to make 3D objects with API, like that example shown earlier!

Response to As: Api 2005-07-13 22:19:54


At 7/13/05 10:03 PM, Denvish wrote: Haha, nice job decompiling my game there. If you'd written that yourself, the colour values would look like this: 0x897754, not 8-digit numbers. I just set swf decompiler on the swf of Throw It!, and the AS code it produces is exactly what you pasted.

In other words, don't claim credit for ripped code

BURNED!!!

Response to As: Api 2005-07-13 22:28:23


Hey denvish, I have a decompiler. But do you think it's wrong to use it to study other people's scripts? Like your throw it game, I decompiled it so that I could study the scripting. Is it wrong to do it? If i'm not telling others that I made it or broadcasting it, if I'm just using it to study, is it alright?

Response to As: Api 2005-07-14 03:17:28


At 7/13/05 10:28 PM, jeremysfilms wrote: Hey denvish, I have a decompiler. But do you think it's wrong to use it to study other people's scripts? Like your throw it game, I decompiled it so that I could study the scripting. Is it wrong to do it? If i'm not telling others that I made it or broadcasting it, if I'm just using it to study, is it alright?

Well, I can't really criticise you for it, since it's something I've done myself in the past. So long as you're not copying letter-for-letter into your own game, I'd say it's OK. Unfortunately, programs like Eltima cause headaches for developers, because they render most forms of swf protection useless. The good thing is that people are starting to develop swf encryptors, which will obscure all actionscript and prevent code stealing (in theory, at least).


- - Flash - Music - Images - -

BBS Signature

Response to As: Api 2005-07-14 08:01:37


At 7/14/05 03:17 AM, Denvish wrote: The good thing is that people are starting to develop swf encryptors, which will obscure all actionscript and prevent code stealing (in theory, at least).

Like the cool password thing that Inglor made, that was good.. Anyway, I don't trust decompiling a flash for its code because the decompiler usually goes wrong somewhere.. and I don't really need to look at others code O_O.

I'm going to do something tonight when I get home in API, basically it's my random movement code but I'm going to add depth. I also want to make another short game in API, because of how cool 'tis. Something simple, a puzzle game maybe.

I've also got a really good idea for something that I will post tonight, you'll need to be able to make a game in API and you'll find out the rest later :P


Sup, bitches :)

BBS Signature

Response to As: Api 2005-07-14 10:05:22


Darn,I should get a decompiler too..
I'll have a look at Alien Hominid's AI engine :P ( joking).
But hey,Denvish,since people can decompile your game,would you mind posting the code here?


BBS Signature

Response to As: Api 2005-07-14 15:38:30


Here is the random movement code I promised, with a _z axis. It took a strangely short time and there were no problems whatsoever. AYA!

Copy and paste:

_root.createEmptyMovieClip("square", -16384);
//make a new MC
with (square) {
//begin squares attributes
lineStyle(2, 0xffffff, 100);
//squares lines should be 2 pixels thick, white and 100% visible
moveTo(-10, -10);
beginFill(0x000000, 100);
//begin filling in black
lineTo(10, -10);
lineTo(10, 10);
lineTo(-10, 10);
lineTo(-10, -10);
//the lines to be drawn
endFill();
}
//end the squares attributes
onLoad = function () {
getX = random(550);
getX = random(400);
};
//when the flash loads, the squares target X and Y (getX/Y) randomise.
onEnterFrame = function () {
square._xscale = square._yscale;
//the squares X scale should match it's Y scale.
gotoX = (getX-square._x)/speed;
gotoY = (getY-square._y)/speed;
gotoZ = (getZ-square._yscale)/Zspeed;
//This sets by how much the square should move to get to the desired location.
square._x += gotoX;
square._y += gotoY;
square._yscale += gotoZ;
//this tells the square to move
speed = 20;
Zspeed = 10;
//this sets the speeds.
if (0.5>gotoX) {
getX = random(550);
getY = random(400);
getZ = random(200);
}
//when the square is slowed down (when it is near the desired location) it should pick a new location
};

I even explained it for people that don't understand! omg!

Sup, bitches :)

BBS Signature

Response to As: Api 2005-07-14 18:04:10


Quick firework-style script. Click background to generate.

//Recommend 20 to 25 FPS
gravity=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)

Result


- - Flash - Music - Images - -

BBS Signature

Response to As: Api 2005-07-14 18:11:07


s = 0;
_root.createTextField("t", 8, 200, 200, 350, 200);
t.text = "Click to start. First to 10 wins";
p = Math.PI;
_root.onMouseDown = function() {
if (s == 0) {
s1 = s2=a=0;
t.text = "";
_root.createEmptyMovieClip("p1", 1);
p1.moveTo(-5, -40);
p1.beginFill(0x000);
p1.lineTo(5, -40);
p1.lineTo(5, 40);
p1.lineTo(-5, 40);
p1.lineTo(-5, -40);
p1.endFill;
p1._x = 15;
p1._y = 200;
s = 2;
duplicateMovieClip("p1", "p2", 2);
duplicateMovieClip("p1", "b", 3);
p2._x = 535;
p2._y = 200;
b._height = 10;
sp = 9;
_root.createTextField("t1", 4, 30, 20, 20, 20);
_root.createTextField("t2", 5, 510, 20, 20, 20);
}
};
_root.onEnterFrame = function() {
if (s == 1) {
if (s1>=10) {
t.text = "Player Wins! Click to play again";
}
if (s2>=10) {
t.text = "CPU Wins! Click to play again";
}
if (s1>=10 || s2>=10) {
removeMovieClip(p1);
removeMovieClip(p2);
removeMovieClip(b);
s = 0;
}
if (sp>19) {
sp = 19;
}
t1.text = s1;
t2.text = s2;
p1._y = _ymouse;
if (Math.abs(xs)<1.5) {
xs = -3;
}
b._x += xs;
b._y -= ys;
if (b._x<20 && b._y>p1._y-40 && b._y<p1._y+40) {
b._x = 20;
a = Math.atan2(b._x-p1._x, b._y-p1._y)/(p/180)*-1+180;
xs = sp*Math.sin(a*(p/180));
ys = sp*Math.cos(a*(p/180));
}
if (b._x>530 && b._y>p2._y-40 && b._y<p2._y+40) {
b._x = 530;
a = Math.atan2(b._x-p2._x, b._y-p2._y)/(p/180)*-1+180;
xs = sp*Math.sin(a*(p/180));
ys = sp*Math.cos(a*(p/180));
}
if (b._y>395) {
ys *= -1;
b._y = 395;
}
if (b._y<5) {
ys *= -1;
b._y = 5;
}
if (b._x<5) {
s2 += 1;
s = 2;
}
if (b._x>545) {
s1 += 1;
s = 2;
}
if (b._y>p2._y) {
p2._y += 7;
}
if (b._y<p2._y) {
p2._y -= 7;
}
}
if (s == 2) {
b._x = 275;
sp += .5;
b._y = 200;
a = random(360);
xs = sp*Math.sin(a*(p/180));
ys = sp*Math.cos(a*(p/180));
s = 1;
}
};

Response to As: Api 2005-07-14 18:40:01


COOL PONG GAME!!

What's API stand for anyway? I've been trying to figure it out.

Response to As: Api 2005-07-14 18:54:09


Response to As: Api 2005-07-15 05:02:20


My first attempt =D
3d Box! <3

_root.createEmptyMovieClip("part1", _root.getNextHighestDepth());
part1.lineStyle(1, 0xFF00FF,0);
part1.beginFill(0x82B9AC, 30);
part1.moveTo(160.0,121);
part1.lineTo(270.4,128.3);
part1.lineTo(456.4,125.5);
part1.lineTo(383.7,116.8);
part1.lineTo(160.0,121);
part1.endFill();
_root.createEmptyMovieClip("part1b", _root.getNextHighestDepth());
part1b.lineStyle(1, 0xFF00FF,0);
part1b.beginFill(0x90B5AC);
part1b.moveTo(160.0,121);
part1b.lineTo(270.4,128.3);
part1b.lineTo(456.4,125.5);
part1b.lineTo(454.1,332.5);
part1b.lineTo(271.1,317.2);
part1b.lineTo(271.1,317.2);
part1b.lineTo(270.4,128.3);
part1b.endFill();
_root.createEmptyMovieClip("part1c", _root.getNextHighestDepth());
part1c.lineStyle(1, 0xFF00FF,0);
part1c.beginFill(0x51886F);
part1c.moveTo(160.0,121);
part1c.lineTo(270.4,128.3);
part1c.lineTo(271.1,317.2);
part1c.lineTo(163.6,355.2);
part1c.lineTo(160.0,121.0);
part1c.endFill();
_root.createEmptyMovieClip("part1d", _root.getNextHighestDepth());
part1d.lineStyle(1, 0xFF00FF,0);
part1d.beginFill(0x666B6A);
part1d.moveTo(271.1,317.2);
part1d.lineTo(454.1,332.5);
part1d.lineTo(381.9,379.6);
part1d.lineTo(163.6,355.2);
part1d.lineTo(271.1,317.2);
part1d.endFill();
_root.createEmptyMovieClip("part1e", _root.getNextHighestDepth());
part1e.lineStyle(1, 0xFF00FF,0);
part1e.beginFill(0x385F50, 50);
part1e.moveTo(383.7,116.8);
part1e.lineTo(456.4,125.5);
part1e.lineTo(454.1,332.5);
part1e.lineTo(381.9,379.6);
part1e.lineTo(383.7,116.8);
part1e.lineTo(456.4,125.5);
part1e.endFill();

=D

Response to As: Api 2005-07-15 05:37:36


you guys wanna have a 35 line contest, who can make the best think with only 25 lines of coding.
must be api

and ive made (crappy) asteroid games with only 25 lines of coding(i think, might have been 35), so you'll be fine

Response to As: Api 2005-07-15 05:44:10


At 7/15/05 05:37 AM, punkkid7188 wrote: you guys wanna have a 35 line contest, who can make the best think with only 25 lines of coding.
must be api

and ive made (crappy) asteroid games with only 25 lines of coding(i think, might have been 35), so you'll be fine

DONE!
LESS THAN ONE LINE OF CODE!!!
createEmptyMovieClip("1",1);1.lineStyle(1,
0x000000,1);1.moveTo(1,1);1.LineTo(1,1);


BBS Signature

Response to As: Api 2005-07-15 05:45:48


Ohhh, ahh, but if you hit auto format thats 4 lines! If we are allowed to cram as much code onto one line as we want, this could get crazy.

Response to As: Api 2005-07-15 05:48:02


At 7/15/05 05:45 AM, BleeBlap wrote: Ohhh, ahh, but if you hit auto format thats 4 lines! If we are allowed to cram as much code onto one line as we want, this could get crazy.

Hahaha.. Erm..
Darn ) :


BBS Signature

Response to As: Api 2005-07-15 06:00:12


i really didnt think i'd have to add this, but the maximum is determened by the number of lines after being autoformatted.
and just a hint, use alot of functions. anything used more then once and is more then 2 lines. id make a function for

Response to As: Api 2005-07-15 09:43:16


Hmmm, 35 lines... that's a challenge. I think 50 lines would be better, 35 is too limiting - it takes a good 10-20 lines just to draw shapes.

Anyway:
Boring Bucket
Code lines: 35
Filesize: 690 bytes

Code: (use 30 FPS)
_root.createTextField("score", 50000, Stage.width/2, 0, 100, 20);
score.text = "0";
score.textColor = 0xFFFFFF;
_root.createEmptyMovieClip("bucket", 30000);
bucket.beginFill(0xCCCCCC);
bucket.moveTo((Stage.width/2)-20, Stage.height-40);
bucket.lineTo((Stage.width/2)+20, Stage.height-40);
bucket.lineTo((Stage.width/2)+15, Stage.height-5);
bucket.lineTo((Stage.width/2)-15, Stage.height-5);
bucket.endFill();
function makedrop(obno) {
_root.createEmptyMovieClip("drop"+obno, obno);
_root["drop"+obno].lineStyle(14, 0x0099FF, 100);
_root["drop"+obno].moveTo(0, 0);
_root["drop"+obno].lineTo(0.2, 0);
_root["drop"+obno].spd = random(7)+3;
_root["drop"+obno]._x = random(Stage.width-14)+7;
_root["drop"+obno].onEnterFrame = function() {
this._y += this.spd;
(this._y>Stage.height) ? _root.h(this, 0, 0, obno) : null;
(this.hitTest(_root.bucket)) ? _root.h(this, 1, this.spd, obno) : null;
};
}
function h(mc, ct, sc, obno){
(ct<>1) ? null : _root.score.text = int(_root.score.text)+sc;
removeMovieClip(mc);
_root.makedrop(obno);
}
onEnterFrame = function () {
bucket._x -= Key.isDown(37)*10;
bucket._x += Key.isDown(39)*10;
};
for (z=1; z<10; z++) {
makedrop(z);
}


- - Flash - Music - Images - -

BBS Signature

Response to As: Api 2005-07-15 09:54:28


By the way,Denvish,instead of making that complicated system for your "THROW IT" background,there's "_root.beginGradientFill" command -_- ...
No need for dozens of line of code : P


BBS Signature

Response to As: Api 2005-07-15 10:01:50


beginGradientFill still takes dozens of lines of code (at least I can't figure it out)

Response to As: Api 2005-07-15 10:07:00


At 7/15/05 10:01 AM, Glaiel_Gamer wrote: beginGradientFill still takes dozens of lines of code (at least I can't figure it out)

Really?Isn't it:
BG.beginGradientFill(filType,colors,alphas
,ratios,matrix);
?

Denvish's codes is a lot longer..


BBS Signature

Response to As: Api 2005-07-15 10:07:06


At 7/15/05 09:54 AM, -Toast- wrote: By the way,Denvish,instead of making that complicated system for your "THROW IT" background,there's "_root.beginGradientFill" command -_- ...
No need for dozens of line of code : P

I looked into that, and I prefer my way... you just have to specify 2 hexidecimal codes, rather than messing with R: G: and B: values.


- - Flash - Music - Images - -

BBS Signature

Response to As: Api 2005-07-15 10:08:07


At 7/15/05 10:07 AM, Denvish wrote: I looked into that, and I prefer my way... you just have to specify 2 hexidecimal codes, rather than messing with R: G: and B: values.

It's more useful for the "30 lines of code" contest though.


BBS Signature

Response to As: Api 2005-07-15 10:22:30


At 7/15/05 10:08 AM, -Toast- wrote:
At 7/15/05 10:07 AM, Denvish wrote: I looked into that, and I prefer my way... you just have to specify 2 hexidecimal codes, rather than messing with R: G: and B: values.
It's more useful for the "30 lines of code" contest though.

True. Actually, the reason why this wouldn't work for Glaiel is probably because both in the AS Dictionary and on this page, they haven't capitalised the T in 'lineto' or 'moveto' - so the code works fine for Flash Player 6, but not for 7. This code will work:

_root.createEmptyMovieClip("grad", 1);
with (grad) {
colors = [0xFF0000, 0x0000FF];
alphas = [100, 100];
ratios = [0, 0xFF];
matrix = {a:200, b:0, c:0, d:0, e:200, f:0, g:200, h:200, i:1};
beginGradientFill("linear", colors, alphas, ratios, matrix);
moveTo(100, 100);
lineTo(100, 300);
lineTo(300, 300);
lineTo(300, 100);
lineTo(100, 100);
endFill();
}


- - Flash - Music - Images - -

BBS Signature