00:00
00:00
Newgrounds Background Image Theme

ESCANOR2169 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!

AS: Little tricks and tidbits

9,527 Views | 65 Replies
New Topic Respond to this Topic

Response to AS: Little tricks and tidbits 2005-11-24 09:39:22


Hey, I found the best gadget of all time:
AS: Main ;)


BBS Signature

Response to AS: Little tricks and tidbits 2005-11-24 09:50:34


function getGCD(a, b)
{
while (b != 0)
{
tmpB = b;
b = a % b;
a = tmpB;
}
return a;
}

Usage:

A short way to get the greatest common denominator of a and b. For example:

trace(getGCD(20, 8)); // returns 4
trace(getGCD(121, 44)); // returns 11
trace(getGCD(9, 129)); // returns 3

Response to AS: Little tricks and tidbits 2005-11-24 09:55:15


At 11/24/05 09:50 AM, Begoner wrote: function getGCD(a, b)

Nice one there


BBS Signature

Response to AS: Little tricks and tidbits 2005-11-24 10:45:41


At 11/24/05 09:50 AM, Begoner wrote: function getGCD(a, b)

It's a good function, you could get rid of the != 0 in while (b != 0) though =)


BBS Signature

Response to AS: Little tricks and tidbits 2005-11-24 11:11:51


At 11/23/05 06:15 PM, -dELta- wrote: function cout():Void
{
trace(arguments);
}

Nice function, I had no idea you could use arguments in flash (I've never seen it used before) so that might come in handy too ^^

At 11/24/05 04:43 AM, T-H wrote: This is a shite excuse for an AS thread, come on...

Yeah, it's a good thread but I can't see why it's an AS thread =\

At 11/24/05 05:11 AM, ZYX3D wrote: Since "null" is too much for a nothing for me, I use 0 instead. The very same effect, but 75% shorter.

Same here, I can't see why everyone uses null when 0 is so much shorter and easier.


Sup, bitches :)

BBS Signature

Response to AS: Little tricks and tidbits 2005-11-24 13:37:18


At 11/24/05 08:16 AM, T-H wrote: Very true, but my point being: I've never had to do that, and can't think of a time when I will.

on my new game, i wanted something special
to happen every 5 rounds, so i set it up to happen:

if (round%5==0){
// do thing
}


BBS Signature

Response to AS: Little tricks and tidbits 2005-11-24 14:04:13


At 11/24/05 01:37 PM, authorblues wrote: if (round%5==0){
// do thing
}

Thats a good example of how it can be used

=P


Sup, bitches :)

BBS Signature

Response to AS: Little tricks and tidbits 2005-11-24 14:24:03


At 11/24/05 05:23 AM, Rantzien wrote:
At 11/24/05 04:43 AM, T-H wrote: Nonono, it really isn't. The only use Ive ever found for it is to make object snap to a grib by getting the remainder and adding/taking it, but there is an even easier way to do that anyway.
You could also check if something is evenly divisible by something:

function isDiv (a:Number, b:Number):Boolean {
return a%b ? false : true;
}

As was mentioned before, true = 1, false = 0, and vise versa. So a variation of that function could be:

function isDiv(a:Number, b:Number):Boolean {
return !Boolean(a%b);
}

Response to AS: Little tricks and tidbits 2005-11-24 14:35:34


At 11/24/05 02:24 PM, -fwe- wrote:

:(...)


As was mentioned before, true = 1, false = 0, and vise versa. So a variation of that function could be:

Actually, 0 and undefined are false, everything else (1,2, INFINITY, -200...) is true.

Response to AS: Little tricks and tidbits 2005-11-24 15:46:33


At 11/24/05 02:04 PM, -liam- wrote: =P

hehe, liam cant get pwned

Response to AS: Little tricks and tidbits 2005-11-24 16:29:41


At 11/24/05 02:24 PM, -fwe- wrote: As was mentioned before, true = 1, false = 0, and vise versa.

Yeah, I know. It's not a very useful function anyways, just a quick example =D


BBS Signature

Response to AS: Little tricks and tidbits 2005-11-24 17:11:18


At 11/24/05 01:37 PM, authorblues wrote: on my new game, i wanted something special
to happen every 5 rounds, so i set it up to happen:

if (round%5==0){
// do thing
}

And that couldn't have been done using

