i want to make a scrollable index of particular math book for android version where i will be able to scroll a movie clip consists of 56 child movieclips(there are chapter 1 to chapter 56 child clips has made "buttons_all" parentclip) and when i will choose a child movie clip it will go to selected label or chapter(suppose if i click chapter 1 movie clip it will gotoAndPlay("chapter 1")).i had made the parent movieclip scrollable and added eventlistener to each child movie clip..but when i want to scroll it is doing two things,first it scrolls then go to that "chapter" that i clicked to start scrolling whether i want to go this chapter or not.to solve that i added a timer event to create an interval to stop selecting chapter immediately before i want to select a specific chapter..but it is working partially.i want to add this interval to every button.because i dont have a scrollbar here for up and down..please help me to solve this..here is my part of code
var pat1:MovieClip = scrolling_manu.buttons_all.part1;
var listTimer:Timer; // timer for all events
var tapDelayTime:Number = 0;
var maxTapDelayTime:Number = 20; // change this to increase or descrease tap sensitivity
var tapEnabled:Boolean = false;
init();
function init()
{
//removeEventListener(Event.ADDED_TO_STAGE, init);
pat1.addEventListener(TouchEvent.TOUCH_BEGIN, onmouseDown );
//trace("hit");
pat1.addEventListener(TouchEvent.TOUCH_END, onmouseUp );
listTimer = new Timer( 33 );
listTimer.addEventListener( TimerEvent.TIMER, onListTimer);
listTimer.start();
}
function onmouseDown( e:TouchEvent ):void
{
handleItemPress()
}
function onmouseUp( e:TouchEvent ):void
{
onTapDisabled();
//listTimer.stop();
}
function onListTimer(e:Event):void
{
// test for touch or tap event
if(tapEnabled)
onTapDelay();
}
function onTapDisabled():void
{
tapEnabled = false;
tapDelayTime = 0;
}
function onTapDelay():void
{
tapDelayTime++;
if(tapDelayTime > maxTapDelayTime )
{
//tapItem.selectItem();
tapDelayTime = 0;
tapEnabled = false;
trace("hit");
pat1.gotoAndPlay("over1");
pat1.addEventListener(TouchEvent.TOUCH_END, onmouseUp );
}
}
function handleItemPress()
{
tapDelayTime = 0;
tapEnabled = true;
trace("hit");
}
Firstly, I recommend you to convert all vector images to raster. It's very hard for processor to animate vector images.
Delete all code after drop_me
function.
Write this:
scrolling_manu.buttons_all.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);
scrolling_manu.buttons_all.addEventListener(TouchEvent.TOUCH_END, onTouchEnd);
var touchedPart:MovieClip;
var posY:int;
function onTouchBegin(event:TouchEvent):void
{
touchedPart = event.target as MovieClip;
posY = scrolling_manu.buttons_all.y;
}
function onTouchEnd(event:TouchEvent):void
{
// if list was been moved, that isn't a tap.
if (posY == scrolling_manu.buttons_all.y)
{
trace("part tapped", touchedPart.name);
touchedPart.gotoAndPlay("over1");
}
}