




已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
本文介绍如何建立一个舞台随窗体尺寸大小动态改变的Flash例子,使用的脚本为AS3.01. 建立工程2. 新建一个AS文件,主要实现舞台的动态缩放功能代码如下:package import flash.display.Sprite;import flash.display.Stage;import flash.events.Event;import flash.external.ExternalInterface;public class BrowserCanvas public static const HACK_MARGIN_BOTTOM:String = marginBottom; /Adds a negative bottom margin to object tags to compensate for browser weirdnesspublic static const HACK_IE_REPARENT:String = IEReparent; /In IE, create a container div which encapsulates the object tag in order to hav min/max sizes workpublic static const HACK_UNIQUE_ID:String = uniqueId; /If you put both an embed and object tag with the same id, this tries to compensateprivate var stage:Stage;private var containerId:String;private var _width:String;private var _minWidth:String;private var _maxWidth:String;private var _height:String;private var _minHeight:String;private var _maxHeight:String;private var timerSprite:Sprite;public function BrowserCanvas ( stage:Stage,containerId:String=null , browserHacks:Array=null ) trace(BrowserCanvas - Copyright (c) 2008 Noel Billig ();this.stage = stage;timerSprite = new Sprite();_width = String( stage.stageWidth );_height = String( stage.stageHeight );if (browserHacks = null) browserHacks = HACK_MARGIN_BOTTOM,HACK_IE_REPARENT,HACK_UNIQUE_ID;this.containerId = containerId;if (this.containerId = null) this.containerId = ExternalInterface.objectID;if (this.containerId = null) this.containerId = ExternalInterface.call(JSScripts.GET_FLASH_ID, stage.loaderInfo.url);if (browserHacks.length != 0) this.containerId = ExternalInterface.call(JSScripts.INSERT_BROWSER_HACKS, this.containerId, browserHacks.join(,);public function set width(newWidth:String):void this._width = formatSize(newWidth);invalidate();public function set minWidth(newWidth:String):void this._minWidth = formatSize(newWidth);invalidate();public function set maxWidth(newWidth:String):void this._maxWidth = formatSize(newWidth);invalidate();public function set height(newHeight:String):void this._height = formatSize(newHeight);invalidate();public function set minHeight(newHeight:String):void this._minHeight = formatSize(newHeight);invalidate();public function set maxHeight(newHeight:String):void this._maxHeight = formatSize(newHeight);invalidate();private function formatSize(size:String):String if (size = null) return ; /Null causes opera to never clear the appropriate values, so use empty stringreturn (int(size) = 0) ? size : size+px;private function invalidate():void timerSprite.addEventListener(Event.ENTER_FRAME,update);private function update(event:Event):void timerSprite.removeEventListener(Event.ENTER_FRAME,update);ExternalInterface.call(JSScripts.RESIZE_CONTAINER,containerId,_width,_height,_minWidth,_minHeight,_maxWidth,_maxHeight);class JSScripts public static var GET_FLASH_ID:XML = !CDATAfunction(swfFullPath) var getFileName = function(fullPath) var ary = fullPath.split(/);var fileName = aryary.length-1.split(.swf)0;return fileName;var ensureId = function(node) if (node.attributesid = null) node.setAttribute(id,swf+new Date().getTime();var matchesTarget = function(fullPath) return (getFileName(fullPath) = targetSwfName);var targetSwfName = getFileName(swfFullPath);/Look through the embed nodes for one that matches our swf namevar nodes = document.getElementsByTagName(embed);for (var i=0; i nodes.length; i+) /Parse just the SWF file name out of the whole src path and check if it matchesif (matchesTarget(nodesi.attributessrc.nodeValue) ensureId(nodesi);return nodesi.attributesid.nodeValue;/If we havent found a matching embed, look through the object nodesnodes = document.getElementsByTagName(object);for (var j=0; j nodes.length; j+) /Check if the object tag has a data nodeif (nodesj.attributesdata != null) if (matchesTarget(nodesj.attributesdata.nodeValue) ensureId(nodesj);return nodesj.attributesid.nodeValue;/Grab the param nodes out of this object, and look for one named movievar paramNodes = nodesj.getElementsByTagName(param);for (var k=0; k ;public static var INSERT_BROWSER_HACKS:XML = ;public static var RESIZE_CONTAINER:XML = ;3. 建立Flash文件场景相关的类package import flash.display.Sprite;import flash.display.StageAlign;import flash.display.StageScaleMode;import flash.events.Event;import flash.events.MouseEvent;import flash.text.TextField;import flash.text.TextFormat;/导入第2节中建立的类import BrowserCanvas;SWF(width=550, height=400, frameRate=30, backgroundColor=#000000) public class ResizeSceneClass extends Sprite private var canvas:BrowserCanvas;public function ResizeSceneClass () /Set up the stage so we dont scale (you may not want to do this, depending on your desired goal)stage.align = StageAlign.TOP_LEFT;stage.scaleMode = StageScaleMode.NO_SCALE;canvas = new BrowserCanv
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 岳阳市中储粮2025秋招笔试模拟题及答案
- 内江市中石油2025秋招笔试性格测评专练题库及答案
- 中国广电嘉兴市2025秋招心理测评常考题型与答题技巧
- 绥化市中石油2025秋招笔试提升练习题含答案
- 郴州市中石油2025秋招心理测评常考题型与答题技巧
- 毕节市中石化2025秋招笔试模拟题含答案油气储运与管道岗
- 国家能源昌都市2025秋招面试专业追问及参考计算机与自动化岗位
- 三门峡市中石油2025秋招笔试模拟题含答案炼油设备技术岗
- 邯郸市中石油2025秋招笔试模拟题含答案炼油设备技术岗
- 平顶山市中石化2025秋招面试半结构化模拟题及答案油品分析质检岗
- 路灯施工安全责任协议书
- 沪科版七年级上册初一数学全册教案(教学设计)
- 防止电力生产事故25项反措地重点要求最终版
- 第2章-信息可视化设计的概念、原则与类型60课件
- 日本蜡烛图技术完整版
- 崇义县凌志矿冶有限责任公司过埠铁木里铁矿(新增资源)采矿权出让收益评估报告
- 大学学生违纪处罚办法
- 癌痛规范化治疗课件资料
- 牛津9AU3-Head-to-head名师制作优质教学课件
- 深信服SDWAN产品介绍
- 雨露计划职业教育补助-学籍证明-模板四川优秀资料
评论
0/150
提交评论