Actionscript 2, StopDrag, add item ++

  • neildavey
  • Born
  • Born
  • neildavey
  • Posts: 1
  • Loc: Belfast, Northern Ireland

Post 3+ Months Ago

Need a helping hand with this please. I have a drag and drop game where you click on an item in a scrolling pane. A instance of that item is attached from the library to mouse and you drag the item to one dropZone. Above the dropZone are 4 brownCircle's. What I am trying to do is everytime you drop an item in the dropZone, that item is then added to a brownCircle until you fill all 4 of the brown circles.

Here is my code so far, everything works apart from the items added to the brownCircles:

Code: [ Select ]
var itemList:Array = []

var curr_item;
for (var i = 1; i <= 20; i++)
{
  curr_item = itemLine["item" + i];
  curr_item.num = i;
  curr_item.onPress = function(){
    attachMovie("item" + this.num, "newItem", this._parent.getNextHighestDepth());
    newItem._x = _xmouse;
    newItem._y = _ymouse;
    newItem.startDrag();
  }
    curr_item.onRelease = function(){
        newItem.stopDrag();
        unloadMovie(newItem);
    }
     curr_item.onReleaseOutside = function(){
        newItem.stopDrag();
        unloadMovie(newItem);
        if (newItem._droptarget == "/dropZone") {
            newItem._x = _root.dropZone._x;
            newItem._y = _root.dropZone._y;
            newItem.stopDrag();
            //trace(this.num);
            itemList.push(this.num);
            trace(itemList);
            for (var i = 1; i <= 4; i++){
            addNewItem = "brownCircle" + i;
            addNewItem.attachMovie("item" +this.num, "newItem",this._parent.getNextHighestDepth());
}
        }else{
            unloadMovie(newItem);
            }
  }
}
  1. var itemList:Array = []
  2. var curr_item;
  3. for (var i = 1; i <= 20; i++)
  4. {
  5.   curr_item = itemLine["item" + i];
  6.   curr_item.num = i;
  7.   curr_item.onPress = function(){
  8.     attachMovie("item" + this.num, "newItem", this._parent.getNextHighestDepth());
  9.     newItem._x = _xmouse;
  10.     newItem._y = _ymouse;
  11.     newItem.startDrag();
  12.   }
  13.     curr_item.onRelease = function(){
  14.         newItem.stopDrag();
  15.         unloadMovie(newItem);
  16.     }
  17.      curr_item.onReleaseOutside = function(){
  18.         newItem.stopDrag();
  19.         unloadMovie(newItem);
  20.         if (newItem._droptarget == "/dropZone") {
  21.             newItem._x = _root.dropZone._x;
  22.             newItem._y = _root.dropZone._y;
  23.             newItem.stopDrag();
  24.             //trace(this.num);
  25.             itemList.push(this.num);
  26.             trace(itemList);
  27.             for (var i = 1; i <= 4; i++){
  28.             addNewItem = "brownCircle" + i;
  29.             addNewItem.attachMovie("item" +this.num, "newItem",this._parent.getNextHighestDepth());
  30. }
  31.         }else{
  32.             unloadMovie(newItem);
  33.             }
  34.   }
  35. }


Would really appreciate any help with this as its doing my head in, Cheers
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • zhaojany
  • Student
  • Student
  • User avatar
  • Posts: 79

Post 3+ Months Ago

I'm not sure about what u want. And after u drop the item on to the dropZone then u want it to dispear?

And why do u use the same instance name "newItem" ? It will be confusing.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 16 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.