正在加载...

Flash中如何用asp、XML读取Blog中的信息。

我自己的成果,由于我也是刚刚接触这部分的技术,高手多多批评,新人多多学习:)

注释用英文写的,总觉着代码里头加点中文有点别扭。:)呵呵

第一部分:负责设置按钮事件,大家可以讨论、切磋一下逻辑事件的设置,事件的(伪)重载等等
aw注:所谓“(伪)重载”是我自己构造的一个概念,其实就是在某一个事件发生后,重定义另一个出发事件。

stop();
// Let the Timeline stop
#include “mc_tween2.as”
// use the Tween Prototype , special thanks to www.moock.org
textBlog.onRollOver = function() {
this.tagb.tag.colorTo(0xffffff, 0.5, “linear”);
//use colorTo of “tween Prototype” to define the Buttons Events_Style;
};
textBlog.onRollOut = flashBlog.onRollOut=function () {
this.tagb.tag.colorTo(null, 0.5);
// use colorTo of “tween Prototype” to define the Buttons Events_Style;
};
textBlog.onRelease = function() {
//—HINT——-Here is the begin

onRelease ———////////////////
//test If the UIFranme_MC exists
//trace(UIFrame_MC);
if (UIFrame_MC != undefined) {
UIFrame_MC.buttom_Bar.gotoAndPlay(1);
//If the Buttom_bar does exist , and we the user is visiting the “textBlog” , let it out
}
choice = true;
//the Boolen typed-var ‘choice’ stands for the user are visiting the “textBlog”(True) or “flashBlog”(False)
this._parent.flashBlog.tagb.tag.colorTo(null, 0.5);
this.onRollOut = this.onReleaseOutside=function () {
this.tagb.tag.colorTo(0xffffff, 0.5, “linear”);
// when onRelease(d) , the button should not be fade/disable.
};
this._parent.flashBlog.onRollOut = this._parent.flashBlog.onReleaseOutside=function () {
this.tagb.tag.colorTo(null, 0.5);
};
this.tween([“_x”, “_y”, “_xscale”, “_yscale”], [60, 300, 60, 60], 1);
//make the button move to its own place
this._parent.flashBlog.tween([“_x”, “_y”, “_xscale”, “_yscale”], [100, 440, 50, 50], 1);
//make the other button move to its own place
this._parent.gotoAndStop(“textBlog”);
//—HINT——-Here is the end of onRelease ———////////////////
};
//Here is the action for the 2nd button ^_^
flashBlog.onRollOver = function() {
this.tagb.tag.colorTo(0xffffff, 0.5, “linear”);
};
flashBlog.onRollOut = flashBlog.onReleaseOutside=function () {
this.tagb.tag.colorTo(null, 0.5);
};
flashBlog.onRelease = function() {
//test If the UIFranme_MC exists
//trace(UIFrame_MC);
if (UIFrame_MC != undefined) {
UIFrame_MC.buttom_Bar.gotoAndPlay(“startHide”);
//If the Buttom_bar does exist , and we the user is visiting the “flashBlog” , kill it(for it is for the “textBlog”
}
choice = false;
//the Boolen typed-var ‘choice’ stands for the user are visiting the “textBlog”(True) or “flashBlog”(False)
this._parent.textBlog.tagb.tag.colorTo(null, 0.5);
this.onRollOut = this.onReleaseOutside=function () {
this.tagb.tag.colorTo(0xffffff, 0.5, “linear”);
};
this._parent.textBlog.onRollOut = this._parent.textBlog.onReleaseOutside=function () {
this.tagb.tag.colorTo(null, 0.5);
};
this.tween([“_x”, “_y”, “_xscale”, “_yscale”], [60, 300, 60, 60], 1);
//make the button move to its own place
this._parent.textBlog.tween([“_x”, “_y”, “_xscale”, “_yscale”], [100, 440, 50, 50], 1);
//make the other button move to its own place
this._parent.gotoAndStop(“flashBlog”);
};

第二部分:这一部分负责调度XML,我刻意加入了一个缓冲loading效果