if(round == 5){

:S ?

Response to AS: Little tricks and tidbits 2005-11-24 17:15:21


At 11/24/05 05:11 PM, T-H wrote: And that couldn't have been done using

if(round == 5){

Actually not =)
If round is 10, for example:
round == 5 // false
round%5 == 0 // true

You could say that modulo (%) divides round by 5, and returns the remainder.


BBS Signature

Response to AS: Little tricks and tidbits 2005-11-24 17:24:06


At 11/24/05 05:15 PM, Rantzien wrote:
At 11/24/05 05:11 PM, T-H wrote: And that couldn't have been done using

if(round == 5){
Actually not =)
If round is 10, for example:
round == 5 // false
round%5 == 0 // true

You could say that modulo (%) divides round by 5, and returns the remainder.

I missed the every 5 rounds part , thanks :D

thought it just said on round 5

Response to AS: Little tricks and tidbits 2005-11-24 18:21:46


At 11/24/05 02:04 PM, -liam- wrote: Thats a good example of how it can be used
=P

awww... theifer. that was my idea, with the encryption variable.
good work. i KNOW you only did that out of spite for TD's 1337-translator...

...kids today, with their grudges and their pumpkin pies...


BBS Signature

Response to AS: Little tricks and tidbits 2005-11-27 18:11:38


hey something just gave me an idea based on all these translator thingies...

if you did << with a string what would it do

Response to AS: Little tricks and tidbits 2005-12-10 16:55:49


At 11/27/05 06:11 PM, Glaiel_Gamer wrote: hey something just gave me an idea based on all these translator thingies...

if you did << with a string what would it do

if you use bitwise shift on a string (non numeric) then you get 0

Response to AS: Little tricks and tidbits 2006-02-18 13:39:59


At 11/23/05 03:23 PM, -cherries- wrote:
stop;

wow. your such crap at action script you said that! it stop(); not stop;


If a man that always tells the truth comes up to you and says that another man always tells lies, and the man who always lies come up to you and says "I'm lying", then is he?

BBS Signature

Response to AS: Little tricks and tidbits 2006-02-18 13:47:15


At 2/18/06 01:39 PM, DragonFruit_Clock wrote: wow. your such crap at action script you said that! it stop(); not stop;

myMovieClip.onMouseDown = stop;


Sup, bitches :)

BBS Signature

Response to AS: Little tricks and tidbits 2006-02-18 14:34:55


At 11/23/05 06:15 PM, -dELta- wrote: you have 3 variables: x,y,z
and you want to trace them:

can somebody tell me waht trace means?

Response to AS: Little tricks and tidbits 2006-02-18 14:38:17


At 2/18/06 02:34 PM, ryanpridgeon wrote:
At 11/23/05 06:15 PM, -dELta- wrote: you have 3 variables: x,y,z
and you want to trace them:
can somebody tell me waht trace means?

trace(); is an action that receives data and displays it in the Output box, which only you will see on your version of flash.

trace("this is what the trace action does");
//this will make the text "this is what the trace actoin does" appear in your Output box

Response to AS: Little tricks and tidbits 2006-02-18 14:40:54


:ppl said stuff about trace

wow thats kinda useful... no more temporary dynamic text boxes... lol..

Response to AS: Little tricks and tidbits 2006-02-18 14:54:11


At 2/18/06 02:40 PM, ryanpridgeon wrote:
ppl said stuff about trace
wow thats kinda useful... no more temporary dynamic text boxes... lol..

haha yea, trace is a lot easier when you want to solve problems on your own or calculate data or something. But just remember that only you see it and it won't show up on the regular swf.

Response to AS: Little tricks and tidbits 2006-02-18 14:54:26


Be a l337 h4rdc0r3 h4xx0r and write actionscript in pure bytecode!
__bytecode__("88240002006900486F6C79207368
69742C2062797465636F646520696E207468652066
6C612100960B0008000600000000000000003C9602
0008001C960500070A00000048129D020015009602
00080126960400080008001C501D990200D6FF00")
;

Response to AS: Little tricks and tidbits 2006-02-18 14:58:40


At 2/18/06 02:54 PM, Newsdee wrote: Be a l337 h4rdc0r3 h4xx0r and write actionscript in pure bytecode!
__bytecode__("numbers");

Yeah... How did you do that again?


BBS Signature

Response to AS: Little tricks and tidbits 2006-02-18 15:02:38


At 2/18/06 02:54 PM, Newsdee wrote: Be a l337 h4rdc0r3 h4xx0r and write actionscript in pure bytecode!
__bytecode__("numbers");

WTFZ0Rz

Response to AS: Little tricks and tidbits 2006-02-18 15:02:53


At 2/18/06 02:54 PM, Newsdee wrote: Be a l337 h4rdc0r3 h4xx0r and write actionscript in pure bytecode!
__bytecode__("88240002006900486F6C79207368
69742C2062797465636F646520696E207468652066
6C612100960B0008000600000000000000003C9602
0008001C960500070A00000048129D020015009602
00080126960400080008001C501D990200D6FF00")
;

"holy shit, bitecode in the fla" i think is what it translates into

Response to AS: Little tricks and tidbits 2006-02-18 15:12:21


At 2/18/06 02:58 PM, Rantzien wrote:
__bytecode__("numbers");
Yeah... How did you do that again?

You can use Flasm to compile the bytecode from Flash assembly language. Or you can try opening an swf with a hex editor and copy/pasting :-)

Response to AS: Little tricks and tidbits 2006-02-18 15:15:01


At 2/18/06 03:12 PM, Newsdee wrote: You can use Flasm to compile the bytecode from Flash assembly language. Or you can try opening an swf with a hex editor and copy/pasting :-)

Oh, ok =)
It doesn't work with graphics too, does it?


BBS Signature

Response to AS: Little tricks and tidbits 2006-02-18 15:20:11


At 2/18/06 03:15 PM, Rantzien wrote: It doesn't work with graphics too, does it?

For embedding jpgs, for example? No, it's just encoded AS. :-(
That being said, it's easy to make your own bytecode interpreter for images. Just grab every 2 characters in a hex string and convert them a single byte...