已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- Unit4 Interests and Abilities知识点总结及训练-2024北师大版七年级英语上册
- 2026年跨界创意合作合同
- 烟台汽车工程职业学院《跨境电商》2024-2025学年第一学期期末试卷
- 胆绞痛个案护理
- 学海大联考 2026届物理高二第一学期期末复习检测试题含解析
- 浙江同济科技职业学院《建筑力学绿色建筑评价项目》2024-2025学年第一学期期末试卷
- 新疆哈密市第十五中学2026届高一上生物期末经典模拟试题含解析
- 深圳市平湖中学2026届化学高二第一学期期末调研试题含解析
- 肾皮质化脓性感染的护理
- Unit 2 Be good friends 单元分层作业-北京版四年级英语上册
- GB/T 16825.1-2022金属材料静力单轴试验机的检验与校准第1部分:拉力和(或)压力试验机测力系统的检验与校准
- GB/T 7764-2017橡胶鉴定红外光谱法
- 石材检测报告2023
- 民事权利体系图示
- 数据中心机房应急全新预案
- 房地产估价习题与答案
- WiFi技术简介PPT课件(PPT 95页)
- GB∕T 1927.2-2021 无疵小试样木材物理力学性质试验方法 第2部分:取样方法和一般要求
- 4M变更管理程序含表格
- 城市设计(共32页)
- 全球四大管理咨询公司培训讲义打造让战略落地的人力资源系统
评论
0/150
提交评论