stop();
// Make the timeline stop
loader.onLoad = function() {
this._width = 0;
};
loader._width = 0;
//preset the loader-bar to 0(for we didn’t start loading XML yet ^_^)
per = “0%”;
//per is the hint-text
hintText.text = “Connecting…”;
//Now we are gonna connect the XML source
linkArray = new Array();
titleArray = new Array();
catelogArray = new Array();
pubDateArray = new Array();
//We are using the four arrays to store the XML data
myXml = new XML();
myXml.ignoreWhite = true;
myXml.load(“http://www.awflasher.com/blog/awrss.asp“);
//get our XML now
this.createEmptyMovieClip(“tracer”, 888);
//the temp-MC is used to trace the loading-presentage
tracer.onEnterFrame = function() {
picGL = 100*myXml.getBytesLoaded()/myXml.getBytesTotal();
//use an onEnterFrame to check the precentage
};
myXml.onLoad = function(success) {
if (success) {
loader.onEnterFrame = function() {
//—–Here begin our detecting (of progress)——-
//
this._width += (this._parent.picGL-this._width)/2;
// make a smooth loading to let the user know something^.^
per = this._width+”%”;
var logA:Boolean = (this._parent.picGL == 100);
//if Loaded, logA is true
if (logA && this._width>99) {
// only By detecting the width of loading-bar is not enough , we need to detect the “logA”
per = “100%”;
this._width = 100;
//make them ok
hintText.text = “Loaded”;
delete tracer.onEnterFrame;
delete this.onEnterFrame;
//delete the 2 onEnterFrames in order to cancel the memories they applied.
} else {
hintText.text = “Receiving data”;
}
//—–Here end our detecting (of progress)——-
};
loadXml();
//now , parse our XML
} else {
hintText.text = “Connecting…”;
// if not ready , still connecting :(
}
};
getBlogItem = new Array();
getLink = new Array();
getTitle = new Array();
getCatelog = new Array();
getPubDate = new Array();
function loadXml() {
for (var itemID = 0; itemID<10; itemID++) {
// This is my-modified-RSS-tree, not the usual RSS//
// Now we are getting the information into the arrays//
getBlogItem[itemID] = myXml.childNodes[0].childNodes[itemID];
getLink[itemID] = getBlogItem[itemID].childNodes[0].childNodes[0];
getTitle[itemID] = getBlogItem[itemID].childNodes[1].childNodes[0];
getCatelog[itemID] = getBlogItem[itemID].childNodes[2].childNodes[0];
getPubDate[itemID] = getBlogItem[itemID].childNodes[3].childNodes[0];
var BCnm = “BlowCate_txt”+itemID;
var BTnm = “BlowTitle_txt”+itemID;
var BPnm = “BlowPT_txt”+itemID;
var LKnm = “BlowPT_mc”+itemID;
this.textBlog_mc[BCnm].text = getCatelog[itemID];
this.textBlog_mc[BTnm].text = getTitle[itemID];
this.textBlog_mc[BPnm].text = getPubDate[itemID];
this[LKnm].awct.awlk = this.getLink[itemID];
this[LKnm].awct.onRelease = function() {
getURL(this.awlk, “_blank”);
aaab.text = this.awlk;
// set the link
};
}
}

还没找到您要的东西?Google试试看吧,
Google更注重原创、时效性好的文章:


本文相关评论: 才 4 条评论
  1. 堂吉柯德 2005-03-30 09:06:00

    我来学习。还是中文好,看e文有点晕,不过正在强迫自己不晕。大概看了一下,不过还是不明白逻辑事件指的是?

  2. aw 2005-03-30 09:17:48

    主要就是按钮的一些响应,xml的响应.等等

  3. N神 2005-04-06 10:35:36

    没仔细看, 这个错了吧,onload好象是加载完了才触发
    myXml.onLoad = function(success) {
    if (success) {
    loader.onEnterFrame = function() {
    //—–Here begin our detecting (of progress)——-
    //
    this._width += (this._parent.picGL-this._width)/2;
    // make a smooth loading to let the user know something^.^
    per = this._width+"%";
    var logA:Boolean = (this._parent.picGL == 100);
    //if Loaded, logA is true
    if (logA && this._width>99) {
    // only By detecting the width of loading-bar is not enough , we need to detect the "logA"
    per = "100%";

  4. aw 2005-04-06 11:35:28

    容我下午去办公室看看。。。。

    关于xml的加载 我的确不熟悉,多谢n兄弟提醒,哈哈!!

[支持Ctrl+Enter]为了我们大家和家人的安全,留言请慎重!
声明:
1、本站仅与见过面的个人博客交换链接,见此文
2、留言时的头像是Gravatar提供的服务。如果您有兴趣并且有闲暇时间,可以看看这里的介绍