zoukankan
html css js c++ java
flash读取XML 背景自动适应大小
var
bg
=
new
Object();
bg.bgdoc_xml
=
new
XML();
bg.parse_XML
=
function
()
{
function
displayXML()
{
if
(bg.bgdoc_xml
==
undefined)
{
trace(
"
..undefined
"
);
}
if
(bg.bgdoc_xml.loaded
==
false
)
{
trace(
"
loaded false
"
);
}
else
{
//
清除从 setInterval() 的调用
clearInterval(rep_int);
//
trace("BgXml Load success");
play();
}
}
bg.bgdoc_xml.ignoreWhite
=
true
;
bg.bgdoc_xml.load(
"
background.xml
"
);
bg.bgdoc_xml.onLoad
=
function
(success)
{
if
(
!
success)
{
trace(
"
background.xml false
"
);
}
else
{
//
每隔200毫秒调用displayXML
rep_int
=
setInterval(displayXML,
200
);
}
}
;
}
;
//
bg.Init
=
function
()
{
//
trace("
bg.Init");
bg.folder
=
bg.bgdoc_xml.firstChild.attributes.folder;
bg.path_array
=
new
Array();
for
(
var
i
=
0
; i
<
bg.bgdoc_xml.firstChild.childNodes.length; i
++
)
{
bg.path_array.push(bg.folder
+
bg.bgdoc_xml.firstChild.childNodes[i].attributes.url);
}
bg.nowOrder
=
random(bg.path_array.length);
bg.start
=
true
;
}
;
bg.show
=
function
()
{
//
trace("
bg.show");
if
(bg.nowOrder
==
undefined)
{
bg.nowOrder
=
0
;
}
var
bg_mc
=
_root.Content_bg;
if
(bg_mc
==
undefined)
{
gotoAndPlay(
"
Loadbg
"
);
}
else
{
bg_mc.bg_content_mc.loadMovie(bg.path_array[bg.nowOrder]);
}
}
;
bg.showPrev
=
function
()
{
_root.bg.nowOrder
--
;
if
(_root.bg.nowOrder
<
0
)
{
_root.bg.nowOrder
=
_root.bg.path_array.length
-
1
;
}
bg.show();
}
;
bg.showNext
=
function
()
{
_root.bg.nowOrder
++
;
if
(_root.bg.nowOrder
>
_root.bg.path_array.length
-
1
)
{
_root.bg.nowOrder
=
0
;
}
bg.show();
}
;
bg.Brightness
=
function
()
{
var
mark_mc
=
_root.Content_bg.bgmark_mc;
mark_mc.play();
}
;
ff
=
function
()
{
var
loader
=
_root.Loader_mc;
bg_mc.onEnterFrame
=
function
()
{
var
Total
=
this
.bg_content_mc.getBytesTotal();
var
Loaded
=
this
.bg_content_mc.getBytesLoaded();
var
percent
=
int
(Loaded
/
Total
*
100
);
loader.gotoAndStop(percent);
trace(
"
Loaded:
"
+
percent);
if
(percent
>=
100
)
{
this
.onEnterFrame
=
undefined;
if
(bg.start)
{
bg.start
=
false
;
_root.gotoAndPlay(
"
playMenu
"
);
}
}
}
;
}
;
var
bgListener
=
new
Object();
bgListener.onResize
=
function
()
{
//
trace("Stage size is now "+Stage.width+" by "+Stage.height);
resizeBg();
}
;
Stage.addListener(bgListener);
function
resizeBg()
{
var
bg_mc
=
_root.Content_bg;
var
bgWidth
=
bg_mc.bg_content_mc._width;
var
bgHeight
=
bg_mc.bg_content_mc._height;
//
scale the background to resize
var
maxScale
=
Math.max(Stage.width
*
bg_mc.bg_content_mc._xscale
/
bgWidth, Stage.height
*
bg_mc.bg_content_mc._yscale
/
bgHeight);
bg_mc.bg_content_mc._xscale
=
bg_mc.bg_content_mc._yscale
=
maxScale;
}
查看全文
相关阅读:
HTTP协议
从Iterator到async/await
那些年曾谈起的跨域
设计模式之观察者模式与发布订阅模式
移动Web深度剖析
浅析JavaScript异步
mySql入门-(二)
C# WEB项目MVC框架原理及约定
Dynamics CRM 邮箱设置 “允许使用凭据进行电子邮件处理” 被禁用的解决
Win10系统恢复IE 11浏览器
原文地址:https://www.cnblogs.com/nasa/p/687231.html
最新文章
WPF中显示GIF图片
计划任务
C#操作电脑多显示器设置
WPF使用资源图片
WPF贝塞尔曲线示例
WPF最小化窗体后激活函数显示不了窗体
WPF中Matrix介绍
Http的简单介绍
Windows账户管理
Web前端性能优化
热门文章
Mysql 修改密码及重置密码方法
Javascript面向对象之继承
Javascript起源...
JS中 escape, encodeURI 和 encodeURIComponent的区别
鼠标经过(hover)事件的延时处理
imagesLoaded图片预加载,及lazyload,scrollLoading延迟加载介绍
瀑布流布局实现总结
CentOS6.4安装包初识
Sequelize手记
前端攻城狮应该了解的交互
Copyright © 2011-2022 走看看