Copy link to clipboard
Copied
hey folks,
I'm looking at a I think a pretty basic request. This code below works, but I'd like to modify it so that if my dragged item passes over a region in the x coordinates. So if I pass the dragged item over the range of 600 - 700 then it would play the frame labelled "square", and when it passes out of that region, go back to play the frame labelled "circle". So realy I'm asking how can I modify the <=600 to instead 600 to 700, and else refer to circle.
Hope this makes sense.
if (me.x <=600){
me.gotoAndStop("Square")
} else if (me.x>= 700){
me.gotoAndStop("Circle")
}
Are you looking for something like
if( me.x >= 600 && me.x <= 700 )
me.gotoAndStop("Square")
} else {
me.gotoAndStop("Circle")
}
?
Copy link to clipboard
Copied
Are you looking for something like
if( me.x >= 600 && me.x <= 700 )
me.gotoAndStop("Square")
} else {
me.gotoAndStop("Circle")
}
?
Copy link to clipboard
Copied
your solution worked, can you look at my second question
Copy link to clipboard
Copied
I'm not really sure I follow your description, but the following will do what I was able to interpret...
if (me.x>= 700){
me.gotoAndStop("Circle")
} else if (me.x >=600){
me.gotoAndStop("Square")
}
That ignores anything below 600. If you want to have anything below 700 go to the square, then just use 'else' instead of 'else if(me.x >= 600)'
Copy link to clipboard
Copied
Hey guys, will test out the solutions provide. Here's the basis of what I'm doing...theoretically. I will have a table top with a piece of paper (the dimensions for which I want the dragged object to change. So any time my grabbed item passes over the paper, it'll change into text, and when I pass off the paper it'll return to a drop. So I'm just messing with the x values first. So I grab an object and when it passes into a region of x values of say 600 to 800 it'll change, when I venture below 600 or past 800 it'll change back into the original item. Hope this makes sense.
Copy link to clipboard
Copied
hey guys,
I have the code working 95 percent the way I want. the only issue I have is that if you drop the item in the designated area, and pick it back up again, when you cross into the region that it should turn back to the circle, both shapes stay. I've attached the fla coding if anyone can help with this! Thanks for the help! So if I start outside of the designated zone and pass through its fine, the only issue occurs if I drop it in the target zone and pick it up, re-entry into the area outside of the zone keeps both shapes.
backbutton.addEventListener(MouseEvent.CLICK, backclick);
helpbutton.addEventListener(MouseEvent.CLICK, helpclick);
answerbutton.addEventListener(MouseEvent.CLICK, answerclick);
circle.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
//import caurina.transitions.Tweener;
//import com.greensock.*;
import flash.media.Sound;
var me:Object;
function grabMe(e:MouseEvent):void{
me = e.currentTarget;
me.removeEventListener(MouseEvent.MOUSE_DOWN, grabMe);
me.startDrag();
e.target.parent.addChild(e.target)
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragMe);
stage.addEventListener(MouseEvent.MOUSE_UP, dropMe);
}
function dropMe(e:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_UP, dropMe);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, dragMe);
me.stopDrag();
me.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
}
function dragMe(e:MouseEvent):void {
e.updateAfterEvent();
if( me.x >= 368 && me.x <= 860 && me.y >= 103 && me.y <= 640 )
{
me.gotoAndStop("Square")
}
else
{
me.gotoAndStop("Circle")
}
}
function backclick(event:MouseEvent):void{
//testmenu.visible=false;
}
function helpclick(event:MouseEvent):void{
}
function answerclick(event:MouseEvent):void{
}