Let Flash website have ie forward back function

Source: Internet
Author: User
Tags hash iis variables

Flash Total Station Technology application series :
(i)as+js flash site without the refresh location technology
(ii)The SEO of the Flash website
(iii)Flash website Traffic Statistics
(iv) let the flash website have ie forward back function ( this article )

Preface :

After writing the flow statistics tutorial, I thought it would be easy to finish the article. Later found that the original still encountered difficulties. Because to control the main HTML variables through the IFRAME, at the beginning, considering that the Open parent window is _parent, and the parent in Flash is _parent, it is reasonable to assume that the IFRAME access to the main HTML is also through the _parent, resulting in a long time, or prompt _parent undefined.
To this end, I Baidu to see how to access the main HTML through the IFRAME. Halo, originally this is not underlined, and then changed, found that there are new problems, is the hint "No permissions" error. This problem was encountered in a game that was previously in reverse compilation and was caused by cross-domain access. Strange, My Documents are in the local Ah, why not? Tortured for half an hour, decided to use IIS to test it. Well, IIS was successful. Doesn't the file protocol have permissions? Or can not identify the domain name? I'm not going to go into this.

Effect Preview (should be wolf2999 requirements, this time I will not put the super girl things up, and my site now add this function still a little trouble, because the structure is a bit complicated:
Http://hbro.cincn.com/hbro/cours ... ex_flash.html#page1

Point to the left a row of buttons, you will find that in the animation effect jump process, the address bar has changed, but obviously Flash does not refresh, while the Back button is available. After you have a few more times, try to press the back button, Flash also does not refresh, but it will be animated to jump to your previous point of page.
In this way, it is through the IE Button control Flash program. However, in essence, there is an iframe in the refresh, so, if the network slow, and point quickly, will cause some pages to skip.

Implementation Principle :

Looking for a lot of information, originally wanted to the history of IE to add the asfunction address, but found it seems impossible, in the Digi point, I know can be refreshed through the IFRAME to achieve control purposes. The process is:

    • Click a so-called link in Flash to perform an action. Some of the parameters of the state are geturl to a fixed page in the IFRAME. For example, I ordered a page1, then Geturl's address would be statistics.html?page1
    • Click a few times later, the IFRAME has actually been refreshed several times, it will enable the function of back, this time, in fact, the IFRAME has been opened a few pages, if you follow this point page1,page2,page3,page4 these four buttons, then, The IFRAME has browsed the four pages of Statistics.html?page1,statistics.html?page2,statistics.html?page3,statistics.html?page4. Final positioning in Statistics.html?page4
    • At this point IE's back button, the IFRAME will return to Statistics.html?page3. But this alone does not allow Flash to be controlled. Therefore, we need to open the statistics.html, enable a control of flash function, ie back to achieve the function. The same goes for the same reason.

Specific Practices :

1.1 Create a new flash document, Save as Index_flash.fla

1.2 Create a new MC in the document named Pagesbuttons_clip, put a button inside it, write code:

On (release) {
_parent.loadnews (_name);//This function is used for page jumps within Flash.
}

1.3 Reload a dynamic text with the variable named _name

1.4 In the home scene to put four pagesbutton_clip, respectively named Page1,page2,page3,page4

1.5 Create a new MC in the home scene named pages and put an MC with instance named Page1,page2,page3,page4 in it.

1.6 Create a mask mask in the appropriate place for the pages.

1.7 can write code below, this jump, I will let the corresponding page positioning to mask there, so that the page display, others are hidden.
The main scene is written in the frame:

var initx = mask._x;//First locates an initial point, which is the constant of the page positioning
var inity = mask._y;//ditto
var Targetx=initx;
var targety=inity;//these two variables are also used for positioning, using the Korean buffer formula algorithm to allow the MC to move slowly to (targetx,targety) this point.
This.onenterframe = function () {
pages._x = pages._x-0.2* (PAGES._X-PAGES.TARGETX);
pages._y = pages._y-0.2* (pages._y-pages.targety);
};//This is the buffer formula.
function loadnews (HREF) {//define button-triggered functions
Pages.targetx = initx-pages[href]._x;
Pages.targety = inity-pages[href]._y;//The target to the current MC (that is, the parameter href passed in), and the buffer formula will let the current incoming MC show and the others hide
Fscommand ("setaddress", href);/set address bar content, used to refresh the location of the page, in JS will respond to this command.
GetURL ("statistics.html?") +href, "stat"); Open the IFRAME and let the IFRAME record the instance name href of the MC at the current point
}

2.1 Publish an HTML file and a SWF file with Flash with Fscommand tracking, and then remove the HTML from the Format tab in the Publish settings.

2.2 With Notepad open index_flash.html file, find//place your code here a sentence. Write

if (command== "Setaddress") {
Document.location.hash=args
}

2.3 then defines a function that the onload performs js_loadnews

function Js_loadnews () {
window.open ("statistics.html?") +document.location.hash.slice (1), "stat")//Allow an IFRAME named stat to open an address with a parameter
}

2.4 According to the previous step of JS, add an IFRAME

<iframe noscroll border= "0" src= "About:blank" width= "1" height= "1" name= "stat" id= "stat" ></iframe>

2.5 add onload=js_loadnews () in the body tag

3.1 Create a new HTML file named Statistics.html, where you write code to control Flash:

<script language= "JavaScript" >
function Pageload () {
Window.parent.index_flash.setVariable ("link", Window.document.location.search.slice (1))//parent refers to the parent frame, Here you can point to the Flash file, Location.search is to get the address parameter, which contains "?", so remove it with slice (1).
}
</script>
<body onload=pageload () >
</body>

3.2 The above code set the link value in Flash, in order to trigger the Flash function, in Flash with AddProperty to trigger the relevant functions:
Append Frame code:

This.addproperty ("link", GetLink, Setlink);
function GetLink () {
}
function Setlink (link) {
Fscommand ("setaddress", link);
Pages.targetx = initx-pages[link]._x;
Pages.targety = inity-pages[link]._y;
}



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.