Sliding pages in Fex4 using group

Source: Internet
Author: User

Use group with animate to implement paging, and to animate page flipping:

<?xml version="1.0"encoding="Utf-8"? ><s:application xmlns:fx="http://ns.adobe.com/mxml/2009"xmlns:s="Library://ns.adobe.com/flex/spark"xmlns:mx="LIBRARY://NS.ADOBE.COM/FLEX/MX"MinWidth="955"minheight=" the"> <fx:Script> <![cdata[ImportSpark.core.NavigationUnit; /** * Previous page*/        Private functionPrepagehandler ():void{Smp.valueby=Hgroup.gethorizontalscrollpositiondelta (Navigationunit.page_left);        Anmiate.play (); }         /** * Next page*/        Private functionNextpagehandler ():void{Smp.valueby=Hgroup.gethorizontalscrollpositiondelta (navigationunit.page_right);        Anmiate.play (); }         ]]> </fx:script> <fx:Declarations> <s:animate id="Anmiate"target="{Hgroup}"duration=" the"> <s:motionPaths> <s:simplemotionpath id="SMP"property="Horizontalscrollposition"/> </S:motionpaths> </S:animate> </Fx:declarations> <s:panel title="Flex4 group New features"> <s:hgroup id="Hgroup"gap="Ten"height=" the"Width=" the"clipandenablescrolling="true"> <s:button width=" the"height=" the"Label="1"Fontsize="+"/> <s:button width=" the"height=" the"Label="2"Fontsize="+"/> <s:button width=" the"height=" the"Label="3"Fontsize="+"/> <s:button width=" the"height=" the"Label="4"Fontsize="+"/> <s:button width=" the"height=" the"Label="5"Fontsize="+"/> <s:button width=" the"height=" the"Label="6"Fontsize="+"/> <s:button width=" the"height=" the"Label="7"Fontsize="+"/> </s:hgroup> <s:controlBarContent> <s:hgroup width="100%"horizontalalign="Center"> <s:button label="Prev"click="Prepagehandler ()"/> <s:button label="Next Page"click="Nextpagehandler ()"/> </S:hgroup> </S:controlbarcontent> </s:panel></S:application>

Using motionpaths belongs to animate can set the target at the same time multiple belong to achieve more complex animation, here we just change group horizontalscrollposition can,

Because Horizontalscrollposition and verticalscrollposition are automatically calculated when the group container does not display all the subsets, the two properties are for scroller.

The most flexible and ingenious place is that these two properties can be used not only as scrollbars, but also through animate to change their values to achieve the effect of sliding.

Navigationunit is an enumeration class, he defines Page_up, Page_down, Page_left, Page_right and so on, here we use Hgroup, is horizontal, so only with Page_left, Page_right, you can do it.

It is also very important that the group's two methods:Gethorizontalscrollpositiondelta () and Getverticalscrollpositiondelta (), Using this two-person method and the Navigationunit enumeration class parameter, you can calculate the left or right shift of the current page,

The horizontalscrollposition value that needs to be adjusted. And so on, you can use Vgroup to achieve up and down the page, Tilegroup can achieve up and down around the flip, and the change is very simple.

That's it, calculating the scrolling distance to Simplemotionpath and then playing the animation, everything is so simple and extremely efficient.

Sliding pages in Fex4 using group

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.