web base 吴志华

27
WebBase Flash 基基 IE 基基基基 基基基 /2010-7-24

Upload: flash

Post on 22-Apr-2015

2.589 views

Category:

Education


6 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Web base 吴志华

WebBaseFlash 基于 IE 开发框架

望月狼 /2010-7-24

Page 2: Web base 吴志华

WebBase 采用模块式开发概念,处理多模块协作

问题保持各模块的依赖关系,追求项目与 IE 的溶合,是

应用于 Flash 或 FlashBuilder 开发 web 项目的开源框架。

Page 3: Web base 吴志华
Page 4: Web base 吴志华

简 单

自 由

高 效

稳 定

WebBaseFlash 基于 IE 的应用

Page 5: Web base 吴志华

1 . 纯 AS 开发高手,用于 WEB 应用项目 , 实现模块式的开发。2 . 喜欢靠 AS2 的自由性开发 Flash 全站或善未完成 AS3 技术蜕变的人。3 . 工作喜欢“偷懒”又追求原创与细节的设计师。4 . Flash 艺术高手并略懂 AS 编程的技术贵族。

Page 6: Web base 吴志华

WebBase 能做什么?01 . 快速地实现模块建立与调用。02 . 可以轻松地实现伪地址与标题 。03 . 支持状态值的记录管理。 04 . 很方便地实现更换页面时的过渡动画。05 . 垃圾回收机制。 06 . Flash 基于 IE 的尺寸控制与自适应能力。07 . 互访功能。08 . IE 控制能力。 09 . 基于 IE 的 DeBug 功能。10 . 辅助工具。

Page 7: Web base 吴志华

框 架 原 理

Page 8: Web base 吴志华

继承与可扩展基类

Page 9: Web base 吴志华

◎ 页面调入与模块加载

Page 10: Web base 吴志华

openPage 页面调入方法

openPage(path:String, target:String = "blank", usePlayEnd:Boolean = false, waitTime:uint = 0):void @param path 要打开的页面,使用 XML 菜单中的 ID 值@param target 加载的目标,值可以是 BLANK,TOP,PARENT@param usePlayEnd 使用尾动画@param waitTime 旧 SWF 移除后可能还要等待别的动画执行完毕再加载新的 SWF

◎ 页面调入与模块加载

Example:openPage("about",BLANK,true);addEventListener(LoadSwfEvent.PROGRESS,childProgress )// 子页加载进度addEventListener(ParentEvent.ADD_CHILD, addSwfFile);// 子 SWF 被添加载舞台时触发事件function childProgress(event:LoadSwfEvent):void {

var getPct:uint = event.bytesPct; trace(getPct+ " %")}function addSwfFile(event:ParentEvent):void {

addChild(event.loader);}

Page 11: Web base 吴志华

◎ 页面调入与模块加载loadModule 模块加载方法

Example:

var module:IloadInfo=loadModule("childModule.swf")module.addEventListener(LoadModuleEvent.COMPLETE,loadComplete)function loadComplete(e:LoadModuleEvent):void{

var pb:ParentBase = e.module as ParentBase;}

Page 12: Web base 吴志华

getURL(url:String,window:String=null):void @param url     链接网址@param window 浏览器窗口,可以指定窗口也可以是已命名的窗口

可用值:“ _self”、“ _blank“、” _parent”、 "_top"

navigateToURL(new URLRequest("www.xxx.com"))

◎ 页面调入与模块加载getURL 打开页面

Page 13: Web base 吴志华

<data> <menu height="600" title="About us" id="about" file="about.swf" /> <menu height="900" title="My project" id="project" file="work.swf" /> <menu height="700" title="News&Message" id="blog" file="news.swf" /> <menu height="600" title="Contact" id="contact" file="guestbook.swf" /></data>

XML 菜单配置

Page 14: Web base 吴志华

package com.webBaseDemo {

import com.webBase.ParentBase;import com.webBase.event.ParentEvent;import flash.display.Loader;public class Main extends ParentBase{

public function Main() { this.addEventListener(ParentEvent.ADD_CHILD, addSwfFile);}private function addSwfFile(event:ParentEvent):void {

var loader:Loader = event.loaderthis.addChild(loader);

}}

}

Index code:

Page 15: Web base 吴志华

