package com.rubenswieringa.interactivemindmap {
import flash.display.DisplayObject;
import flash.filters.BlurFilter;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import mx.flash.UIMovieClip;
public class NodeRendererBase extends UIMovieClip {
private var _transparent:Boolean = false;
private var _text:String = "";
private static const NUM_DEPTHS:uint = 5;
public function NodeRendererBase():void {
this.cacheAsBitmap = true;
// set settings for all TextFields:
var i:int;
var textField:TextField;
for (i=1; i<=NodeRendererBase.NUM_DEPTHS; i++){
textField = this.getChildByName("textField"+i) as TextField;
textField.autoSize = TextFieldAutoSize.CENTER;
}
}
public function setSkinByID (id:String):Boolean {
this.gotoAndStop(id);
if (this.currentLabel != id){
return false;
}
this.applyText();
return true;
}
public function setSkinByDepth (depth:int):Boolean {
return this.setSkinByID("depth"+depth);
}
public function get text():String {
return this._text
}
public function set text (value:String):void {
if (this._text == value){
return;
}
this._text = value;
this.applyText();
}
/**
*
*/
private function applyText():void {
var i:int;
// this method is not needed if the item-renderer is not displaying a certain depth:
if (this.currentLabel.slice(0, 5) != "depth"){
return;
}
// textField (TextField):
var textField:TextField;
for (i=1; i<=NodeRendererBase.NUM_DEPTHS; i++){
textField = this.getChildByName("textField"+i) as TextField;
if (i.toString() == this.currentLabel.slice("depth".length)){
textField.text = this._text;
}else{
textField.text = "";
}
}
// background (MovieClip):
var background:DisplayObject;
//for (i=1; i<=NodeRendererBase.NUM_DEPTHS; i++){
for (i=1; i<=NodeRendererBase.NUM_DEPTHS; i++){
background = this.getChildByName("background_mc"+i);
if (i.toString() == this.currentLabel.slice("depth".length)){
textField = this.getChildByName("textField"+i) as TextField;
background.height = textField.height + (textField.y - background.y) * 2;
}else{
background.visible = false;
}
}
}
public function setColor (index:int):void {
var background:DisplayObject = this.getChildByName("background_mc"+this.currentLabel.slice("depth".length));
background['gotoAndStop'](index);
}
public function get transparent():Boolean {
return this._transparent;
}
public function set transparent (value:Boolean):void {
if (this._transparent == value){
return;
}
this._transparent = value;
// set visuals:
var newFilters:Array = (value) ? [new BlurFilter(3, 3)] : [];
this.filters = newFilters;
}
}
}
如果我將private static const NUM_DEPTHS:uint = 5;
更改爲5以外的任何值(我試圖增加它的值),則腳本將失敗。任何投入爲什麼?actionscript問題
「失敗」是什麼意思?你看到什麼行爲? – Herms
生成的swf有一個背景,這就是它的全部!低於5的數值產生這樣的結果:0:黑色氣泡,1個白色氣泡,2:第一個氣泡可以休息,有奇怪的渲染3:4:5:同樣地畢業,但如果你超過5,一切都是空白的 – sam