View Full Version : -Scroll bar Problem-
dubsign
07-13-2005, 02:17 AM
Hi there im trying to get a scroll bar working but it has not been possible. Im loading dynamic content into an empty movie clip in the root time line and then trying to move the _X & _y position of the empty clip once the content is loaded. Using the following code:
var origx:Number = Holder_mc._x;
var origy:Number = Holder_mc._y;
down_mc.onPress = function ()
{
moveup = true;
};
down_mc.onRelease = function ()
{
moveup = false;
};
up_mc.onPress = function ()
{
movedown = true;
};
up_mc.onRelease = function ()
{
movedown = false;
};
_root.onEnterFrame = function ()
{
//this is kind off a preloader
if (Holder_mc._framesloaded == Holder_mc._totalframes)
{
//this will create the mask for the text clip
Holder_mc.setMask (square_mc);
theHeight = Holder_mc._height;
}
if (moveup)
{
if (Holder_mc._y < origy)
{
Holder_mc._y += 12;
}
}
if (movedown)
{
if (Holder_mc._y > (origy - theHeight))
{
Holder_mc._y -= 12;
}
}
};
stop ();
It seems to work when i scroll it down but when y tried to go up it jammed it doesn't work. Im wondering if any one out there can help me or if you can suggest a better way to scroll throw the clip.
Thank's
Hi!
i just added a variable to check the height of your mask. Now it seems to work just fine. And I also added onRelesaseOutside on your buttons. Hope it helps.
var origx:Number = Holder_mc._x;
var origy:Number = Holder_mc._y;
scrollSpeed = 12;
//this is the height of your mask
maskHeight = square_mc._height;
down_mc.onPress = function() {
moveup = true;
};
down_mc.onRelease = down_mc.onReleaseOutside = function() {
moveup = false;
};
up_mc.onPress = function() {
movedown = true;
};
up_mc.onRelease = up_mc.onReleaseOutside = function() {
movedown = false;
};
_root.onEnterFrame = function() {
//this is kind off a preloader
if (Holder_mc._framesloaded == Holder_mc._totalframes) {
//this will create the mask for the text clip
Holder_mc.setMask(square_mc);
theHeight = Holder_mc._height;
}
if (moveup) {
if (Holder_mc._y<origy) {
Holder_mc._y += scrollSpeed;
}
}
if (movedown) {
//here is were i added the variable for the mask height
if (Holder_mc._y>(origy-theHeight+maskHeight)) {
Holder_mc._y -= scrollSpeed;
}
}
};
stop();
Cheers // kent
dubsign
07-15-2005, 04:50 AM
Kent,
Thank's for that, but I still have problems when i scroll up. I don't know if is the code that im using to duplicate the clips inside the SWF in trying to load in the movie clip i want to scroll
myy = myClip_mc._y;
myx = myClip_mc._x;
myWidth = myClip_mc._width;
myHeight = (myClip_mc._height+30);
loaded = false;
numberOfProducts = 0;
loadVariables("TextFiles/Products/GLUTEN_FREE.txt", this);
this.onEnterFrame = function() {
if (this.product1 != undefined && loaded == false) {
for (var prop in this) {
trace(prop);
trace(prop.indexOf("product"));
if (prop.indexOf("product") == 0) {
numberOfProducts++;
trace(numberOfProducts);
}
}
for (i=1; i<=numberOfProducts; i++) {
duplicateMovieClip("myClip_mc", "example"+i, i);
this["example"+i]._x = myx;
this["example"+i]._y = i*myHeight;
this["example"+i].productNumber = i;
this["example"+i].productDetails = this["product"+i];
this["example"+i].imageHolder_mc.createEmptyMovieClip("ih_mc", 100);
this["example"+i].imageHolder_mc.ih_mc.loadMovie("ImagesFiles/Products_Pics/GlutenFree_pics/thumbs/productThmb"+i+".jpg");
this["example"+i].imageHolder_mc.onPress = function() {
//trace (this);
theY = this._parent._y;
theX = this._parent._x;
trace(theY)
myclip = attachMovie("large_image", "large_holder_mc", 200);
myclip.close_mc.onPress = function() {
this._parent.removeMovieClip();
};
myclip._y = theY;
myclip._x = theX;
myclip.empty_mc.loadMovie("ImagesFiles/Products_Pics/GlutenFree_pics/large/productFull"+this._parent.productNumber+".jpg");
};
loaded = true;
}
}
};
myClip_mc._visible = 0;
stop();
or if is the code im using to reset the clip to it's original positon
SubMenu_mc.GlutenFree_mc.onPress = function ()
{
Holder_mc._y = origy;
Holder_mc.loadMovie ("GlutenFree_v02.swf");
};
SubMenu_mc.CafeSelection_mc.onPress = function ()
{
Holder_mc._y = origy;
Holder_mc.loadMovie ("CafeSelection_v02.swf");
};
SubMenu_mc.NonChocolate_mc.onPress = function ()
{
Holder_mc._y = origy;
Holder_mc.loadMovie ("NonChocolate_v02.swf");
};
SubMenu_mc.PetitFours_mc.onPress = function ()
{
Holder_mc._y = origy;
Holder_mc.loadMovie ("PetitFours_v02.swf");
};
SubMenu_mc.Truffles_mc.onPress = function ()
{
Holder_mc._y = origy;
Holder_mc.loadMovie ("Truffles_v02.swf");
};
SubMenu_mc.Handmade_mc.onPress = function ()
{
Holder_mc._y = origy;
Holder_mc.loadMovie ("HandMade_v02.swf");
};
SubMenu_mc.GiftSelection_mc.onPress = function ()
{
Holder_mc._y = origy;
Holder_mc.loadMovie ("GiftSelection_v02.swf");
};
SubMenu_mc.Bonbonniere_mc.onPress = function ()
{
Holder_mc._y = origy;
Holder_mc.loadMovie ("Bonbonniere_v02.swf");
};
SubMenu_mc.Savouries_mc.onPress = function ()
{
Holder_mc._y = origy;
Holder_mc.loadMovie ("Savouries_v02.swf");
};
To see what i mean go to http://www.sissysbix.com go to products sections and try to use the scroll. You will find where my problem is.
I hope someone can help me
srija
07-15-2005, 06:26 AM
not sure :confused: but this may cause prblm:
origy - theHeight
b'coz after this origy will not b the same
try using a variable:
let me know if i m right?? :eek:
dubsign
07-22-2005, 06:06 AM
Kent,
Cheers mate... the code you provided solve my problem much appreciated
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.