PDA

View Full Version : Missing The Boat


ganalon
06-16-2005, 09:56 PM
I think I may be missing the boat when it comes to OOP and listeners and objects.

I want to be able under certain circumstances to drag the parent clip around but at other times I want to be able to drag its children.

As soon as I set the listener for the parent I can never remove it to go back to move the child around. I have a brain cloud.

source: http://www.herlihyracing.com/drag.fla
####### code

swapmodes();
function changemodes() {
if (mymode) {
mymode = false;
swapmodes();
} else {
mymode = true;
swapmodes();
}
}
function swapmodes() {
if (mymode) {
titanic.onPress = function() {
startDrag(this);
};
titanic.onRelease = function() {
stopDrag();
};
} else {
titanic.onPress.close()
titanic.kate.onPress = function() {
startDrag(this);
};
titanic.kate.onRelease = function() {
stopDrag();
};
}
}

deadbeat
06-16-2005, 10:00 PM
I don't know what this line is supposed to do, it makes no sense:

titanic.onPress.close()

but you should try replacing it with

delete titanic.onPress;

K.

senocular
06-16-2005, 10:17 PM
on a side note, be sure to use both onRelease and onReleaseOutside for stopDrag()

ganalon
06-16-2005, 11:31 PM
titanic.onPress.close() was junk i left in there but I did need this.

delete titanic.onPress;

Turns out delete.onPress works kinda but I can never reinitialize the onPress for the child.

deadbeat
06-16-2005, 11:43 PM
Try this:

var myMode:Boolean=false;

function toggleMode(){
myMode=!myMode;
swapMode();
}

function swapMode(){
if(myMode){

titanic.onPress = function() {
startDrag(this);
}

titanic.onRelease = function() {
stopDrag();
}

}
else{
delete titanic.onPress;
delete titanic.onRelease;
}
}

titanic.kate.onPress = function() {
startDrag(this);
}

titanic.kate.onRelease = function() {
stopDrag();
}


See attached example file (click green button to switch modes)...

K.

The_Sue
06-16-2005, 11:50 PM
If the parent is deleted, then its behaviour /functions/ actions will be lost too - I assume, by child, you are duplicating a movie clip

you can try using "myMovieClip.._visible=boolean" which would make it vanish yet the associated script would still be available. Also you can shorthand the boolean swap with;

myBoolean = myBoolean? false: true; ...just a thought

ganalon
06-17-2005, 04:16 AM
Yes the delete onRelease was the answer.

thanks deadbeat for the sample.