I’m trying to get a playhead to move across a grid, when it reaches the maximum space of the mask covering the grid I want the playhead to automatically scroll the scrollbar. Right now, the playhead will move to the end of a specified area and go back to the beginning of the grid but will not scroll. I’m stuck because it all involves using events and I can’t figure out how to pass an event to another event (if that’s even possible). The code that scrolls the scroll bar by user interaction is: (and mc is the name of the content that is to be scrolled)
function scrollMCHoriz(event:ScrollEvent):void{
mc.x = -event.position + mcMask.x;
}
and the playhead (enter frame event) code is as follows:
function onPlayHeadMove(event:Event):void {
playHead.x += 10;
if ((playHead.x - 100) >= mcMask.width) {
}
else if ((playHead.x - 100) >= mc.width) {
playHead.x = mc.x;
}
}
This code:
if ((playHead.x - 100) >= mcMask.width) {
}
is where I want the scrollbar to automatically scroll. But I can’t use mc.x = -event.position + mcMask.x; in that code above anywhere because it throws a runtime error.
The error is 1119: Access of possibly undefined property position through a reference with static type flash.events:Event.
Thanks for your help.