Skip to main content
New Participant
August 5, 2009
Question

flash tutorial gone wrong..

  • August 5, 2009
  • 1 reply
  • 633 views

Hello

I am trying to create a custom scrollbar for a website... I watched the tutorial>http://www.entheosweb.com/Flash/video_tutorials/custom_scroller.asp

on how to create one. I have the scrollbar working but it won't attach to the text!

Here is the actionscript:

var scrollUpper:Number = 338.2;
var scrollLower:Number = 498.2;

var textLower:Number = 337.0;
var textUpper:Number = 514;

var scrollRange:Number = scrollLower - scrollUpper;
var textRange:Number = textLower - textUpper;

function scroll () {
    var moved:Number = scroller_mc._y - scrollUpper;
    var pctMover:Number = moved/scrollRange;
    var textMove:Number = pctMoved*textRange;
    text_mc_y = textLower - textMove;
}

scroller_mc.onPress = function () {
    this.startDrag (false,this._x,scrollUpper,this._x,scrollLower);
    this.onMouseMove = scroll;
}

scroller_mc.onRelease = scroller_mc.onReleaseOutside = function() {
    this.stopDrag ();
    this.onMouseMove = null;
}

I have the text in a mc called text_mc and the scrollbar in scroll_mc. There is a mask over the text.

Thank you for your time!

Virginia

This topic has been closed for replies.

1 reply

kglad
Adobe Expert
August 5, 2009

you have a typo.  use:


var scrollUpper:Number = 338.2;
var scrollLower:Number = 498.2;

var textLower:Number = 337.0;
var textUpper:Number = 514;

var scrollRange:Number = scrollLower - scrollUpper;
var textRange:Number = textLower - textUpper;

function scroll () {
    var moved:Number = scroller_mc._y - scrollUpper;
    var pctMover:Number = moved/scrollRange;
    var textMove:Number = pctMoved*textRange;
    text_mc._y = textLower - textMove;
}

scroller_mc.onPress = function () {
    this.startDrag (false,this._x,scrollUpper,this._x,scrollLower);
    this.onMouseMove = scroll;
}

scroller_mc.onRelease = scroller_mc.onReleaseOutside = function() {
    this.stopDrag ();
    this.onMouseMove = null;
}


New Participant
August 5, 2009

I added the period but it still didn't work.. Here is my new as>

var scrollUpper:Number = 338.2;
var scrollLower:Number = 498.2;

var textLower:Number = 337.0;
var textUpper:Number = 514;

var scrollRange:Number = scrollLower - scrollUpper;
var textRange:Number = textLower - textUpper;

function scroll () {
    var moved:Number = scroller_mc._y - scrollUpper;
    var pctMover:Number = moved/scrollRange;
    var textMove:Number = pctMoved*textRange;
    text_mc._y = textLower - textMove;
}

scroller_mc.onPress = function () {
    this.startDrag (false,this._x,scrollUpper,this._x,scrollLower);
    this.onMouseMove = scroll;
}

scroller_mc.onRelease = scroller_mc.onReleaseOutside = function() {
    this.stopDrag ();
    this.onMouseMove = null;
}

Any ideas? Thank you so much for your help!

Virginia

kglad
Adobe Expert
August 5, 2009

you have a 2nd typo:


var scrollUpper:Number = 338.2;
var scrollLower:Number = 498.2;

var textLower:Number = 337.0;
var textUpper:Number = 514;

var scrollRange:Number = scrollLower - scrollUpper;
var textRange:Number = textLower - textUpper;

function scroll () {
    var moved:Number = scroller_mc._y - scrollUpper;
    var pctMoved:Number = moved/scrollRange;
    var textMove:Number = pctMoved*textRange;
    text_mc._y = textLower - textMove;
}

scroller_mc.onPress = function () {
    this.startDrag (false,this._x,scrollUpper,this._x,scrollLower);
    this.onMouseMove = scroll;
}

scroller_mc.onRelease = scroller_mc.onReleaseOutside = function() {
    this.stopDrag ();
    this.onMouseMove = null;
}

Any ideas? Thank you so much for your help!

Virginia