Skip to main content
February 3, 2013
Answered

1013: The private attribute may be used only on class property definitions.

  • February 3, 2013
  • 1 reply
  • 616 views

import com.doitflash.consts.Orientation;

import com.doitflash.consts.Easing;

import com.doitflash.events.ScrollEvent;

import com.doitflash.starling.utils.scroller.Scroller;

import starling.events.TouchEvent;

import starling.events.TouchPhase;

import starling.events.Touch;

import starling.extensions.ClippedSprite;

import flash.geom.Point;

var content:ClippedSprite = new ClippedSprite(); // the content you want to scroll

content.clipRect = new Rectangle(0, 0, 500, 500); // set the space that you want your content to be visible at, set its mask actually

content.addEventListener(TouchEvent.TOUCH, onTouch);

this.addChild(content);

var scroll:Scroller = new Scroller();

scroll.boundWidth = 500; // set boundWidth according to the mask width

scroll.boundHeight = 500; // set boundHeight according to the mask height

scroll.content = content; // you MUST set scroller content before doing anything else

scroll.orientation = Orientation.VERTICAL; // accepted values: Orientation.AUTO, Orientation.VERTICAL, Orientation.HORIZONTAL

// you call this function, to start scrolling

private function onTouch(e:TouchEvent):void

{

    var touch:Touch = e.getTouch(stage);

    var pos:Point = touch.getLocation(stage);

   

    if (touch.phase == TouchPhase.BEGAN)

    {

        scroll.startScroll(pos); // on touch begin

    }

    else if (touch.phase == TouchPhase.MOVED)

    {

        scroll.startScroll(pos); // on touch move

        //trace(_scroll.isHoldAreaDone); // to see that we have got out of the hold area or not

    }

    else if (touch.phase == TouchPhase.ENDED)

    {

        scroll.fling(); // on touch ended

    }

}

i got this error after pasting this code in.. i cant figure out the problem.. some help pls?

This topic has been closed for replies.
Correct answer kglad

use:

import com.doitflash.consts.Orientation;

import com.doitflash.consts.Easing;

import com.doitflash.events.ScrollEvent;

import com.doitflash.starling.utils.scroller.Scroller;

import starling.events.TouchEvent;

import starling.events.TouchPhase;

import starling.events.Touch;

import starling.extensions.ClippedSprite;

import flash.geom.Point;

var content:ClippedSprite = new ClippedSprite(); // the content you want to scroll

content.clipRect = new Rectangle(0, 0, 500, 500); // set the space that you want your content to be visible at, set its mask actually

content.addEventListener(TouchEvent.TOUCH, onTouch);

this.addChild(content);

var scroll:Scroller = new Scroller();

scroll.boundWidth = 500; // set boundWidth according to the mask width

scroll.boundHeight = 500; // set boundHeight according to the mask height

scroll.content = content; // you MUST set scroller content before doing anything else

scroll.orientation = Orientation.VERTICAL; // accepted values: Orientation.AUTO, Orientation.VERTICAL, Orientation.HORIZONTAL

// you call this function, to start scrolling

function onTouch(e:TouchEvent):void

{

    var touch:Touch = e.getTouch(stage);

    var pos:Point = touch.getLocation(stage);

   

    if (touch.phase == TouchPhase.BEGAN)

    {

        scroll.startScroll(pos); // on touch begin

    }

    else if (touch.phase == TouchPhase.MOVED)

    {

        scroll.startScroll(pos); // on touch move

        //trace(_scroll.isHoldAreaDone); // to see that we have got out of the hold area or not

    }

    else if (touch.phase == TouchPhase.ENDED)

    {

        scroll.fling(); // on touch ended

    }

}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
February 3, 2013

use:

import com.doitflash.consts.Orientation;

import com.doitflash.consts.Easing;

import com.doitflash.events.ScrollEvent;

import com.doitflash.starling.utils.scroller.Scroller;

import starling.events.TouchEvent;

import starling.events.TouchPhase;

import starling.events.Touch;

import starling.extensions.ClippedSprite;

import flash.geom.Point;

var content:ClippedSprite = new ClippedSprite(); // the content you want to scroll

content.clipRect = new Rectangle(0, 0, 500, 500); // set the space that you want your content to be visible at, set its mask actually

content.addEventListener(TouchEvent.TOUCH, onTouch);

this.addChild(content);

var scroll:Scroller = new Scroller();

scroll.boundWidth = 500; // set boundWidth according to the mask width

scroll.boundHeight = 500; // set boundHeight according to the mask height

scroll.content = content; // you MUST set scroller content before doing anything else

scroll.orientation = Orientation.VERTICAL; // accepted values: Orientation.AUTO, Orientation.VERTICAL, Orientation.HORIZONTAL

// you call this function, to start scrolling

function onTouch(e:TouchEvent):void

{

    var touch:Touch = e.getTouch(stage);

    var pos:Point = touch.getLocation(stage);

   

    if (touch.phase == TouchPhase.BEGAN)

    {

        scroll.startScroll(pos); // on touch begin

    }

    else if (touch.phase == TouchPhase.MOVED)

    {

        scroll.startScroll(pos); // on touch move

        //trace(_scroll.isHoldAreaDone); // to see that we have got out of the hold area or not

    }

    else if (touch.phase == TouchPhase.ENDED)

    {

        scroll.fling(); // on touch ended

    }

}