理智地、负责任地、透明地推广Firefox
您可能也对这些感兴趣
切换

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

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

注释用英文写的,总觉着代码里头加点中文有点别扭。:)呵呵
最终效果可以见 http://www.awflasher.com的2005版

第一部分:负责设置按钮事件,大家可以讨论、切磋一下逻辑事件的设置,事件的(伪)重载等等
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");
};[/quote]第二部分:这一部分负责调度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
    };
  }
}

: http://www.awflasher.com/blog/archives/132

哇!跟我一样,您也是一名Firefox用户,这些话题您可能感兴趣:

RSS feed | Trackback URI

才 4 条评论 ( 展开所有评论 | 收起所有评论 ) 立刻发表评论 »

堂吉柯德
2005-03-30 21:06:00

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

aw
2005-03-30 21:17:48

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

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%";

aw
2005-04-06 11:35:28

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

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