PDA

View Full Version : another scrollPane problem...


rach236
06-01-2006, 07:44 PM
Hi everyone, sorry to post on this subject but I have searched and searched and fiddled with my flash for ages and I just can't get it to work!

Ok my problem is that I can't get my dynamically created mc to go inside my scrollpane it just sits on top.

This is the way i have done things. I have a function which creates the content. This involved dynamically creating a blank movieclip and attaching other movie clips to this - the code is fine, it functions by itself.
I then have another function to create the scrollpane. WhenI run the scrollpane function. The last line of this tells flash to create the scrollpane content.

Ok here is my code to create the scrollpane...


function createScroll():Void {
var cars:MovieClip;
import mx.containers.ScrollPane;
// create a new scrollpane:
createClassObject(ScrollPane, "scrollPane", getNextHighestDepth());
with (scrollPane) {
move(0, 0);
setSize(500, 400);
hScrollPolicy = "off";
vScrollPolicy = "on";
// add an empty clip from the library:
contentPath = "blank2";
};
scrollPane.invalidate();
createScrollContent();
}

blank2 is just an empty mc in the library.

Ok now I have my code for the content...

function createScrollContent():Void{


numberVar = new LoadVars();
loadVarsText = new LoadVars();

blank=this.attachMovie("blank","blank_mc",this.getNextHighestDepth(),{_x:0,_y:0});

scrollPane.content=blank;
for (var i = 0; i<4; i++) {
cell = blank.attachMovie("cell", "cell_"+i, blank.getNextHighestDepth(), {_x:0, _y:120*i});
placeholder = cell.attachMovie("placeholder", "placeholder_"+i, cell.getNextHighestDepth(), {_width:133, _height:100, _x:50, _y:20});
jpegName = "stock/car"+i+"/thumbMain"+i+".jpg";
//some more script setting up buttons etc...

};
}
//blank._visible=false;

scrollPane.invalidate();
//scrollPane.contentPath.refreshPane();
};


blank is an empty movie clip that I dynamically attach the content to.
I have used scrollPane.content=blank; to load this into the scrollpane but its not working.

I am confused by the difference between content and contentPath and whether I need both of these and whether they should point to different things.

Any suggestions would be great - sorry about the epic post :(

rach236
06-01-2006, 07:54 PM
wow i sorted it myself. Just incase anyone is having a similar problem I replace the line...


scrollPane.content = blank;
with
blank = scrollPane.spContentHolder;

:D

sleekdigital
06-01-2006, 09:22 PM
The more correct way would be ...
blank = scrollPane.content
scrollPane.spContentHolder is a direct movieclip reference. scrollPane.content is a reference to the same movieclip but it is exposed through the API.

rach236
06-01-2006, 10:47 PM
thanks still learing so it all helps ;)