惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hacker News - Newest:
Hacker News - Newest: "LLM"
U
Unit 42
月光博客
月光博客
T
The Blog of Author Tim Ferriss
Jina AI
Jina AI
Microsoft Azure Blog
Microsoft Azure Blog
有赞技术团队
有赞技术团队
P
Proofpoint News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
Vercel News
Vercel News
博客园 - 三生石上(FineUI控件)
美团技术团队
D
Docker
大猫的无限游戏
大猫的无限游戏
人人都是产品经理
人人都是产品经理
J
Java Code Geeks
Google DeepMind News
Google DeepMind News
博客园 - 司徒正美
The Cloudflare Blog
博客园 - 叶小钗
M
MIT News - Artificial intelligence
AI
AI
Security Archives - TechRepublic
Security Archives - TechRepublic
The Register - Security
The Register - Security
C
Cybersecurity and Infrastructure Security Agency CISA
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
宝玉的分享
宝玉的分享
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Security Latest
Security Latest
Recorded Future
Recorded Future
Cloudbric
Cloudbric
K
Kaspersky official blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
V
Visual Studio Blog
Apple Machine Learning Research
Apple Machine Learning Research
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
博客园_首页
T
Threat Research - Cisco Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Last Week in AI
Last Week in AI
I
Intezer
The Hacker News
The Hacker News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hacker News: Front Page
Attack and Defense Labs
Attack and Defense Labs
MongoDB | Blog
MongoDB | Blog
O
OpenAI News
Hacker News: Ask HN
Hacker News: Ask HN
WordPress大学
WordPress大学
Project Zero
Project Zero

博客园 - HelloSnoopy

写了个用一个文件定义样式的DataGrid 一个最基本的WebService+Flash调用的实例 [转载]如何奔向程序员打工的出头之日? 一定要讲给孩子们的20个小故事 人脉对职业生涯最重要 (转) 爱情的10种样子,送给懂爱的朋友们 装了Enterprise Library.NET 200501release C#判断是否为数字的最好速度! 开源的 BugTracker.net 错误跟踪管理系统 Enjoy new year of 2005! 设计模式随笔-让众口不再难调 CodeSmith使用心得 [专题]MVC构架模式 使用Microsoft Application Block之Cache Application 用一条SQL完成数据表的行统计 如何使IFrame的长宽与内容自动适应大小 为Project提供一个统一风格的DataGrid 用于读取树形任一节点下所有级别子节点的SqlServer UDF asp.net forums中定时器的应用
Flash AS2 用EventDispatcher广播事件
HelloSnoopy · 2004-12-28 · via 博客园 - HelloSnoopy
Flash AS2 用EventDispatcher广播事件

Product.as文件

import USStore.Model.ProductInfo;
class USStore.BusinessObj.Product
{
    public 
var addEventListener:Function;
    public 
var removeEventListener:Function;
    private 
var dispatchEvent:Function;
    
    public 
function Product() 
    {
        mx.events.EventDispatcher.initialize(
this);
    }
    public function GetProductsByCategoryID(categoryID:Number):Void 
    {
        
var xml:XML = new XML();
        xml.ignoreWhite 
= true;
        xml.load("data/products.xml");
        
var self = this;
        xml.onLoad 
= function(suc) 
        {
            
if(suc) 
            {
                
//产品集合
                var items:Array = new Array();
                
var nodes = this.firstChild.childNodes;
                
for(var i:Number=0; i<nodes.length; i++
                {
                    
var pobj:ProductInfo = new ProductInfo();
                    pobj.ProductID        
= parseInt(nodes[i].attributes.productID);
                    pobj.CategoryID        
= parseInt(nodes[i].attributes.categoryID);
                    pobj.ProductName    
= nodes[i].attributes.productName;
                    pobj.Brief            
= nodes[i].attributes.brief;
                    pobj.Detail            
= nodes[i].attributes.detail;
                    pobj.Image            
= nodes[i].attributes.image;
                    pobj.Price            
= parseInt(nodes[i].attributes.price);
                    pobj.AddDate        
= nodes[i].attributes.marketDate;
                    items[i] 
= pobj;
                    
//trace(pobj.ProductName);
                }
                //广播产品加载成功事件
                var eventObj:Object    = {target:self,type:"Loaded",args:items};
                self.dispatchEvent(eventObj);
            } 
else {
                getURL(
"ErrorPage.htm");
            }
        };
    }
}

fla文件上的as:

stop();
_global.Product 
= new USStore.BusinessObj.Product();
var loadObj:Object = new Object();
loadObj.Loaded 
= function(eventObj)
{
    
var items:Array = eventObj.args;
    
for(var i=0;i<items.length;i++)
    {
        _root.txtShow.text 
+= items[i].ProductName;
    }
};
_global.Product.addEventListener(
"Loaded",loadObj);
_global.Product.GetProductsByCategoryID();

posted on 2004-12-28 20:39  HelloSnoopy  阅读(705)  评论(0)    收藏  举报