A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Simple Drag & Drop question! help!

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    2

    Exclamation Simple Drag & Drop question! help!

    actionscript 2

    Hey everyone. I have a movie clip that I am dragging onto another movie clip and i want it to stay put. But once I add in another 'OR' statement in the if statement, it freaks out and doesn't work. Why is this?

    This code works:
    Code:
    btn1.onRelease=function(){
    	stopDrag();
    	if(eval(this._droptarget) != btn1Hold) {
    		this._x=this.startX;
    		this._y=this.startY;
         }
    	 else{
    		//CODE
    	 }
    	 
    }

    This code DOES NOT work:
    Code:
    btn1.onRelease=function(){
    	stopDrag();
    	if( (eval(this._droptarget) != btn1Hold) || (eval(this._droptarget) != btn2Hold) ) {//CHANGED LINE
    		this._x=this.startX;
    		this._y=this.startY;
         }
    	 else{
    		//CODE
    	 }
    	 
    }
    For whatever reason it doesn't like the extra 'OR' in the if statement! why!?

    Thanks in advance!

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    try using an 'AND' instead of an 'OR'
    Code:
    btn1.onRelease = function() {
    	stopDrag();
    	if ((eval(this._droptarget) != btn1Hold) && (eval(this._droptarget) != btn2Hold)) {
    		this._x = this.startX;
    		this._y = this.startY;
    	} else {
    		//CODE
    	}
    };

  3. #3
    Senior Member
    Join Date
    Dec 2009
    Posts
    109
    what do you mean by it freaks out?
    Syntax Error

  4. #4
    Junior Member
    Join Date
    Feb 2010
    Posts
    2
    I can't use 'AND' because i want to drag 'btn1' to either 'btn1Hold' or 'btn2Hold'. When i only give it an action when btn1Hold is being contacted, it does the code i want it to do. When i put in the 'OR' statement for either one of my landing places for my draggable movie clip, it doesn't work with either of 'btn1Hold' or 'btn2Hold'.

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