|
-
[RESOLVED] startDrag help
I am building a sliding image movie. It takes two photos and compares them by using "startDrag" to slide a "setMask" MC horizontally to reveal one photo under another. The idea here is to compare two photos taken 50 years apart.
Here is the AS:
myImage.setMask(myMask);
myMask.onPress = function() {
this.startDrag(false,5,this._y,490,this._y);
}
myMask.onRelease = function() {
stopDrag();
}
handle_mc.onPress = function() {
this.startDrag(false,5,this._y,515,this._y);
}
handle_mc.onRelease = function() {
stopDrag();
}
As you can see I have two MCs here one is a mask and the other is a handle of sort. They work fine separately but I would like to have the two function in unison or as one MC. The handle MC is just that a handle that appears on the left edge of the masked image. So when user drags the handle the masked image moves as well. (or vice versa)
Thanks
Adam
-
var x:Number = 1; x /= 0;
The problem is that onPress and onRelease are read as button events, and in button events "this" actually means "_parent".
Your code should actually be this:
myImage.setMask(myMask);
myMask.onPress = function() {
myMask.startDrag(false,5,myMask._y,490,myMask._y);
}
myMask.onRelease = function() {
stopDrag();
}
handle_mc.onPress = function() {
handle.startDrag(false,5,handle._y,515,handle._y);
}
handle_mc.onRelease = function() {
stopDrag();
}
That should work.
-
Thanks Zippy, your code is cleaner but accomplishes the same result as mine. The two movie clips move separately when dragged. I have attached the file and image assets which should make it more clear what I am trying to do.
Thanks for your help with this. First time i have used startDrag so I am a bit bewildered.
Thanks
Adan
Last edited by ADVaughn; 01-24-2010 at 09:18 AM.
-
var x:Number = 1; x /= 0;
Oh, of course. I forgot that you were trying to get them to move together.
I've simplified your code a bit, too.
Code:
var dragtarg:MovieClip = myMask;
myImage.setMask(myMask);
myMask.onPress = dragThis;
myMask.onRelease = dropThis;
myMask.onReleaseOutside=dropThis;
handle_mc.onPress = dragThis;
handle_mc.onRelease = dropThis;
handle_mc.onReleaseOutside=dropThis
_root.onEnterFrame = function() {
myMask._x = dragtarg._x;
handle_mc._x = dragtarg._x;
}
function dragThis(){
this.startDrag(false,5,this._y,515,this._y);
dragtarg=this;
}
function dropThis(){
stopDrag();
}
-
awesome Zippy thanks so much. If I can help you with anything don't hesitate to ask
Adan
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|