A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Button Help

  1. #1
    Junior Member
    Join Date
    Feb 2009
    Posts
    2

    Question Button Help

    Hey everyone!

    As you may have already guessed, I'm a complete n00b when it comes to flash.
    I started working on this project some time ago, a "game" (kind of), and now I really need some help. Here's a pic.



    OK, so the thing is, I want the red arrow, to go to the next scene when I click it (so that it seems like you move forward in the game), how do I do that?

    I really hope you guys can help me, thanks

  2. #2
    Junior Member
    Join Date
    Feb 2009
    Posts
    2
    Please, anyone? (:

  3. #3
    Junior Member
    Join Date
    Mar 2009
    Posts
    3
    Hmm.. I'm actually also a n00b, so I probably won't be able to help much, haha but maybe I could try a little bit... Although, maybe it would be better if I didn't since I could confuse with my noobness xD But oh well~

    I'm making a mini game and I have two arrows on top, one takes you to the right and the other to the left, so what I did was that I made the background 200x200 and the "map" i made it 1000x200, so there are 5 stages, but they are all on the same frame.

    Then this was my code on the main layer:

    stop();

    var vx:Number = 0;
    var vy:Number = 0;
    var mainSpeed: Number = 200;

    function leftmove(e:MouseEvent):void
    { if(fondo.x<400)
    fondo.x += mainSpeed;

    }

    function rightmove(e:MouseEvent):void
    { if(fondo.x>-200)
    fondo.x -= mainSpeed;


    }
    left.addEventListener(MouseEvent.CLICK, leftmove);
    right.addEventListener(MouseEvent.CLICK, rightmove);


    In the 1000x200 background it would show only 200x200 on each click, and you wouldn't be able to keep clicking the arrow when the en was reached...

    You can also make the background for each level, make each one an object, make the arrow, and on the main timeline add each of the backgrounds on each frame, add the arrow and make it last for all the time and do something like:
    stop();
    function moveup(e:MouseEvent):void
    {
    gotoAndStop(2);
    }
    button.addEventListener(MouseEvent.CLICK, moveup);

    and then just change the gotoAndStop(2); to 3, 4, 5 etc... Or maybe you can add a variable that after each click is added... like
    var nextlvl: Number = 1;

    and then where the gotoAndStop(2); was it would be like
    gotoAndStop(nextlvl);
    nextlvl=nextlvl+1;



    Hmm... I just started using flash so this is probably a really noobish way to do it, but it could give you some ideas

  4. #4
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    What version of Flash are you building your game in? It is important to provide sample code.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

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