◎ 建立页面过渡动画

Page 16: Web base 吴志华

◎ 建立页面过渡动画

this.addEventListener(ChildEvent.END_PLAY, startPlay)// 开始播放结束动画private function startPlay(value:ChildEvent):void {

mc.gotoAndPlay("end");}

[ 演示 ]

Page 17: Web base 吴志华

◎ 互访功能

a.swf => public function setValue(str:String):void { };b.swf => var acode:ACode = parentPage as ACode;

acode.setValue("abc")

Page 18: Web base 吴志华

◎ DeBug 能力

1.traceWin(value:Object):void2.JSAlert(script:Object):void 3.debugMode:Boolean [read-write] Example: traceWin(1+1) traceWin(this)Example: JSAlert("abc")

Page 19: Web base 吴志华

◎ 伪地址与状态值

伪地址: http://localhost/webbase/#/about/tag2采用多个SWF来实现某一种交互时使用

状态值: http://localhost/webbase/#/about-tag2 [演示]采用一个SWF来实现不同模块的交互时使用

Page 20: Web base 吴志华

Example1: openPage("about");

◎ 伪地址与状态值

Example2: addState(value:String); delState(value:String); clearState();

addEventListener(StateEvent.GET_STATE, getParamStates)function getParamStates(event:StateEvent):void {

traceWin(event.states[0]);}

Page 21: Web base 吴志华

◎ 工具包

Page 22: Web base 吴志华

◎ 工具包

control.addFavorite(url:String="",title:String="")// 加入收藏夹,可兼容不同浏览器

control.fullScreen(intoCallBack:Function,exitCallBack:Function)

Example:control.fullScreen(intoFun,exitFun)function intoFun():void{

traceWin(" 进入全屏模式 ")}function exitFun():void{

traceWin("退出全屏模式 ")}

Page 23: Web base 吴志华

control.frameScript(mc:MovieClip,frame:Object,callBack:Function):void//在帧上添加代码Example:control.frameScript(mc, "end", callFun)function callFun():void {

//Your code}

effect.buttonEffect(target:DisplayObject,changeTarget:DisplayObject,obj:Object):void//对象过渡效果,当鼠标滑入滑出某一显示对象时产生过渡变化Example:buttonEffect(butMc,butMc.bg,{startColor: 0xC29C6A, overColor:0xC29C6A});

◎ 工具包

net.loadBg(filePath:String,width:uint,height:uint,mode:String="matrix")加载背景图片 ,格式为 jpg,png 或 gif图片@param filePath 图片路径@param width 背景宽@param height 背景高@param mode 显示模式:matrix:矩阵平埔 (默认 ) , stretch:拉伸 ,center:居中

Page 24: Web base 吴志华

◎ 工具包

net.loadXML(filePath:String,callback:Function,gbCode:Boolean,useXML:Boolean):URLLoaderXML 或者 txt文件加载@param filePath 文件路径@param callback 回调函数 ,如果加载 XML,函数参数为 XML,如 function getXML(xml:XML)@param gbCode 是否使用中文编码 ,默认是@param useXML 是否返回 XML格式 ,默认是

loadFile(filePath:String, callback:Function = null):Loader// 加载外部文件, jpg,png,gif图片及 SWF文件

Page 25: Web base 吴志华

net.bgSound():BgSound

Example:net.bgSound.path = "webbase/config/music.mp3";// 设置背景音乐net.bgSound.soundEffect = true;// 是否使用声音缓入缓出效果net.bgSound.volume = 30;//音量, 0-100net.bgSound.play();// 开始播放net.bgSound.stop();//声音停止

◎ 工具包

Page 26: Web base 吴志华

◎ 工具包

位图文字转换style.bitmapFont(sourceTxt:TextField,

showText:String,txtFormat:TextFormat,wid:Number,sharp:Boolean) :Sprite

@param sourceTxt 文字模板@param showText 显示文字@param txtFormat 文本样式@param wid 强制宽度@param sharp 是否使用未消除锯齿功能Example:var txtFormat:TextFormat = new TextFormat("隶书 ",15,0x990000);var bf:Sprite = new BitmapFont(textExalpme,"测试文本 abcdefg",txtFormat);addChild(bf)

Page 27: Web base 吴志华

应 用 演 示