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?
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?