Jump to content

Need Helpt With Actionscript 3.0


omgnoseat

Recommended Posts

Well, I got a school assignment where I need to program an animation in adobe flash cs3 where the user has influence on what happends, so something like a little game.

The problem is that I never have programmed in my life, and I don´t have the time to study it now...

So some help would be gratefull.

Someone I my class helped me to create a ball which you can controll by the keyboard, but that isn´t going to do for the assignment.

I would like the ball to be clickable, and then change into a square which will move faster.

This is my current code:

package    {
    import flash.display.Sprite;
    import flash.events.Event
    import flash.events.KeyboardEvent;
    import flash.ui.Keyboard;

    public class Test extends Sprite {
        var Ball:Sprite = new Sprite();
        var speed:int = 5;
        
        
        public function Test() {
            init();
        }

        private function init():void {
        
        
            stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyboardEvent);
            
            
                
            
            Ball.graphics.beginFill(0XFF0909);
            Ball.graphics.drawRoundRect(50,50,60,60,60);
            Ball.graphics.endFill();
            stage.addChild(Ball);
            
        }
        
         private function handleKeyboardEvent(event:KeyboardEvent):void {
            switch(event.keyCode) {
                case Keyboard.UP :
                    Ball.y -= speed;
                    break;
                case Keyboard.DOWN :
                    Ball.y += speed;
                    break;
                case Keyboard.LEFT :
                    Ball.x -= speed;
                    break;
                case Keyboard.RIGHT :
                    Ball.x += speed;
                    break;

            }
         }
             
    }
}

I'm using 2 files:

Deelopdracht1.fla

Test.as

I'm using the document class in the .fla file to link them.

Some help will be greatly apreaciated, it's quite important :(

Link to comment
Share on other sites

Does it HAVE to be programed in actionscript 3 because i have only just started touching on it as its pretty new i know theres not a lot different part from its in its own separate file.

But i have some actionscript 2 stuff thats user interactive but wouldnt just give you it as its meant to be your work.

But could point you in the right direction

Link to comment
Share on other sites

Does it HAVE to be programed in actionscript 3 because i have only just started touching on it as its pretty new i know theres not a lot different part from its in its own separate file.

But i have some actionscript 2 stuff thats user interactive but wouldnt just give you it as its meant to be your work.

But could point you in the right direction

It has to be in actionscript 3

I'm all stressed out, if I don't make this thing I have to do a harder test which is basicly impossible

hurray

Link to comment
Share on other sites

  • 11 months later...

Have a chance to retry my assignment from last year, which I failed. Have to use actionscript 3 once again, I do get the hang of it alot more now though.

We can only use actionscript for everything, nothing on the stage whatsoever. We have to use a document clas in the .fla file to connect to the .as file, so we get a OOP type of programming.

I´ve made a little ghost from some sprites, which was hard enough for me but it did work out. Now I´m having some problems connecting events to it. I want it to me able to be controlleable with the mouse, and on a mouse click it should dissapear [change decrease the alpha on mouse click]. I thought I figured it out but i'm just getting errors =/

Edit:

Worked it out together with my gf :P:D

Edited by omgnoseat
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...