PDA

View Full Version : Drag and drop from scrollpane


jeeep
03-09-2008, 12:01 AM
Does anyone have a good tutorial on this? Right now I have this code for loading thumbnails:

button_btn.onRelease = function() {
// create the scrollpane
_root.createClassObject(mx.containers.ScrollPane, "scroll_sp", _root.getNextHighestDepth(), {_width:300, _height:200, _x:100, _y:0});
checkPaneLoaded(_root.scroll_sp);
};
function checkPaneLoaded(instance:Object) {
// make sure the scrollpane is on the stage
_root.onEnterFrame = function() {
scrollPaneLoaded(instance);
};
}
function scrollPaneLoaded(instance:Object) {
if (instance instanceof mx.containers.ScrollPane) {
// free up resources
delete _root.onEnterFrame;
// Create scrollpane listener
instanceListener = new Object();
instanceListener.complete = function(evtObject) {
// Load the pictures into the loaded movie clip
loadPictures(evtObject.target);
};
instance.addEventListener("complete", instanceListener);
// Load the content into the scrollpane
instance.contentPath = "clips.swf";
}
}
function loadPictures(scrollpane) {
// Create the array with the file urls
var clipArray:Array = new Array("pics/winter.jpg", "pics/sunset.jpg", "pics/waterlillies.jpg", "pics/bluehills.jpg");
for (var i = 0; i<clipArray.length; ++i) {
// loops through array and dynamically creates containers for each url
var clip:MovieClip = scrollpane.content.pane_mc.createEmptyMovieClip("clip"+i+"_mc", i);
clip.loadMovie(clipArray[i]);
clip._x = 50;
// spacing
clip._y = i*150;
}
}



And this code for dragging and dropping

function dragMe(target) {
target.onPress = function() {
startDrag(this);
selectedObject = this._name;
trace(selectedObject);
}
target.onRelease = function() {
stopDrag();
trace(this._name+" X = "+this._x);
trace(this._name+" Y = "+this._y);
}
}
for (i=0; i<25; ++i) {
_root.dragMe(_root["ob"+i]);
}


How do I get the two to work together?

jeeep
03-13-2008, 04:01 AM
I have a MC named "m1" that has 4 items inside of it that I can drag and drop from.

for(n=0;n<=3;n++){
_root.m1["mc"+n].dupAndDrag();
}


When I attach this MC to a ScrollPane* I am unable to reach "m1"
*s1.contentPath="m1";

I've tried

for(n=0;n<=3;n++){
_root.s1.m1["mc"+n].dupAndDrag();
}


But this isnt working. What do I need to involve so that I may drag and drop from the scrollpane?

inhan
03-13-2008, 04:17 AM
Try the following:

_root.s1.spContentHolder["mc"+n]