SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ship fire event not working right..

    Hi,
    I got a spaceship to fire in my flash but however, two shots can't be on the screen at once for some odd reason. Here's the swf:

    http://www.flashninjaclan.com/spaceship.swf

    and the source

    http://www.flashninjaclan.com/spaceship.fla


    I followed this flashkit tutorial:

    http://www.flashkit.com/tutorials/Ga...-598/index.php

    It was pretty successfull except for the fire. In this, if you hold own ctrl, you get a stream of fire. In mine if you hold down ENTER(I changed the key) the shot stays in place. Anyone know why?

  2. #2
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Fixed it.
    The swf & the fla have been zipped & the zip file has been attached to this post.

    I changed the missile to line from circle though. You can change it back, it'll work fine & I've commented your code, so both your code & mine code is present.

    Nice tut by the way. Thanks for the link.
    Attached Files Attached Files
    Last edited by asp_funda; Jan 29, 2004 at 14:48.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  3. #3
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks A bunch!

  4. #4
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    My Pleasure
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  5. #5
    SitePoint Enthusiast dooch's Avatar
    Join Date
    Nov 2003
    Location
    London UK
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nice ship

  6. #6
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I don't want to travel in one of those for sure.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  7. #7
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I gots another problem with the fire now. I want to limit the number of times you can fire in a row. Right now I have this code:

    Code:
    if (Key.isDown(Key.SPACE)){
       laserCounter++;
       _root.laser.duplicateMovieClip( "laser"+laserCounter, laserCounter );
       _root["laser"+laserCounter]._visible=true;
    	playsound = new Sound(this);
     playsound.attachSound("laser");
     playsound.start(0, 1);
     m--;
    
     }
    I tried this:

    Code:
    if (Key.isDown(Key.SPACE)){
    m=1;
    while(m<5){
       laserCounter++;
       _root.laser.duplicateMovieClip( "laser"+laserCounter, laserCounter );
       _root["laser"+laserCounter]._visible=true;
    	playsound = new Sound(this);
     playsound.attachSound("laser");
     playsound.start(0, 1);
     m--;
    }
     }
    But that just jams up my computer, what am I doing wrong. I thought my change would limit it to 5 shots at a time.

  8. #8
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    What you are doing here is putting the fire in a loop. So, even if the code works right(which I doubt), it'll fire 5 shots for every press of the SPACE key.

    I suggest that you place a dynamic textfield at the root. Update its value with each fire. Now before initiating fire, check its value. If it equals 5, don't fire. Also, set an Interval of 2 seconds to set the textfield to 0 so that its usable next time user decides to fire.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  9. #9
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Taken the SWF & FLA file off & attached to the post instead of links.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  10. #10
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, after messing around for a few more hours I got it figured out:
    [code]
    if (Key.isDown(Key.SPACE)){


    laserCounter++;
    if(lasercounter%4==0)
    {
    _root.laser.duplicateMovieClip( "laser"+laserCounter, laserCounter );
    _root["laser"+laserCounter]._visible=true;
    playsound = new Sound(this);
    playsound.attachSound("laser");
    playsound.start(0, 1);

    }
    }

    It creates a bit of time between shots.

  11. #11
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The script is giving errors!!
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  12. #12
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Really, It doesn't cause errors on my machine, I haven't uploaded my stuff to the server yet and my server has had alot of load today for some reaosn.

  13. #13
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    umm, maybe b'coz the script you posted above is not same as that you have in the flash file. Can be b'coz you left half or some part of the total script above while you thought you were pasting whole of it.

    Care to check back what you've pasted & what you've got working? I'd say that why not copy & paste it again? And in the {code} block please.

    I thought that mentors were well behaved?
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  14. #14
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I did cut and paste, that is the code I have in my flash file. Thats strange..

  15. #15
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    That's sure strange.

    Maybe I didn't copy & paste it right. I'll try & tell ya.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •