PDA

View Full Version : make a loaded swf dragable



ditti
October 9th, 2005, 08:16 PM
Hello!

I have tried for quite a while to make a loaded swf dragable.
I have a main movie.
In the main movie I have a button (load_btn) which on press load a swf (loaded.swf) into an empty movieclip called holder.
In the loaded movie I have a button called drag.
I want the loaded swf to be dragable when I press the button drag.
Is it possible. Can someone help me with this??



_root.load_btn.onPress=function() {
_root.createEmptyMovieClip('holder',_root.getNextH ighestDepth());
_root.holder._x = 150;
_root.holder._y=100;
with(_root.holder){
loadMovie("loaded.swf");
}
}


holder.drag.onPress=function() {
startDrag(holder);
}

holder.drag.onRelease=function() {
stopDrag();

scotty
October 10th, 2005, 02:46 AM
Put the drag actions after the swf is fully loaded

_root.load_btn.onPress = function() {
var box = _root.createEmptyMovieClip("holder", _root.getNextHighestDepth());
box._x = 150;
box._y = 100;
preLoad(box, "loaded.swf");
};
function preLoad(box, clip) {
box.loadMovie(clip);
var temp = this.createEmptyMovieClip("temp", this.getNextHighestDepth());
temp.onEnterFrame = function() {
if (box.getBytesLoaded() == box.getBytesTotal() && box.getBytesTotal()>4) {
box.drag.onPress = function() {
this._parent.startDrag();
};
box.drag.onRelease = function() {
stopDrag();
};
delete this.onEnterFrame;
}
};
}

or put those actions in the external swf :)

scotty(-:

ditti
October 10th, 2005, 07:15 AM
Thanks a lot!! I am really greatful!

scotty
October 10th, 2005, 04:53 PM
you're welcome =)

mucho
May 23rd, 2006, 01:11 PM
yep, thanks, could use this very good as well