This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-01-12 13:55:28

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Can anyone help with Actionscript 3.0?

I'm trying to make this game in Adobe Flash CS5.5, but I'm running into problems when I try to add a shooting feature.  Can anyone help?  The file just freezes when I press space, and then a little later starts behaving normally, except there's never any laser/bullet thing.  I don't get any output or compiler errors.  Also, is there a version of that kongregate.com/labs tutorial for AS3?  Thanks in advance!

Code:

import flash.events.KeyboardEvent;
import flash.ui.Keyboard;

stage.addEventListener(KeyboardEvent.KEY_DOWN, fire);

function fire(evt:KeyboardEvent):void
{
    if (evt.keyCode == Keyboard.SPACE)
    {
        var laser:bullet = new bullet;
        stage.addChild(laser);
        laser.x = player.x + player.width / 2;
        laser.y = player.y;
        while (laser.y > 0)
        {
            laser.y += 5;
        }
        stage.removeChild(laser);
    }
}

Offline

 

#2 2012-01-12 14:14:38

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Can anyone help with Actionscript 3.0?

Wow.  100+ views and not a reply.

Last edited by maxskywalker (2012-01-12 14:14:51)

Offline

 

#3 2012-01-12 17:35:34

GameHutSoftware
Scratcher
Registered: 2010-04-24
Posts: 1000+

Re: Can anyone help with Actionscript 3.0?

you need to put it in a package and all that stuff
wow a lot of flash topics recently


Lurking more than posting, but still here.

Offline

 

#4 2012-01-12 18:09:27

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Can anyone help with Actionscript 3.0?

GameHutSoftware wrote:

you need to put it in a package and all that stuff
wow a lot of flash topics recently

Source code please?

Offline

 

#5 2012-01-12 19:53:25

GameHutSoftware
Scratcher
Registered: 2010-04-24
Posts: 1000+

Re: Can anyone help with Actionscript 3.0?

well
you have to start it with this:

Code:

package 
{

all code has to be in a package


Lurking more than posting, but still here.

Offline

 

Board footer