flex cairngorm项目实战


  项目功能与界面模仿阿布网站
  系统功能:
  新闻管理 用户管理 日记管理 留言管理
  实践步骤:
  1 数据库表的建立
  2 包及类的构建
  3 界面的搭建
  4 flex端代码的编写
  5 php端代码的编写
  6 集成测试
  com.peter.tl
  ----------------business
  ----------------command 处理请求php端资源的动作
  -------------------GetNewCommand.as
  ----------------controls  处理事件转发功能
  -------------------mainControl.as
  ----------------events 定义网站所有发生事件
  -------------------ControlEvent.as 
  ----------------model vo检索功能
  -------------------MainModelLocator.as
  ----------------view 存放视图
  -------------------news.mxml
  ----------------vo 存放bean
  -------------------Vonews.as
  com.peter.net
  ---------------- GetUrl.as 
  com.kingnare 存放样式组件
  component 
  ----------------H_News.mxml
  ----------------H_Dairy.mxml
  img
  style 
  style.css
  swf
  main.mxml
  doc
  ----------------sql脚本
  注意在搭建界面的时候最好从里到外,从小到大
  1 数据库表
  admin
  uid user password
  dairy
  uid D_title D_content D_date D_author D_time
  guestbook
  uid db_title db_name db_content db_qq db_email  url_img nowtime reply
  news
  uid news_title news_content news_time
  关键代码:
  mainControl.as
  extends FrontController addCommand(ControlEvent.GETNEWS,GetNewsCommand);
  ControlEvent.as
  extends CairngormEvent
  public static var GETNEWS:String = "获取新闻数据";
  MainModelLocator.as extends ModelLocator [Bindable]         public var vo_news:VOnews = new VOnews();  getInstance():MainModelLocator GetNewsCommand.as implements Command 连接php端
  Connect = new NetConnection();  Connect.connect(urlStr);//http://localhost/amfphp/gateway.php  Connect.call("php.H_News.getAll",new Responder(onResult,onFault));  function onResult(result:Object):void{  var rs:Array = result as Array;  MainModelLocator.getInstance().vo_news.n_data = rs; //php返回值  getNews.complete();//通知view端更新 }
  function onFault(fault:Object):void
  VOnews.as
  变量命名规则: 表名首字母_表字段
  public var n_data:Array; //存放所有新闻数据
  public var n_title:String;
  news.mxml模板 上:界面元素 下:脚本
  引用其他包中资源,统一以包名+s
  xmlns:controls="com.adobe.cairngorm.control.*"
  导入项目必要素材
  img style

猜你喜欢

转载自lxn014wg.iteye.com/blog/1573650