A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: ??? Is this possible in Swish ???

  1. #1
    Junior Member
    Join Date
    Jan 2002
    Posts
    21

    ??? Is this possible in Swish ???

    Hi,

    I am [trying] to make a little game in Swish,

    I was wondering whether it is possible to play sprites on the press of a key?

    For example, when the user presses 'g', a certain sprite is loaded.

    I know this is posible in Flash, so if it isn't at all possible in Swish, I would really appreciate any ways you could think of doing it.

    How about making something in Flash and then importing into Swish?

    I have flash, so if it's quite simple to make I can have a go, or if you can do it, even better!


    Thanks


    P.s, examples would be great

  2. #2
    Senior Member Lys12's Avatar
    Join Date
    Feb 2001
    Location
    Munich, Germany
    Posts
    5,237
    hi swash_jon,

    yes it's possible using javascript, at the meoment there are problems with NN6 though. read this thread:

    http://board.flashkit.com/board/show...hreadid=271527

  3. #3
    Junior Member
    Join Date
    Jan 2002
    Posts
    21
    Hey Lys12,


    NS 6, meaning Netscape?

    That shouldn't be a problem because i won't be putting it on the net,


    I'd love to know how to do it with javascript, if you could point me in the right direction, or even explain in a reply that would be great..




    Thanks again

  4. #4
    Senior Member Lys12's Avatar
    Join Date
    Feb 2001
    Location
    Munich, Germany
    Posts
    5,237
    have you clicked on the link i've provided above?

    however, see this password thingy which uses Jamescovers script and enter the correct password to download the necessary files (and also to view the keycodes):

    http://www.msnrd.de/password1/password1.html

  5. #5
    Junior Member
    Join Date
    Jan 2002
    Posts
    21
    Hi again, yeah I did, but didn't really understnad what the whole things' about...

    I know this is gonna sound dumb, and possibly quite annoying, but...

    What javascript do I need to include in my project, so that when the person presses, say, 'p', sprite1 in scene 1 loads?


    Sorry to be so dumb, but I've not had much experience with this kinda thing..


    thanks for sticking with me

  6. #6
    Senior Member Lys12's Avatar
    Join Date
    Feb 2001
    Location
    Munich, Germany
    Posts
    5,237
    check back in an hour or so, i'll make a sample file for you.

  7. #7
    Junior Member
    Join Date
    Jan 2002
    Posts
    21
    That would be fantastic!






  8. #8
    Senior Member Lys12's Avatar
    Join Date
    Feb 2001
    Location
    Munich, Germany
    Posts
    5,237
    ok here's everything you need. make sure to change the swfs name (Movie171 in my example) and the targets name (characters in my example) in the script!

    http://www.msnrd.de/Movie171.html

    what the script does is send the specified sprite to a certain frame, but it won't tell it to play, so you'll have to place a play action at the specific frame. since the characters only show, but there's no animation, this wasn't necessary in this example.

    i've included the keycodes as well in the zip

    have fun... and let's not forget that it was Jamescover who wrote the script!


    i forgot to mention that the script will stop working when you click inside the swf. i'd place a transparent rectangle, same size as the canvas, on top and assign a "on press -> javascript -> location.reload() " action to it.
    [Edited by Lys12 on 03-03-2002 at 04:29 PM]

  9. #9
    Junior Member
    Join Date
    Jan 2002
    Posts
    21
    Thats execellent,

    but when I opened the Swi file, I coudn't see the script anywhere, are you sure it's included in the swi?







    So if I wanted to, say, simply go to a sprte and play it, when the the letter G is pressed, I'd put this script

    }
    }
    else if (document.all) {
    if (event.keyCode==120) {
    document.Movie171.TGotoFrame('/characters',24);
    }
    }
    if (document.layers) {
    document.captureEvents(Event.KEYPRESS);
    if (e.which==71) {
    document.mygame.TGotoFrame('/game',1);

    umm then.....sorry I'm lost on what to do.


    Could you maybe do another example so when the G is pressed asprite loads??

    If you can that would be great, if not no worries..

    Thanks



  10. #10
    Senior Member Lys12's Avatar
    Join Date
    Feb 2001
    Location
    Munich, Germany
    Posts
    5,237
    well no... the script is in the html. you can put it inside the textfield of the javascript action of swish, but then this code will only work in IE5.5 for some reason.

    in my example every key pressed sends the characters sprite to a specific frame. sure you can play a sprite instead. instead of a placing a character at a certain frame, you can as well place a sprite.

    make sure that you have correct pairs:

    }
    if (document.layers) {
    document.captureEvents(Event.KEYPRESS);
    if (e.which==103) {
    document.mygame.TGotoFrame('/game',1);
    }
    }
    else if (document.all) {
    if (event.keyCode==103) {
    document.Movie171.TGotoFrame('/game',1);
    }


    in this case you'll have a sprite named "game". put a stop action at frame 0 and a play action at frame1. pressing the g will send it to frame 1 and it'll play.

  11. #11
    Junior Member
    Join Date
    Jan 2002
    Posts
    21
    Hey again,

    I understand what you mean now, but I still can't get it to work

    here's the swi,

    http://www.geocities.com/theultimateboss/mygame.zip

    the sprite is of an animation of a punch bag being hit.


    could you try and make it so when 'L' is pressed, the sprite plays and the whole process begins again, so you could press 'L' loads of times in theory and it would keep playing, like multiple hits I guess..


    thanks for helping me out, i'm really a thankful.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center