Be a Supporter!
Response to: question about arrays Posted July 22nd, 2005 in Game Development

At 7/22/05 05:38 PM, TaXxER wrote: Let's say I have two Array with 26 elements. The first Array is filled with the letters of the alphabet. I want to fill the second Array with the same letters but now in a random order.
What is the easiest way to do this?

A1=new Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
A2=new Array();
while(A1.length>0){
f=random(A1.length)
A2.push(A1.slice(f, f+1))
A1.splice(f, 1);
}
trace(A2)

This will destroy your original A1 array, so create it again afterwards if you need to

A1=new Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");

Response to: AS: While Posted July 22nd, 2005 in Game Development

At 7/22/05 04:17 PM, -KhAo- wrote: but to stay in topic, basically, while is only a loop of "if" right?
would do the same to make
for(...){
if(...){
...
}
}
?

Yes, but that's a for more than an if. But that's the way I do it, I rarely have a need for while loops. There are rare occasions where they're necessary, but generally I'll go out of my way to avoid them.

Response to: AS: While Posted July 22nd, 2005 in Game Development

At 7/22/05 03:36 PM, Glaiel_Gamer wrote: you'd need 250 if statements to do the same as a while statement.

Or a for and an if =)

At 7/22/05 03:36 PM, Inglor wrote: no you can't... unless you do function recursion instead... which I doubt anyone really uses :P
while is importent

