[FLASH LITE 2]解析XML後載入圖檔

LINEで送る
[`evernote` not found]

SOP大概是這樣

  1. 讀入名為banner.xml的檔案
  2. 從裡面找到img_path
  3. 用場景上含有mc0的空movieclip名為pic的movieclip複製後載入圖檔,並且再複製場景上的maskMC作為MASK
  4. 最後用tween做動態

不過有版本上的問題@@
還要再查一下甚麼版本以上的FLASH LITE才能做這樣的動作….

好像只有DOCOMO的FLASH LITE2.1以上的手機支援….- –
還是有人要好心的幫我測測看哩~^^”
QRimg


banner.xml:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version="1.0" encoding="UTF-8"?>
<banner_list limit="3" offset="0">
 
<banner regist_date="2008/10/28 19:06:25">
<banner_id>1</banner_id>
<img_path><![CDATA[pic/b1.jpg]]></img_path>
</banner>
 
<banner regist_date="2008/10/28 19:06:25">
<banner_id>2</banner_id>
<img_path><![CDATA[pic/b2.jpg]]></img_path>
</banner>
 
<banner regist_date="2008/10/28 19:06:25">
<banner_id>3</banner_id>
<img_path><![CDATA[pic/b3.jpg]]></img_path>
</banner>
 
<banner regist_date="2008/10/28 19:06:25">
<banner_id>4</banner_id>
<img_path><![CDATA[pic/b4.jpg]]></img_path>
</banner>
 
</banner_list>

actionscript:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "mc_tween2.as"
 
var moveTime:Number = setInterval (doMove,2000);
 
var query :String = _url.substring(_url.indexOf("?") + 1);
var domain:String = "http://xxx.jp/flash/";
var params:Array  = query.split("&");
var div   :Array  = [];
var length:Number = params.length;
var bannerNum:Number;
var bannerArr:Array;
for (var i:Number = 0; i < length; i++)
{
	div = params[i].split("=");
	_root[div[0]] = div[1];
}
 
var flooring:XML = new XML(); 
flooring.ignoreWhite = true; 
 
flooring.onLoad = function(success:Boolean) { 
	var lan:Number = flooring.firstChild.childNodes.length;
	bannerNum = lan<5? lan*2 : lan;
	for (var i = 0; i<bannerNum; i++) { 
		var j = i%2; 
		var imgurl  = domain+flooring.firstChild.childNodes[j].childNodes[1].firstChild.nodeValue; 
		var loadMC:MovieClip = pic.duplicateMovieClip("loadMC" + i, 100+i, {_x:i*60});
		loadMC.mc0.loadMovie(imgurl);
		loadMC.setMask(maskMC.duplicateMovieClip("maskMC" + i, 200+i));
	} 
} 
 
flooring.load("banner.xml"); 
 
function bannerInit(){
	for (var i = 0; i<bannerNum; i++) { 
		var loadMC:MovieClip = _level0["loadMC"+i];
		loadMC._x = i*60
	} 
}
 
function doMove(){
	if(_level0["loadMC"+(bannerNum-flooring.firstChild.childNodes.length)]._x == 0) bannerInit();
	for (var i = 0; i<bannerNum; i++) { 
		var loadMC:MovieClip = _level0["loadMC"+i];
		loadMC.tween("_x", loadMC._x-60, 0.5, "easeOutQuad");
	} 
}
 
btn1.onRelease = function(){
	getURL("/itemdetail/97121?sk="+_root["sk"]);
}
 
 
btn2.onRelease = function(){
	getURL("/sp_box_091114?sk="+_root["sk"]);
}
 
 
btn3.onRelease = function(){
	getURL("/new_item_by_daily?sk="+_root["sk"]);
}
 
 
btn4.onRelease = function(){
	getURL("/kikaku/matome?sk="+_root["sk"]);
}