dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Quick question

  1. #1
    Junior Member
    Join Date
    Sep 2008
    Posts
    18

    Quick question

    Hi everyone,

    I have q question regarding an idea. I have a card game that had a drag and drop feature. Now I have to get rid of this feature and have the app perform a click and go. Sort of like

    When I click a card and then click the target, the card goes to the target. Can someone give me some suggestions on how to code this. Thank you in advance

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Run a search for TweenLite or Tweener...either of those can give you what you need.

  3. #3
    Junior Member
    Join Date
    Sep 2008
    Posts
    18
    Thanks for the response. I have 15 cards that when clicked have to go to 15 different targets. In my script I have added Mouse event listeners to both the cards and the target. So how do I do this with incorporating each position of the card. If possible could you give me an example

    Thanks

  4. #4
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    When you click on a card make that the 'active' card, then just slide it over to the target...it could be as simple as this:

    PHP Code:
    var _currentCard:DisplayObject;

    function 
    onCardClicked(e:MouseEvent):void{
        
    _currentCard e.target;
    }

    function 
    onTargetClicked(e:MouseEvent):void{
        
    TweenLite.to(_currentCard1, {x:e.target.xy:e.target.y});

    But you probably want to hook up a custom position to each target...for that you'll need a lookup table (dictionary):

    PHP Code:
    const TARGET_POSITION:Dictionary = new Dictionary();

    TARGET_POSITION[target0] = new Point(1010);
    TARGET_POSITION[target1] = new Point(3010);
    TARGET_POSITION[target2] = new Point(5010);
    //  ...

    var _currentCard:DisplayObject;

    function 
    onCardClicked(e:MouseEvent):void{
        
    _currentCard e.target;
    }

    function 
    onTargetClicked(e:MouseEvent):void{
        var 
    destination:Point TARGET_POSITION[e.target];
        
    TweenLite.to(_currentCard1, {x:destination.xy:destination.y});


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