It's nothing that can't be done with for loops. I very rarely use while loops, for exactly the same reason as -liam-, I hate losing 30+ minutes of work because Flash is too stupid to recognise and halt an infinite loop (or I'm too stupid to realise I wrote one ;)

Response to: Highscore Hackers Discussion Thread Posted July 22nd, 2005 in Game Development

It's a tricky one, you probably noticed I had major problems with the Throw It scoreboard. One thing you can do is find a program to encrypt your ASP/PHP pages, but while your swf is so readily and easily decompileable, it's hard to hide the URL of the dynamic pages, and the password(s) you use when sending to PHP/ASP.

One thing I'm trying at the moment is creative use of arrays and strings to 'muddle' both the passwords and especially the URL. If you turn the URL string into an array, and then use a random method to jumble it up into another array in a way that's reversible by another function, that will discourage a lot of people (I hope). Here's an example of something I'm playing with, you'll need to run it in a separate swf from your main one

Randomise function:

ustr= "http://www.sitename.com/folder/score.php"
;
uarr=ustr.split("");
farr=new Array();

while(uarr.length>0){
f=random(uarr.length)
farr.push (uarr.slice(f, f+1))
farr.push(f)
uarr.splice(f, 1);
}
trace(farr)

This will output a string like this:

m,22,s,30,:,4,d,25,w,7,t,2,c,26,h,0,m,13,e
,26,o,16,/, 16,w,4,p,26,e,9,/,19,a,10,i,7,o,17,/, 3,r,15,t,6,n,6,p,15,.,4,e, 11,w,3,s,3, c,5,l,7,/,2,f,4,h,7,t,0,o,3,r,3,p,0,.,1,.,
1,e,0

Paste that into Notepad, and use Replace to change this: ,
to this: ","
Add a " to the start and end, too

Now you add this jumble as a new Array in your Flash movie, and convert it back to a URL with this code:

A1=new Array("m","22","s","30",":", "4","d","25","w","7", "t","2","c","26","h", "0","m","13","e","26","o","16", "/","16","w","4","p","26","e","9", "/","19","a","10","i","7","o","17", "/","3","r","15","t","6","n","6","p", "15",".","4","e","11","w","3","s","3","c",
"5","l" "7","/","2","f","4","h","7","t","0","o","3
","r","3", "p","0",".","1",".","1","e","0")
gtr=new Array(); ku="";
while(A1.length>0){
f=A1.length; gtr.splice(A1[f-1], 0, A1.slice(f-2, f-1)); A1.splice(f-2, 2);
}
for(i=0;i<gtr.length;i++) {ku=ku+gtr[i];}
trace(ku)

It's by no means hackproof, but it will discourage casual swf decompilers from taking the obvious path, which is passing values directly to the ASP/PHP page.

You can also use passwords on your dynamic pages: in asp, if("pass"="khfllkhfdkl") Then. Again, you can hide obvious passwords by creating an array dynamically and pulling random items from it. eg:

f=0;
for(i=C3.length-1; i>0; i--){
f+= C3[i]+C4[i];
}
C6=new Array();
pass=1;
for(i=0; i<1000; i++){
pass++;
if(pass>76){ //change this value if you want
pass=1;
}
C6.push(pass);
}
pass=7;
for(i=0; i<1000; i+=146){ //change 146 if you want
pass*=C6[i];
}
trace(pass)

Hope that helps. I intend to try out Swf Encrypt at some point, but I read somewhere that the protection it offers is minimal - it basically just adds some variables to the head & tail of the script that prevent decompilers from reading the AS. Still, probably enough to discourage the majority of amateur hackers.

The worst part I find is the '5000 view - cannot update the swf' rule on NG, it's been a pain in the ass to me with both submissions since it was implemented.

Response to: AS: While Posted July 22nd, 2005 in Game Development

At 7/22/05 02:55 PM, Inglor wrote:
At 7/22/05 02:31 PM, Denvish wrote: while will continue to loop & check the condition until it is either true or false.
the condition is always either true or false... while checks untill the condition is true...

well, I was thinking of:

while (!condition){statements} -checks until condition is true
while (condition){statements} -checks until condition is false

Response to: AS: While Posted July 22nd, 2005 in Game Development

At 7/22/05 02:19 PM, -KhAo- wrote: isnt while the same thing as if?

No, if only checks if a condition is true or false ONCE.
while will continue to loop & check the condition until it is either true or false. That's why it's vital to make sure that your while loop contains statements which will make your condition either true or false.

Response to: AS: While Posted July 22nd, 2005 in Game Development

At 7/22/05 12:55 PM, Glaiel_Gamer wrote:
At 7/22/05 12:53 PM, Denvish wrote: My tip: ALWAYS save your .fla before you test a while loop. I've lost count of the number of times I've crashed Flash by mistakenly using an infinite loop.
If it freezes eventually it asks if you want to abort the script.

For me, it does that for other CPU-killing code, but never for while loops. I've left Flash for 30+ minutes before in the hopes that it will recover and let me save, but no dice.

Response to: As: Main Posted July 22nd, 2005 in Game Development

At 7/22/05 12:24 PM, SpamBurger wrote: Yay! The updated list! Im surprised my creating boundaries got in the intermediate and not beginner.

Well, it probably should be in Beginner, but I thought I'd put it with the other Collision stuff.

At 7/22/05 12:55 PM, Glaiel_Gamer wrote: Yes! And I made it into the advanced section.

I think anything to do with API is pretty advanced. I only just got into it after 5+ years of using Flash.

Response to: As: Main Posted July 22nd, 2005 in Game Development

BASIC
AS: Basic A.I. by Dancing-Thunder
AS: Clock by Glaiel_Gamer
AS: Duplicated Movie Clips
AS: Inventory 1 by Inglor
AS: Loops & Conditions by BleeBlap
AS: Loops - For... In by Inglor
AS: Loops - While by Ninja-Chicken
AS: Maths - Basic by T-H
AS: Movement - Basic
AS: Movement - Scrolling background by DrDeath2k3
AS: Password by Dancing-Thunder
AS: Performance & Optimisation Tips by T-H
AS: Preloader
AS: Quality Toggling
AS: Replay Button by Inglor
AS: Sound
AS: Stop & Play Buttons by Inglor
AS: Symbols by Joelasticot
AS: Variables by Dark_Toaster

INTERMEDIATE
AS: Arrays
AS: Camera Control by Inglor
AS: Collisions by Glaiel_Gamer
AS: Collision Detection by BleeBlap
AS: Creating Boundaries by Spamburger
AS: Debugging Syntax by Inglor
AS: Elasticity by Joelasticot
AS: Functions - Basic by Inglor
AS: Intervals by Inglor
AS: Linear Increasement by Inglor
AS: Load External Data/Cross-Domain
AS: Maths - Intermediate by Inglor
AS: Maze by Begoner
AS: Movement - On slopes by Joelasticot
AS: Output Panel Manipulation by Inglor
AS: Platform Game Basics by Atomic_Sponge
AS: Pong Physics & Gravity by Dark_Toaster
AS: Rain Effect by Inglor
AS: Save and Load
AS: SWF Right-Click Menu
AS: Typewriter Effect by Atomic_Sponge
AS: Volume Slider by Star_Cleaver

ADVANCED
AS: API by -liam-
AS: API Curves by Glaiel_Gamer
AS: API 3-Gradient Fills by Inglor
AS: Binary Increasement by Inglor
AS: Syntax Checking Stack by Inglor
AS: Modular Programming by Inglor
AS: Tile Based Game Development Map by Inglor
AS: Movement - Random by Begoner
AS: OOP (Object Oriented Programming) by Inglor
AS: System Capabilities (Flash-PC Communication) by Inglor
AS: Trigonometry by BleeBlap
AS: XML by Inglor

Total: 53

Response to: AS: While Posted July 22nd, 2005 in Game Development

My tip: ALWAYS save your .fla before you test a while loop. I've lost count of the number of times I've crashed Flash by mistakenly using an infinite loop.

Response to: As: Main Posted July 22nd, 2005 in Game Development

At 7/22/05 12:20 PM, SpamBurger wrote: Denvish, are you gonna update the page? People made a lot more!

Meep. Busy.

BASIC
AS: Basic A.I. by Dancing-Thunder
AS: Clock by Glaiel_Gamer
AS: Conditions and Loops by BleeBlap
AS: Duplicated Movie Clips
AS: For... in loops by Inglor
AS: Inventory 1 by Inglor
AS: Maths - Basic by T-H
AS: Movement - Basic
AS: Movement - Scrolling background by DrDeath2k3
AS: Password by Dancing-Thunder
AS: Performance & Optimisation Tips by T-H
AS: Preloader
AS: Quality Toggling
AS: Replay Button by Inglor
AS: Sound
AS: Stop & Play Buttons by Inglor
AS: Symbols by Joelasticot
AS: Variables by Dark_Toaster

INTERMEDIATE
AS: Arrays
AS: Camera Control by Inglor
AS: Collisions by Glaiel_Gamer
AS: Collision Detection by BleeBlap
AS: Creating Boundaries by Spamburger
AS: Debugging Syntax by Inglor
AS: Elasticity by Joelasticot
AS: Functions - Basic by Inglor
AS: Intervals by Inglor
AS: Linear Increasement by Inglor
AS: Load External Data/Cross-Domain
AS: Maths - Intermediate by Inglor
AS: Maze by Begoner
AS: Movement - On slopes by Joelasticot
AS: Output Panel Manipulation by Inglor
AS: Platform Game Basics by Atomic_Sponge
AS: Pong Physics & Gravity by Dark_Toaster
AS: Rain Effect by Inglor
AS: Save and Load
AS: SWF Right-Click Menu
AS: Typewriter Effect by Atomic_Sponge
AS: Volume Slider by Star_Cleaver

ADVANCED
AS: API by -liam-
AS: API Curves by Glaiel_Gamer
AS: API 3-Gradient Fills by Inglor
AS: Binary Increasement by Inglor
AS: Syntax Checking Stack by Inglor
AS: Modular Programming by Inglor
AS: Tile Based Game Development Map by Inglor
AS: Movement - Random by Begoner
AS: OOP (Object Oriented Programming) by Inglor
AS: System Capabilities (Flash-PC Communication) by Inglor
AS: Trigonometry by BleeBlap
AS: XML by Inglor

Response to: Actionscript is as diverse as... Posted July 20th, 2005 in Game Development

At 7/20/05 05:45 PM, Wasson wrote: P.S. It's driven me to the brink of insanity.

heh, been there... today, yesterday, several times last week, etc.

Response to: creata a loading bar Posted July 20th, 2005 in Game Development

AS: Preloader

AS: Main

Response to: Linking to NG Mp3's Posted July 20th, 2005 in Game Development

You can link to an artist's page by using getURL, but the .mp3 files themselves are downloaded from the Audio Portal via a javascript command, so I don't think it's possible to download or stream the audio files into a Flash.

Response to: Looking for flash maker for hire. Posted July 20th, 2005 in Game Development

At 7/20/05 06:26 AM, SonicZoner wrote: Man, it says your nuetral but you seem pretty mean to me. Is there anybody who can finish a sentence without swearing these days? >: /
At 7/20/05 05:03 AM, SonicZoner wrote: Light aura huh?

Aura has nothing to do with posting.
Aura?

Response to: Linking to NG Mp3's Posted July 20th, 2005 in Game Development

At 7/20/05 06:44 AM, Techno_7 wrote: Can i link directly to the ng mp3's through actionscript? And how?

Nope.

Response to: All sorts of Action Script Posted July 19th, 2005 in Game Development

At 7/19/05 07:05 PM, MrPuff wrote: WHERE DO I TAKE A TUTORIAL????

Pick one:

NG's best tutorial movies
Flash tuts list by AGH
Miscellaneous stuff
AS: Main
Flashkit
actionscript.org
Kirupa
good-tutorials.com

Response to: tea for two collab Posted July 19th, 2005 in Game Development

At 7/19/05 07:05 AM, Appleberry wrote: I believe that you are the worst collab organiser EVER

Response to: Shooting from an MC Posted July 19th, 2005 in Game Development

I would do it like this:

On the first frame of the main timeline, define your bullet speed and add a key listener for the SHOOT action (SPACE in this case)

bulletspeed=20;
z=1000;
firing=0;

kl = new Object(); //Key Listener
kl.onKeyDown = function () {
if (Key.getCode() == 32 && !firing){ //If SPACE is pressed
z++;
firing=1;
duplicateMovieClip ("bullet", "bullet"+z, z)
}
}
kl.onKeyUp = function () {
if (Key.getCode() == 32){ //If SPACE is released
firing=0;
}
}
Key.addListener(kl);

Create your bullet, make it an MC, give it the Instance Name "bullet" and place it off-stage.
Add these actions to it:

onClipEvent(load){
spd= _root.bulletspeed;
if(_name !== "bullet"){
_x= _root.player._x;
_y= _root.player._y;
_rotation= _root.player._rotation;
}
}
onClipEvent(enterFrame){
if(_name !== "bullet"){
if(_rotation>180){
_y+= (spd*Math.cos(Math.PI/180*_rotation));
_x-= (spd*Math.sin(Math.PI/180*_rotation));
}else{
_y-= (spd*Math.cos(Math.PI/180*_rotation));
_x+= (spd*Math.sin(Math.PI/180*_rotation));
}
if (_x>Stage.width+100 || _x<-100 || _y<-100 || _y>Stage.height+100){
this.removeMovieClip(); //Remove duped bullet if off-screen
}
}
}

Rough Demo (SPACE to shoot, arrow keys to move)

Response to: As: Main Posted July 19th, 2005 in Game Development

I count 47 AS: threads now. Once again, many thanks to those who have helped create this resource. Keep 'em coming, and if you decide to make one, make sure you link it in here, so it gets added to the list.

BASIC
AS: Basic A.I. by Dancing-Thunder
AS: Clock by Glaiel_Gamer
AS: Conditions and Loops by BleeBlap
AS: Duplicated Movie Clips
AS: For... in loops by Inglor
AS: Inventory 1 by Inglor
AS: Maths - Basic by T-H
AS: Movement - Basic
AS: Movement - Scrolling background by DrDeath2k3
AS: Password by Dancing-Thunder
AS: Performance & Optimisation Tips by T-H
AS: Preloader
AS: Quality Toggling
AS: Replay Button by Inglor
AS: Sound
AS: Stop & Play Buttons by Inglor
AS: Symbols by Joelasticot
AS: Variables by Dark_Toaster

INTERMEDIATE
AS: Arrays
AS: Camera Control by Inglor
AS: Collisions by Glaiel_Gamer
AS: Collision Detection by BleeBlap
AS: Debugging Syntax by Inglor
AS: Elasticity by Joelasticot
AS: Functions - Basic by Inglor
AS: Intervals by Inglor
AS: Linear Increasement by Inglor
AS: Load External Data/Cross-Domain
AS: Maths - Intermediate by Inglor
AS: Maze by Begoner
AS: Movement - On slopes by Joelasticot
AS: Output Panel Manipulation by Inglor
AS: Platform Game Basics by Atomic_Sponge
AS: Pong physics & gravity by Dark_Toaster
AS: Save and Load
AS: SWF right-click menu
AS: Typewriter Effect by Atomic_Sponge
AS: Volume Slider by Star_Cleaver

ADVANCED
AS: API by -liam-
AS: Binary Increasement by Inglor
AS: Syntax Checking Stack by Inglor
AS: Modular Programming by Inglor
AS: Tile Based Game Development Map by Inglor
AS: Movement - Random by Begoner
AS: OOP (Object Oriented Programming) by Inglor
AS: Trigonometry by BleeBlap
AS: XML by Inglor

Response to: As: Main Posted July 19th, 2005 in Game Development

At 7/19/05 10:08 AM, Inglor wrote: AS: Stop and Play buttons

Cool. Once I get back into the Flash forum (currently on siesta =), I might put together a tut for a Movie Control MC.

Response to: API game collab Posted July 19th, 2005 in Game Development

At 7/19/05 04:08 PM, 23450 wrote: Sorry for the double post, but here is the code i tryed. i drew a square and put bleep blaps code to make it move. Did not work. Any ideas:

_root.createEmptyMovieClip("box", 0);
with ("box") {
lineStyle(3, 0x000000, 100);
beginFill(0x00FF00, 100);
lineTo(0, 50);
lineTo(50, 50);
lineTo(50, 0);
lineTo(0, 0);
moveTo(300, 300);
}
box.onEnterFrame = function() {
if (Key.isDown(Key.RIGHT)) {
_x += 5;
}
};

I don't know if I'm up for this collab right away since I'm currently rather busy with various projects/babies etc, but if there's a slack deadline, I'll try and come up with something interesting.

Response to: yo loada' main, wut up? Posted July 19th, 2005 in Game Development

post the code you're using

Response to: Actionscript several logins Posted July 19th, 2005 in Game Development

Main timeline:

UserA=new Array("InfernoSaint", "username02", "username02", "etc")
PassA=new Array("1234", "password02", "password02", "etc")

Button:

on(release){
ok=0;
for(i=0; i<UserA.length+1; i++){
if(user_txt.text == UserA[i] && pass_txt.text == PassA[i]){
ok++;
}
}

if(ok>0){
this.gotoAndPlay("Succes");
}else{
this.error_mc.gotoAndPlay("start")
}
}

Response to: BS! I got blamed 7 times! Posted July 19th, 2005 in Game Development

Simple answer: make better Flash.

Response to: Omfgjav Help Me Posted July 18th, 2005 in Audio

At 7/18/05 07:29 AM, ehhhROFLCOPTER wrote: Haha. I got it to work! Thanks whatever admin verified me.

No probs. I've been slacking with clearing the list recently, I'm only doing it every 3-5 days currently.

Response to: Guess gfox's b/p Retirement Contest Posted July 18th, 2005 in Where is / How to?

OK, I'm going with ratios:

Blams: 36363
Saves: 24242
Total: 60605