dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Drag selection, and click anywhere tutorial

Hybrid View

  1. #1
    Senior Member
    Join Date
    Aug 2007
    Posts
    228

    Drag selection, and click anywhere tutorial

    I know someone here HAS got to know THIS one.

    Ive seen it before and now i cant find it, why does that always happen to me?

    Tutorial that tells you how to click anywhere on the screen,
    and or tutorial that tells you how to click drag, and make a square to select multiple units for strategy type game and what not.

  2. #2
    Senior Member Pazil's Avatar
    Join Date
    Sep 2006
    Location
    Ontario, Canada
    Posts
    913
    Come on! Figure it out, you must know some basic math!
    WIP-ZOMBIES

    I love vegetarians! More meat for the rest of us!

  3. #3
    Senior Member
    Join Date
    Aug 2007
    Posts
    228
    what does that have to do with anything?

    nevermind i suppose i will try to google it again

  4. #4
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766
    its quite simple actually! get the point where mouse is clicked, and where mouse is released. Then use a for loop to go through your instances and check if they are within the area!

    By the way, are you using as2 or as3?
    If you like me, add me to your friends list .

    PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!

    My Arcade My Blog

    Add me on twitter:

  5. #5
    Senior Member
    Join Date
    Aug 2007
    Posts
    228
    as2

  6. #6
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,379
    Seriously congruent, you've got to start meeting us 1/2 way on these topics. Seems like your trying less because we're available to answer questions on this forum. On to your question...

    You can basically do this by activating a start/stop drag scenario and keeping track of those start/end points on the screen. Once the user has released the mouse to complete the square, cycle through your units and check if they are inside the square.

    Code:
    dragging = false;
    checkit = false;
    startPt = {};
    endPt = {};
    
    onMouseDown = function() {
         dragging = true;
         startPt.x = _xmouse;
         startPt.y = _ymouse;
    }
    
    onMouseUp = function() {
         dragging = false;
         checkit = true;
         endPt.x = _xmouse;
         endPt.y = _ymouse;
    }
    
    onEnterFrame = function() {
         if (!dragging and checkit) {
              // cycle through objects and see if they are between startPt and endPt
              checkit = false;
         }
    }
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  7. #7
    Senior Member
    Join Date
    Aug 2007
    Posts
    228
    Thanks.

    i TOLD you i would google it, noone forced you to help me,
    and how am i suppose to meet halfway on something i dont know how to do?

  8. #8
    Now tell me whos watchin...... samvillian's Avatar
    Join Date
    Feb 2007
    Location
    Where do you live?
    Posts
    539
    By trying to figure it out.... wow... you are basically telling IP that he wasted his time in trying to help out a friend (relatively speaking).


    I would advise you to scan through the code, and code it yourself, and check whether you implemented all the steps right. Shouldn't be hard since its basic code. idk.



    so ya to sum up, don't make people feel bad for helping you... lol..



    meet halfway by saying I got this far, i just need to know how to check blah blah blah.



    @IP, those cig's are getting expensive i see lol. march 15th, very nice. I've never smoked in my life (except hookah) lol.

    nicotine... mmmmmmm nicotine.... lol.. fight the urge... nicotine...
    __________________
    If the only tool you have is a hammer, you tend to see every problem as a nail.
    Last edited by samvillian; 05-06-2009 at 02:58 AM.
    If the only tool you have is a hammer, you tend to see every problem as a nail.

    Xbox 360 Modding Controller PS3 Mod Paint Spray LED Case

  9. #9
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,928
    congruent2006, have a read of the Read Me guide sticky.

    You're asking loads of questions, which is cool 'cause that's what this board is about, but as has been said, you've got to bring something to the party.
    Maybe you're getting a bit more backlash 'cause there's quite a few posts recently with people just asking for something without showing any of their own progress / ideas.

    Even so, if you show people you're willing to try and code things yourself ( As opposed to "i TOLD you i would google it" which is a pretty piss poor attitude ) then you'll get a lot more help back.

    All that happens after a while is that your threads either get flamed or then ignored. No one wants that, so like I said have a read of that guide and post with at least showing something, some thought behind it.

    Squize.

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