RE: [Flashcoders] Scroll Bar formula problem

2007-06-25 Thread Jesse Graupmann
Using 4 movieClips; mask, content, handle, scrollbar


handle.onPress = mx.utils.Delegate.create ( this, startScroll );
handle.onRelease = handle.onReleaseOutside = mx.utils.Delegate.create (
this, stopScroll );

function startScroll()
{
var l = scrollbar._x;
var t = scrollbar._y;
var r = scrollbar._x;
var b = scrollbar._y + scrollbar._height - handle._height;
handle.startDrag (false, l, t, r, b );
onEnterFrame = scrollPer;
}

function stopScroll()
{
handle.stopDrag();
}

function scrollPer()
{
var t = scrollbar._y;
var b = scrollbar._y + scrollbar._height - handle._height;
var per = ( handle._y - scrollbar._y ) / ( b-t );
setScrollPer( per );
}

function setScrollPer( per )
{
var t = mask._y;
var b = mask._y + mask._height - content._height;
var dY = ((b - t)*per) + t;
content._y = dY;
}



_

Jesse Graupmann
www.jessegraupmann.com 
www.justgooddesign.com/blog/ 
_



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of O. Fouad
Sent: Monday, June 25, 2007 1:15 AM
To: Flashcoders mailing list
Subject: [Flashcoders] Scroll Bar formula problem

Hi, I can't figure out how I can move a masked MC according to the position
of the scroll bar.

I tried this code with a scrollbar a mask and MC (the content)

yp = scrollbar._y;
scrollRatio = MC._height/mask._height;

scrollbar._height = mask._height/scrollRatio; //gets the height of the
scrollbar ;


left = scrollbar._x;
top = scrollbar._y
right = scrollbar._x;
bottom = (mask._x + mask._height) - scrollbar._height;

this.onEnterFrame = function () {
//here is the formula i tried

MC._y = (-scrollbar._y+ yp) / scrollRatio; // for sure this is
incorrect!!!
}
scrollbar.onPress = function () {
startDrag(this, false, left,top,right,bottom);
}
scrollbar.onRelease =  function () {
this.stopDrag();
}
scrollbar.onReleaseOutside =  function () {
this.stopDrag();
}
// end of code


With this code the intial position of the MC isn't like the one it is
supposed to be, and the scrollbar isnt srcolling the MC entirely...

can any ne help???


Best Regards..


-- 
O.Fouad
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Scroll Bar formula problem

2007-06-25 Thread O. Fouad

thanks jesse this worked like a charm...  ;-)

On 6/25/07, Jesse Graupmann [EMAIL PROTECTED] wrote:


Using 4 movieClips; mask, content, handle, scrollbar


handle.onPress = mx.utils.Delegate.create ( this, startScroll );
handle.onRelease = handle.onReleaseOutside = mx.utils.Delegate.create (
this, stopScroll );

function startScroll()
{
var l = scrollbar._x;
var t = scrollbar._y;
var r = scrollbar._x;
var b = scrollbar._y + scrollbar._height - handle._height;
handle.startDrag (false, l, t, r, b );
onEnterFrame = scrollPer;
}

function stopScroll()
{
handle.stopDrag();
}

function scrollPer()
{
var t = scrollbar._y;
var b = scrollbar._y + scrollbar._height - handle._height;
var per = ( handle._y - scrollbar._y ) / ( b-t );
setScrollPer( per );
}

function setScrollPer( per )
{
var t = mask._y;
var b = mask._y + mask._height - content._height;
var dY = ((b - t)*per) + t;
content._y = dY;
}



_

Jesse Graupmann
www.jessegraupmann.com
www.justgooddesign.com/blog/
_



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of O. Fouad
Sent: Monday, June 25, 2007 1:15 AM
To: Flashcoders mailing list
Subject: [Flashcoders] Scroll Bar formula problem

Hi, I can't figure out how I can move a masked MC according to the
position
of the scroll bar.

I tried this code with a scrollbar a mask and MC (the content)

yp = scrollbar._y;
scrollRatio = MC._height/mask._height;

scrollbar._height = mask._height/scrollRatio; //gets the height of the
scrollbar ;


left = scrollbar._x;
top = scrollbar._y
right = scrollbar._x;
bottom = (mask._x + mask._height) - scrollbar._height;

this.onEnterFrame = function () {
//here is the formula i tried

MC._y = (-scrollbar._y+ yp) / scrollRatio; // for sure this is
incorrect!!!
}
scrollbar.onPress = function () {
startDrag(this, false, left,top,right,bottom);
}
scrollbar.onRelease =  function () {
this.stopDrag();
}
scrollbar.onReleaseOutside =  function () {
this.stopDrag();
}
// end of code


With this code the intial position of the MC isn't like the one it is
supposed to be, and the scrollbar isnt srcolling the MC entirely...

can any ne help???


Best Regards..


--
O.Fouad
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com





--
O.Fouad
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com