Skip to main content
Inspiring
June 4, 2006
Question

Can anyone explain the difference between these 2 versions?

  • June 4, 2006
  • 2 replies
  • 249 views
I don't understand why Version 2 works and Version 1 does not. Both are on the main timeline, however Version 2 nests one clip inside the other. They both display correctly, however mouse-dragging only works on the Version 2. The events don't get fired for Version 1. Can anyone explain what's up?


Version 1:

this.createEmptyMovieClip("thisClip",getNextHighestDepth());
thisClip.loadMovie("man.swf");
thisClip.onPress = image_press;
thisClip.onRelease = image_release;


Version 2:

this.createEmptyMovieClip("thisClip",getNextHighestDepth());
thisClip.createEmptyMovieClip("man", thisClip.getNextHighestDepth());
thisClip .man.loadMovie("man.swf");
thisClip.onPress = image_press;
thisClip.onRelease = image_release;


The handlers are defined as simple calls to startDrag/stopDrag:

function image_press() {
this.startDrag(false);
trace("man press");
}

function image_release() {
this.stopDrag();
trace("man release");
}
This topic has been closed for replies.

2 replies

kglad
Community Expert
Community Expert
June 5, 2006
it actually does wait. but it's so quick that you may be mislead into thinking your code is ok (which it is when tested locally) only to find that upon uploading to your server, there's a problem.
kglad
Community Expert
Community Expert
June 4, 2006
handlers applied to a movieclip (like your thisClip.onPress handler) is removed when that movieclip is the target of a loadMovie() statement. when loading is complete you can assign an onPress handler that functions as you expect. or you can use version 2 to target the child of a movieclip and assign handlers to the parent.
fred_slAuthor
Inspiring
June 4, 2006
That makes sense now. When the swf's are loaded from the local drive it's easy to forget loadMovie() doesn't wait for completion.