当前位置:文档之家› Flash舞台随窗口大小动态调整

Flash舞台随窗口大小动态调整

//Check if we have an embed tag inside of us, if so, ignore the obj tag
if (this.containerId == null) this.containerId = ExternalInterface.objectID;
if (this.containerId == null) this.containerId = ExternalInterface.call(JSScripts.GET_FLASH_ID, stage.loaderInfo.url);
trace("BrowserCanvas - Copyright (c) 2008 Noel Billig ()");
this.stage = stage;
timerSprite = new Sprite();
_width = String( stage.stageWidth );
(erAgent.toLowerCase().indexOf("opera") != -1)) &&
(objNode.nodeName.toLowerCase() == "object") &&
(browserHacks.indexOf("uniqueId") != -1)
) {ห้องสมุดไป่ตู้
return fileName;
}
var ensureId = function(node) {
if (node.attributes["id"] == null) {
node.setAttribute("id",'swf'+new Date().getTime());
}
}
var matchesTarget = function(fullPath) {
if (browserHacks.length != 0) {
this.containerId = ExternalInterface.call(JSScripts.INSERT_BROWSER_HACKS, this.containerId, browserHacks.join(","));
}
}
public function set width(newWidth:String):void {
this._height = formatSize(newHeight);
invalidate();
}
public function set minHeight(newHeight:String):void {
this._minHeight = formatSize(newHeight);
invalidate();
public static const HACK_UNIQUE_ID:String = "uniqueId"; //If you put both an embed and object tag with the same id, this tries to compensate
private var stage:Stage;
if (matchesTarget(nodes[j].attributes["data"].nodeValue)) {
ensureId(nodes[j]);
return nodes[j].attributes["id"].nodeValue;
}
}
//Grab the param nodes out of this object, and look for one named "movie"
//If you make the mistake of naming the object and embed nodes with the same id, firefox will get confused
if (((erAgent.toLowerCase().indexOf("firefox") != -1) ||
ExternalInterface.call(JSScripts.RESIZE_CONTAINER,containerId,_width,_height,_minWidth,_minHeight,_maxWidth,_maxHeight);
}
}
}
class JSScripts {
public static var GET_FLASH_ID:XML =
var paramNodes = nodes[j].getElementsByTagName("param");
for (var k=0; k < paramNodes.length; k++) {
if (paramNodes[k].attributes["name"].nodeValue.toLowerCase() == "movie") {
}
public function set maxHeight(newHeight:String):void {
this._maxHeight = formatSize(newHeight);
invalidate();
}
private function formatSize(size:String):String {
}
public function set maxWidth(newWidth:String):void {
this._maxWidth = formatSize(newWidth);
invalidate();
}
public function set height(newHeight:String):void {
_height = String( stage.stageHeight );
if (browserHacks == null) browserHacks = [HACK_MARGIN_BOTTOM,HACK_IE_REPARENT,HACK_UNIQUE_ID];
this.containerId = containerId;
return (getFileName(fullPath) == targetSwfName);
}
var targetSwfName = getFileName(swfFullPath);
//Look through the embed nodes for one that matches our swf name
if (size == null) return ""; //Null causes opera to never clear the appropriate values, so use empty string
return (int(size) == 0) ? size : size+"px";
<script><![CDATA[
function(swfFullPath) {
var getFileName = function(fullPath) {
var ary = fullPath.split("/");
var fileName = ary[ary.length-1].split(".swf")[0];
public static var INSERT_BROWSER_HACKS:XML =
<script><![CDATA[
function (containerId,browserHacks) {
var objNode = document.getElementById(containerId);
if (objNode.nodeName.toLowerCase() == "div") return;
}
private function invalidate():void {
timerSprite.addEventListener(Event.ENTER_FRAME,update);
}
private function update(event:Event):void {
timerSprite.removeEventListener(Event.ENTER_FRAME,update);
nodes = document.getElementsByTagName("object");
for (var j=0; j < nodes.length; j++) {
//Check if the object tag has a data node
if (nodes[j].attributes["data"] != null) {
if (matchesTarget(nodes[i].attributes["src"].nodeValue)) {
ensureId(nodes[i]);
return nodes[i].attributes["id"].nodeValue;
}
}
//If we haven't found a matching embed, look through the object nodes
this._width = formatSize(newWidth);
invalidate();
}
相关主题