The Armor Games website will be down for maintenance on Monday 10/7/2024
starting at 10:00 AM Pacific time. We apologize for the inconvenience.

ForumsProgramming ForumAS2 Codes for creating functional game

6 5521
alsage
offline
alsage
132 posts
Nomad

Good Programming Scripts AS2
So a lot of people ask âhow do I create games?â
Well there are many ways to create them. For me I like to use flash. I have decided to make a little forum section on simple but affected scripts for your new flash games. These only work for LINGO scripts.

(I have tested all of the scripts before posting them to make sure I donât give you false code)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Conditional statements
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
YOU ONLY NEED THESE ONCE PER FRAME!

this.onEnterFrame = function()
{
(button type code go in here)
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Button Scripting
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Main Frame Script:

yourButton.onRelease = function()
{
(your code goes here)
}

Inside Your Object:

on (release)
{
(Code goes here)
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Arrow Key Movement
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NEEDS CONDITIONAL STATEMENT!

Main Frame:

this.onEnterFrame = function()
{
if(Key.isDown(Key.UP))
{
yourObject._y -= 10;
}

if(Key.isDown(Key.DOWN))
{
yourObject._y += 10;
}

if(Key.isDown(Key.LEFT))
{
yourObject._x -= 10;
}

if(Key.isDown(Key.RIGHT))
{
yourObject._x += 10;
}
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HitTest Statement
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(_root.yourObject.hitTest(_root.yourOtherObject))
{

(Code goes here)

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mouse rollover & rollout
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Make Sure This Code Is Inside Your Object You Want To Rollover & Rollout!

on(rollOver)
{
(Code goes here)
}

on(rollOut)
{
(Code goes here)
}


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Code Placement
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Codes for inside of the brackets:

trace("Put random word here &quot <- this is used to check to see if your code is working VERY USEFULL!

YourObject._rotation += 10; <- rotates object to the left
YourObject._rotation -= 10; <- rotates object to the right

YourObject._rotation += 10; <- rotates object to specific place
YourObject._rotation -= 10; <- rotates object to specific place


YourObject._width += 10; <- Expands your objects width
YourObject._height += 10; <- Expands your objects height

YourObject._alpha -= 10; <- objects transparency decreases
YourObject._alpha += 10; <- objects transparency increases

YourObject._x += 10; <- moves object to the right
YourObject._x -= 10; <- moves object to the left
YourObject._y += 10; <- moves object downward
YourObject._y -= 10; <- moves object upward

YourObject._x = 10; <- moves object to specific location left to right
YourObject._y = 10; <- moves object to specific location up and down

gotoAndPlay(2); <- goâs to frame 2 (or any frame # you put in) and plays
gotoAndStop(2); <- goâs to frame 2 (or any frame # you put in) and stops

YourObject._X = (550) * Math.random(); <- randomly places object on the x axis (needs conditional statement)
YourObject._y = (400) * Math.random(); <- randomly places object on the y axis (needs conditional statement)

EXAMPLE:

this.onEnterFrame = function()
{
char.onRelease = function()
{

YourObject._y = (400) * Math.random();
YourObject._X = (550) * Math.random();

}
}

  • 6 Replies
alsage
offline
alsage
132 posts
Nomad

sorry I accidently pressed enter so i didnt finish editing

plasmafish
offline
plasmafish
252 posts
Nomad

These are crap IMO. Basic flash programming learned from any basic flash book.

These scripts are nothing special, a lot is left for interpretation by the reader.

Louissi
offline
Louissi
66 posts
Peasant

I doubt these scripts would really help anybody since they are all out of context. I guess the best way to elarn is to follow simple tutorials and understand the whole structure of AS.

plasmafish
offline
plasmafish
252 posts
Nomad

Louissi, I wholly agree.

alsage
offline
alsage
132 posts
Nomad

I just made them to help others.. i wouldnt expect many to need them

madgoblin
offline
madgoblin
1 posts
Nomad

hey thanks for making these codes... i already know all of them but they still help :0 could you make more complex codes for a platformer game?

Showing 1-6 of 6