Report
Save
Cancel
offline
alsage
132 posts
Nomad
Posted February 1, '10 3:37am UTC
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 " <- 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(); } }