Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have implemented something similar, except it was a horizontal scrolling list, and also I used a scroll left/right buttons on the sides of the list, the mouse_over effect is triggered by the buttons, not the list (but this shouldn't be an impediment when adapting the code).</p> <p>To do the actual scrolling, I used an animate effect which targeted the list's layout, and more specifically, the layout's <code>horizontalScrollPosition</code>. This it what the MXML code looks like:</p> <pre><code>&lt;s:Animate id="scrollAnimation" target="{listLayout}"&gt; &lt;s:easer&gt; &lt;s:Linear easeInFraction="0" easeOutFraction="0" /&gt; &lt;/s:easer&gt; &lt;s:SimpleMotionPath id="scrollMotionPath" property="horizontalScrollPosition" /&gt; &lt;/s:Animate&gt; </code></pre> <p>That <code>easer</code> is necessary because animate effect usually have 3 motion stages (acceleration, uniform motion and deceleration), so by default you would get a wavy scrolling motion. I used RobotLeft for that project, so the view is mediated like this:</p> <p>When the mediator is registered, add the scroll button listeners:</p> <pre><code>viewComponent.scrollLeft.addEventListener(MouseEvent.MOUSE_OVER, onScrollLeft); viewComponent.scrollRight.addEventListener(MouseEvent.MOUSE_OVER, onScrollRight); viewComponent.scrollLeft.addEventListener(MouseEvent.MOUSE_OUT, onScrollOut); viewComponent.scrollRight.addEventListener(MouseEvent.MOUSE_OUT, onScrollOut); </code></pre> <p>We also need to add a listener so we can tell when the scrolling effect finished, because we might need to replay it:</p> <pre><code>viewComponent.scrollEffect.addEventListener(EffectEvent.EFFECT_END, onScrollEnd); </code></pre> <p>We can now implement the scrolling method. Since the view is mediated, we have access to the scroll effect, we can reference it here (and also the path). This what the method looks like:</p> <pre><code>private function scrollOnlineFriendsList(scrollBy:int):void { // Set the scrollBy value and play the scrolling effect viewComponent.scrollMotionPath.valueBy = scrollBy; viewComponent.scrollEffect.play(); // Store the scrollBy value in case the effect will need to be replayed, // if the mouse over event is still over the scrolling button/area this.scrollBy = scrollBy; canKeepScrolling = true; } </code></pre> <p>Finally, the handlers:</p> <pre><code>private function onScrollLeft(event:MouseEvent):void { scrollOnlineFriendsList(-33); } private function onScrollRight(event:MouseEvent):void { scrollOnlineFriendsList(33); } private function onScrollOut(event:MouseEvent):void { canKeepScrolling = false; // If you would like the effect to continue playing // until it finishes the current scrolling operation, // once the mouse is no longer over a scroll button, // just comment this line viewComponent.scrollEffect.stop(); } private function onScrollEnd(event:EffectEvent):void { // When the scroll effect has finished playing, // if the mouse is still over the scroll button/area, // replay the effect if (canKeepScrolling) scrollOnlineFriendsList(scrollBy); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload