Specific practices:
1.1 create a new Flash file and save it as index_flash.fla
1.2 Create a MC in this document named pagesButtons_clip. Put a button in it and write the code:
On (release ){
_ Parent. loadNews (_ name); // This function is used to redirect pages in Flash.
}
1.3 load another dynamic text with the variable name _ name
1.4 put four pagesButton_clip in the main scenario and name them page1, page2, page3, and page4 respectively.
1.5 create a new MC in the home scene, the instance name is pages, and put the MC with the instance name page1, page2, page3, and page4 in it.
1.6 create a mask for pages at an appropriate position.
1.7 The following code can be written. In this jump, I will locate the corresponding page to the mask so that the page will be displayed, while others will be hidden.
Frame write in the main scenario:
Var initx = mask. _ x; // first, locate an initial vertex, which is a constant located on the page.
Var inity = mask. _ y; // same as above
Var targetx = initx;
Var targety = inity; // these two variables are also used for locating. Using Korean buffer formula algorithms, MC can be moved slowly to (targetx, targety.
This. onEnterFrame = function (){
Pages. _ x = pages. _ x-0.2 * (pages._x-pages.tar getx );
Pages. _ y = pages. _ y-0.2 * (pages._y-pages.tar gety );
}; // This is the buffer formula
Function loadNews (href) {// define the function triggered by the button
Pages.tar getx = initx-pages [href]. _ x;
Pages.tar gety = inity-pages [href]. _ y; // first let target locate to the current MC (that is, the input parameter href), then the buffer formula will display the input MC, and others will be hidden.
Fscommand ("setAddress", href); // you can specify the content in the address bar to refresh the page. This command is returned in JS.
GetURL ("statistics.html? "+ Href," stat "); // enable iframe to record the instance name href from the current point to the MC
}
2.1 publish an HTML file and a SWF file in Flash with fscommand tracking, and then remove the HTML check on the format tab of the publishing settings.
2.2 Open the index_flash.html file with the notebook and find the // place your code here sentence. Write
If (command = "setAddress "){
Document. location. hash = args
}
2.3 then define the onLoad execution function JS_LoadNews
Function JS_LoadNews (){
Window. open ("statistics.html? "+ Document. location. hash. slice (1)," stat ") // open an iframe with parameters named stat.
}
2.4 add an iframe according to the JS in the previous step
<Iframe noscroll border = "0" src = "about: blank" width = "1" height = "1" name = "stat" id = "stat"> </iframe>
2.5 add onload = JS_LoadNews () to the body tag ()
3.1 Create an HTML file named statistics.html. Write the code for controlling Flash here:
<Script language = "javascript">
Function pageLoad (){
Window. parent. index_flash.setVariable ("link", too many doc ument. location. search. slice (1) // parent refers to the parent framework, which can point to the FLASH file, location. search is an address parameter that contains "? ", So use slice (1) to remove it.
}
</Script>
<Body onload = pageLoad ()>
</Body>
3.2 The above code sets the link value in Flash. In order to trigger the Flash function, addProperty is used in Flash to trigger the related function:
Append frame code:
This. addProperty ("link", getLink, setLink );
Function getLink (){
}
Function setLink (link ){
Fscommand ("setAddress", link );
Pages.tar getx = initx-pages [link]. _ x;
Pages.tar gety = inity-pages [link]. _ y;
}
So far, all three steps to implement the backward forward function have been completed.
The above four articles are part of the first series of Flash full-site applications-bringing Flash closer to HTML, with the aim of "solving the congenital defects of Flash websites with the advantages of HTML ". Today, with the increasingly powerful Flash functions and increasingly distinctive features, the path to HTML for Flash may be "the opposite". In addition, these program codes are boring, therefore, it cannot resonate with everyone. I was going to write this content later. I just mentioned it to solve the problem of the volcano brother.
In the next series, I will write some multimedia applications that are more popular. This includes switching pictures on my website, combining WMP music, video player, and synchronous display of lyrics (but I have already written this content, so I will not repeat it now ).
Preview pictures and music players:
Http://hbro.cincn.com/cindex.htm
PS: remind the volcano brother that I didn't use the positioning technology in the news here. If the refresh fails, I don't need to point it out to me.