Deviant Login Shop  Join deviantART for FREE Take the Tour


Submitted on
October 8, 2008
Image Size
983 bytes


3 (who?)


Creative Commons License
Some rights reserved. This work is licensed under a
Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 License.
just as it says im tripping ball... well not really
this si just a tets of what i have learned so far in acionscript 3 from a book i got last week (foundation actionscript 3.0 with flash cs3 andc Flex).
just click on the stage and watch the balls bounce everywere! haha enjoy :D
Add a Comment:
homestar455 Oct 8, 2008   Photographer
Good job! Keep up the good work, there's always room for more flash devs on the web.
saiyan-chan Oct 9, 2008  Hobbyist General Artist
thank you :D i'm only just learning the basics in action script 3 right now university so i know theres loads more to learn :D
homestar455 Oct 9, 2008   Photographer
One thing I might suggest (I've learned this from programming my own game) is in your if statements for collision with the walls, floor, and roof, you reset the ball's location back to the wall/whatever. As an example, here's some modified source code from my game for when a ball hit's the floor.

if (this._y > 400) {
this.ySpeed = -Math.abs(this.ySpeed);
[b]//The Math.abs makes sure the speed is directed upwards.[/b]
this._y = 400;

Notice how I reset the _y back to 400, and made sure the ySpeed was directed upwards? That prevents the ball from getting stuck in the floor, and vibrating in a constantly changing velocity that never lets it get anywhere.

Anyways, really good for a first attempt... I wish I had a book like that when I started actionscripting.
saiyan-chan Oct 13, 2008  Hobbyist General Artist
thanks i tryed it out but there was no difference (from what i could see), plus i didnt have any if statements to begin with ^^;
heres the complete coding of the flash file.
package {

import flash.display.MovieClip;

public class MultiBounce extends MovieClip {

//Number of balls to create
private static const NUM_BALLS:uint = 50;

public function MultiBounce(){
stage.addEventListener(MouseEvent.MOUSE_DOWN, onStageClick);
//Handler for when stage is clicked, creates balls
private function onStageClick (pEvent:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_DOWN, onStageClick);
// For each Ball to be created
for (var i:uint = 0; i < NUM_BALLS; i++){
//Create new Ball instance
var ball:Ball = new Ball();

//Places ball at mouse click
ball.x = pEvent.stageX;
ball.y = pEvent.stageY;

//Specify random speed and direction
ball.speedX = (Math.random() * 30) -15;
ball.speedY = (Math.random() * 30) -15;

//Add new Ball to stage
^^; as i said i learnt this from a book i recently baught so i just copied it from there....
homestar455 Oct 13, 2008   Photographer
Weird, I only see code in there to create the 50 balls and assign them random .speedX and .speedY ... But I'm new to actionscript, and I don't do anything past AS2.0 (I mainly make flash for wii)

Well good luck with your book, I'm sure if you stick at it you'll be able to make some pretty cool games.
saiyan-chan Oct 14, 2008  Hobbyist General Artist
wow you make flash for the wii thats awesome :D
homestar455 Oct 14, 2008   Photographer
Yep, that game I showed you can be played on wii. It's actually no harder than developing flash for standard computers, it just has to be flash 7 or lower.
hun i have to admit this the 3rd time ive played with this !

kudos on the awesomness!
saiyan-chan Oct 9, 2008  Hobbyist General Artist
haha thanks hun ^^ i'll try and get some more things up soon then ^^ :D
woah the wonders of SCIENCE!!

nice one hun!
Add a Comment: