dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: A little help with hittest, or something.

  1. #1
    Member ghost_flash's Avatar
    Join Date
    Apr 2003
    Location
    United States
    Posts
    98

    A little help with hittest, or something.

    I'm not an actionscriptor in the least, and I have been asked to create a simulation where ojbects will be doing the following:

    - Hanging from a rail and moving horizontally
    - There is a need for them to be selectable so that when they are selected individually, they will drop.

    I'd like to have them move like they are hanging from a sort of conveyor, with the momentum showing as they glide horizontally, and then when selected just drop. (Just the selected item) and then have the others continue to scroll from left to right...

    I'd also like to keep track of the items as they are selected. Some are supposed to be selected and some are not, so the bad items count as correct, and the items that are ok but wrongly selected should count against the score to be tallied at the end of the simulation.

    It's a quality control simulation.

    Can anyone help me along with a basic demonstration of the actionscript involved in this?

    Thanks.

  2. #2
    Member ghost_flash's Avatar
    Join Date
    Apr 2003
    Location
    United States
    Posts
    98
    ::bump::

    Come on people, I know there are at least a handful of you gurus out there that can not only program this in your sleep, you can explain it so that even I can understand how to do it.



    Can I offer a prize for a sample simulation fla? with explanation of the code, or is that bad and put me on the naughty list?

  3. #3
    Spirit Breakers Clan Lead
    Join Date
    Dec 2004
    Location
    Rockland (Canada)
    Posts
    68
    I don't know how to do the score board but I know how to do the moving belt.
    Here is my idea...
    First! Animate the belt.
    Second! Create an object as a MovieClip!
    Go into edit MovieClip. Create an object as a Button inside the movieclip. Go back to the stage view. Name the movielcip that has a button object inside, name it ''Target''.
    Put this script on the mc. (It may not be the exact ressemblence to a real script code, just pay attention if their are any errors)

    onClipEvent (enterFrame) {
    this._x = _x+20;
    or you could just animate it!

    ........ Ah crap dinner is finished later try what I said!
    Hi, my name is Nakrem, Ishiru or Nakremy
    I have a Clan Forum on USWEST D2LOD NON-LADDER.
    My website is s13.invisionfree.com/Clan_spirit_breakers

    contact me in USwest realm, my account name is Ishiru, my best character is Unreal-NakremSB.
    If you want to join my clan. Register to my forums and I might validate you after questions.

  4. #4
    Senior Member kendude's Avatar
    Join Date
    Sep 2003
    Location
    Hartford, CT USA
    Posts
    877
    code:
    items = [true, false, false, true, true, false, true];
    v = 0;
    attachMovie("hand","hand",111);
    this.hand._x = _xmouse;
    this.hand._y = _ymouse;
    lastTime = getTimer()/1000;
    onEnterFrame = function () {
    this.hand._x = _xmouse;
    this.hand._y = _ymouse;

    curTime = getTimer()/1000;
    if (curTime>lastTime+3) {
    addItem();
    lastTime = getTimer()/1000;
    }
    };
    addItem = function () {
    this.attachMovie("item", "item"+v, 100+v);
    this["item"+v]._x = 50;//can be whatever
    this["item"+v]._y = 300;//can be whatever
    v++;
    if (v>10) {
    v = 0;
    }
    };
    onMouseDown = function () {
    for (var i = 0; i<=10; i++) {
    if (this["item"+v].hitTest(this.hand)) {
    // check if item is true or false in array, then do whatever...
    // gotta go to lunch but that is the idea
    }
    }
    };


    This will get you started but you should really learn AS, especially if you are doing paying work. Also, don't bump your post as you just did. You also have to move the items across the screen, gotta go...

  5. #5
    Senior Member kendude's Avatar
    Join Date
    Sep 2003
    Location
    Hartford, CT USA
    Posts
    877
    code:
    items = [true, false, false, true, true, false, true];
    v = 0;
    attachMovie("hand", "hand", 111);
    this.hand._x = _xmouse;
    this.hand._y = _ymouse;
    lastTime = getTimer()/1000;
    onEnterFrame = function () {
    this.hand._x = _xmouse;
    this.hand._y = _ymouse;
    for (var i = 0; i<=10; i++) {
    this["item"+i]._x -= 2;
    if (this["item"+i]._x<=0) {
    this["item"+i].removeMovieClip();
    }
    }
    curTime = getTimer()/1000;
    if (curTime>lastTime+3) {
    addItem();
    lastTime = getTimer()/1000;
    }
    };
    addItem = function () {
    this.attachMovie("item", "item"+v, 100+v);
    this["item"+v]._x = 50;
    // can be whatever
    this["item"+v]._y = 300;
    // can be whatever
    v++;
    if (v>10) {
    v = 0;
    }
    };
    onMouseDown = function () {
    for (var i = 0; i<=10; i++) {
    if (this["item"+v].hitTest(this.hand)) {
    // check if item is true or false in array, then do whatever...
    // gotta go to lunch but that is the idea
    }
    }
    };


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