Learn to do Flash message book: Paging technology

Source: Internet
Author: User
Tags copy count split
Paging this time is to do a message board paging as+asp+access, pass an ID, a title titles, author author Three kinds of data, then define a allid,alltitle,allauthor, And then looping through the database to add all the data IDs in the Allid, all the titles are added to the alltitle, all the titles add up to the Allauthor in the final allid,alltitle,allauthor to Flash (add the time to remember the addition of the separator, For example, "#, then allid=" i#2#3# ... "and so on, split to notice a bit) the next is the Flash section. Here I use the Loadvar class to accept the data.
Define a function
This function accepts three parameters, Allid,alltitle,allauthor
function Showtitle (allId:StringallTitle:String, alluser:string, allauthor:string)
{
Define three arrays
var ids:array = new Array ();
var titles:array = new Array ();
var author:array = new Array ();
According to the separator, put the separated data in the array
ids = Allid.split ("#");
Titles = Alltitle.split ("#");
Author= alluser.split ("#");
Here is the main part of the program, please pay attention to see, with a For loop
First copy a movie, then add the data to the variables in the MC
for (var i = 0; i < ids.length; i++)
{
Copy MC
var mc:movieclip = This.attachmovie ("titles", "titles" + i,10 * i + 100);
mc._x = 40;
mc._y = i * 35;
Assign relevant information to the corresponding variable of MC
Mc.titlevar = Titles[i];
Mc.authorvar = Users[i];
When you click on the title, enter the content
Buttonevent (MC, Ids[i],);
}
}
Defining button Events
function Buttonevent (Btn:movieclip, id:string)
{
btn.menuBtn.onPress = function ()
{
Loadmovienum ("content.swf?&titleid=" + ID, 0);
}
}
This is the function that shows the paging button, this is not a difficult problem, mainly the question of judgment
page, current page--PageCount, total number of pages---count, how many pager on a page when the strong display bar is displayed
function ShowPage (id:string,count:string,page:string,pagecount:string,pager:number)
{
Copy a MC out, which contains the previous page, the next page, the first page, the last page, back to the top of these buttons
if (page!= "1" | | |-count * 1 = = pager)
{
This.attachmovie ("Pagemc", "PAGEMC", 50);
pagemc._x = 200;
pagemc._y = 465;
}
First page
pageMC.oneBtn.onPress = function ()
{
If this is the first page, the pop-up warning box
if (count * 1 = pager)
{
Showalert ("The current page is already the first page");
}
Else
{
Loadmovienum ("title.swf?&&id=" + id,0);
}
}
Previous page
pageMC.upBtn.onPress = function ()
{
If it's the first page,
if (page = = "1" && count = = Pager)
{
Showalert ("No previous page");
}
Else
{
var pageno:number = page * 1-1;
Loadmovienum ("title.swf?&id=" + ID + "&pageno=" + pageno,0);
}
}
Next page
pageMC.nextBtn.onPress = function ()
{
When on the last page
if (page = = PageCount)
{
Showalert ("No Next page");
}
Else
{
var pageno:number = page * 1 + 1;
Loadmovienum ("title.swf?&id=" + ID + "&pageno=" + pageno,0);
}
}
Last page
pageMC.lastBtn.onPress = function ()
{
if (page = = PageCount)
{
Showalert ("The current page is the last page already");
}
Else
{
Loadmovienum ("title.swf?&id=" + ID + "&pageno=" + pagecount,0);
}
}
Home
pageMC.indexBtn.onPress = function ()
{
Loadmovienum ("index.swf", 0);
}
}
Pop-up warning box function, alert component
function Showalert (str:string)
{
Alert.yeslabel = "OK";
Alert.nolabel = "Cancel";
Alert.show (str, "hint", alert.yes| alert.no);
Here is the last step to load the background program files that can output Allid,alltitle,allauthor
Stop ();
System.usecodepage = true; Show Chinese
var pageno:string; First few pages
var sendvar:loadvars = new Loadvars ();
var loadvar:loadvars = new Loadvars ();
If PageNo is empty, always set PageNo to be the first page
if (PageNo = null)
{
PageNo = "1";
}
Pass the pages out so that the background program searches
Sendvar.pageno = PageNo;
Sendvar.sendandload ("filename", Loadvar, "post");
Loadvar.onload = function (Success:boolean)
{
if (success)
{
page = Loadvar.page; Current page
Count = Loadvar.count; The number of the current bar, in fact, this can not, judge the change can be
PageCount = Loadvar.pagecount; Total pages
ShowPage (id,count,page,pagecount,10);
Showtitle (Loadvar.allid,loadvar.alltitle,loadvar.allauthor);
}
Else
{
_root.gotoandstop ("error");
}
}

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.