A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: HELP droptarget=="/shadow1")

Hybrid View

  1. #1

    HELP droptarget=="/shadow1")

    <b>Hi i am making a small Que card game for 3 to 7 year olds to play i have managed to get most of it to work by uesing the following code...
    -----------------------------------------------
    Card1-----</b>

    on (press) {
    startDrag(this);
    this.swapDepths(100);
    }
    on (release) {
    stopDrag();
    if (this._droptarget=="/shadow1") {
    setProperty(this, _x, 124);
    setProperty(this, _y, 154);
    } else {
    setProperty(this, _x, 600);
    setProperty(this, _y, 154);
    }
    }
    <b>-----------------------------------------------
    Card2-----</b>

    on (press) {
    startDrag(this);
    this.swapDepths(100);
    }
    on (release) {
    stopDrag();
    if (this._droptarget=="/shadow2") {
    setProperty(this, _x, 272);
    setProperty(this, _y, 154);
    } else {
    setProperty(this, _x, 600);
    setProperty(this, _y, 300);
    }
    }
    <b>-----------------------------------------------
    Card3-----</b>

    on (press) {
    startDrag(this);
    this.swapDepths(100);
    }
    on (release) {
    stopDrag();
    if (this._droptarget=="/shadow3") {
    setProperty(this, _x, 422);
    setProperty(this, _y, 154);
    } else {
    setProperty(this, _x, 600);
    setProperty(this, _y, 450);
    }
    }
    <b>-----------------------------------------------
    And so on for 6 cards.

    I wont to beable to trigger an event when all 6 cards are in there corect place's for example (goto frame 2 and stop) or (get url"game2.html)

    can any one help????</b>

  2. #2
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    First of all try and paste your code in using [ as ]...[ /as ] tags (without spaces).

    What you need is a flag for each of your cards to tell you whether it's in the right place or not and then call a function to check if every card is placed correctly. So do something like this for each card

    code:

    //Card 1
    on (press) {
    startDrag(this);
    this.swapDepths(100);
    }
    on (release) {
    stopDrag();
    if (this._droptarget=="/shadow1") {
    this._x = 124;
    this._y = 154;
    _root.check1 = true;
    } else {
    this._x = 600;
    this._y = 154;
    _root.check1 = false;
    }
    _root.checkcards();
    }


    Then this is your check function on the _root
    code:

    function checkcards() {
    var numCards = 6;
    var i = 1;
    var onewrong = false; //assume all
    while(i <= numCards && !onewrong) { //go through each card check flag
    if(!_root["check" + i]) { //if this flag is false
    onewrong = true; //this card is not placed so abandon loop
    }else{
    i++; //card is in place, move onto next card
    }
    }
    if(!onewrong) { //if onewrong is still false, all must be correct
    gotoAndStop(2); //They've done it!
    }
    }


  3. #3
    Thanks that has dun the job the only problem is the last card that is placed remaines visable on frame 2 any idears???

    I have alredy incromented _root.check1 = statment....

  4. #4
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    That's because you are using setInterval. A quick workaround would be
    code:

    if(!onewrong) {
    for(var i=1; i<=numCards; i++) {
    this["card" + i]._visible = false;
    }
    gotoAndStop(2);
    }

    Assuming all your cards are named card1, card2, card3 etc
    Last edited by chi-styler; 11-02-2004 at 03:52 PM.

  5. #5
    Rock and Role you roule thanks loadsss....


    Can you recomen a good flash book?

  6. #6
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    Well, there's nothing I've needed that I haven't been able to find in the Help docs, Flashkit or Macromedia site. There's plenty of other good sites to help you out too, such as kirupa.com. If you feel the need to spend money though I'd recommend ActionScript for Flash MX: Definitive Guide by Colin Moock. There's a list of other books here:
    http://www.krazydad.com/bestiary/books.html

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