Flash value transfer

Source: Internet
Author: User

A work that was a long time ago, the customer recently said that he would like to replace the effect of an image rotation made by javascript on the previous homepage with the effect of an image rotation similar to that of sina sports.

As a result, there is a search on the Internet. The excerpt is as follows:

Step 1: first download the flash image player. Http://news.ccidnet.com/images/swf/pixviewer.swf

Step 2: place the following code where you want to display it.
But there are several places to modify. Pixviewer.swf path, image address, link webpage

<Script type = "text/javascript">
<! --

Var focus_width = 260
Var focus_height = 210
Var swf_height = focus_height

Var pics = 'pic/1.jpg | pic/2.jpg | pic/3.jpg | pic/4.jpg '// image address (relative path)

Var links='1.htm | 2.htm | 3.htm | 4.htm '// (link webpage)

Document. write ('<object classid = "clsid: d27cdb6e-ae6d-11cf-96b8-444553540000" codebase = "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width = "' + focus_width + '" height = "' + swf_height + '"> ');
Document. write ('<param name = "allowScriptAccess" value = "sameDomain"> <param name = "movie" value = "pixviewer.swf"> <param name = "quality" value = "high "> <param name =" bgcolor "value =" # F0F0F0 "> ');
Document. write ('<param name = "menu" value = "false"> <param name = wmode value = "opaque"> ');
Document. write ('<param name = "FlashVars" value = "pics =' + pics + '& links =' + links + '& borderwidth =' + focus_width + '& borderheight =' + focus_height + '"> ');
Document. write ('<embed src = "pixviewer.swf" wmode = "opaque" FlashVars = "pics =' + pics + '& links =' + links + '& borderwidth =' + focus_width + '& borderheight =' + focus_height + '"menu =" false "bgcolor =" # F0F0F0 "quality =" high "width ="' + focus_width + '"height ="' + swf_height + '"allowScriptAccess =" sameDomain "type =" application/x-shockwave-flash "pluginspage =" http://www.macromedia.com/go/getflashplayer "/> '); document. write ('</object> ');

// -->
</Script>

So implement my code:

If (! Page. IsPostBack)
{

TList <Dlbj_xw> myxw = DataRepository. Equals (5, "xw_id desc", "xw_pic_path is not null and xw_ssfl = '" + (int) Ignore. Important news + "'");
String htmlstring = @ "<SCRIPT type = text/javascript>
<! --
Var focus_width = 300
Var focus_height = 225
Var text_height = 25
Var swf_height = focus_height + text_height

Var pics = '";

String pics = "";
String texts = "";
String urls = "";
Foreach (Dlbj_xw thexw in myxw)
{

Char [] charSeparators = new char [] {'/'};
Pics + = "uploadfiles/xw/images/" + thexw. Xw_pic_path.Split (charSeparators, StringSplitOptions. RemoveEmptyEntries) [0] + "| ";
Texts + = CutString. cutstring (thexw. Xw_title, 25) + "| ";
Urls + = "view_news_inde.aspx? Id = "+ thexw. Xw_id +" & amp; xwlb = 1 | ";

}
Pics = pics. Substring (0, pics. Length-1 );
Texts = texts. Substring (0, texts. Length-1 );
Urls = urls. Substring (0, urls. Length-1 );

Htmlstring + = pics + "'\ n ";
Htmlstring + = "var links = '" + urls + "' \ n ";
Htmlstring + = "var texts = '" + texts + "' \ n ";
Htmlstring + = "document. write ('<object classid = \ "clsid: d27cdb6e-ae6d-11cf-96b8-444553540000 \ "codebase = \" prop "name = \" flashpic \ "id = \" flashpic \ "width = \" '+ focus_width +' \ "height = \" '+ swf_height + '\ "> '); ";

Htmlstring + = "document. write ('<param name = \ "allowScriptAccess \" value = \ "sameDomain \"> <param name = \ "movie \" value = \ "pixviewer.swf \"> <param name = \ "quality \" value = \ "high \"> <param name = \ "bgcolor \" value = \ "# DADADA \"> '); ";
Htmlstring + = "document. write ('<param name = \ "menu \" value = \ "false \"> <param name = wmode value = \ "opaque \"> ');";
Htmlstring + = "document. write ('<param name = \ "FlashVars \" value = \ "pics =' + pics + '& texts =' + texts + '& borderwidth =' + focus_width + '& borderheight = '+ focus_height +' & textheight = '+ text_height +' \ "> '); ";
Htmlstring + = "document. write ('<embed src = \ "pixviewer.swf \" wmode = \ "opaque \" FlashVars = \ "pics =' + pics + '& links =' + links + '& texts = '+ texts +' & borderwidth = '+ focus_width +' & borderheight = '+ focus_height +' & textheight = '+ text_height +' \ "menu = \" false \ "bgcolor = \ "# DADADA \" quality = \ "high \" width = \ "'+ focus_width +' \" height = \ "'+ swf_height +' \" allowScriptAccess = \" sameDomain \ "type = \" application/x-shockwave-flash \ "pluginspage = \" http://www.macromedia.com/go/getflashplayer\ "/> '); ";
Htmlstring + = "document. write ('</object> ');";
Htmlstring + = "// --> ";
Htmlstring + = "</SCRIPT> ";
Literal1.Text = htmlstring;

}

Test and find that the effect is good. Click the mouse and find that there is a link problem. For analysis, it is mainly because the link address in the variable links contains the "&" symbol when the parameters are passed through FlashVars, so there are some deviations. So I tried other methods of passing values.

We can find that it can be found in src = "xxx.swf? Links = "is used in the same way, but an error is also generated when" & "is passed in.

Finally, modify the code and use javascript to pass parameters to flash.

After the code is modified, add the following code:

Htmlstring + = "invalid variable Doc ument. flashpic. SetVariable (\" links \ ", links );";

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.