我很快就需要一個假髮來取代我已經撕掉這個問題的頭髮!我的網站上有一個Flash元素,它是一個XML庫。它應該與背景無縫融合。我導入了一張具有透明度的PNG,其中一個邊緣是與另一個BG的混合邊緣。當然,在Mac和Windows上都有顏色轉換。我試圖導入PSD,保存爲JPG,使用GammaSlamma刪除分析,各種東西。Flash AS3顏色校正
我想我將不得不手動調整圖像來匹配,然後根據用戶的操作系統或類似的東西來提供兩個不同的Flash文件,但後來我看到AS3支持顏色校正,很多人似乎覺得它有用。不用說我非常興奮但是,我從來沒有使用過AS3,並且正在爲此感到頭疼。
我發現了一個免費更換幻燈片那是AS3,但我只是不知道在哪裏可以在添加此代碼
代碼,根據http://kelsocartography.com/blog/?tag=as3-color-correction是所有需要:
stage.colorCorrection = ColorCorrection.ON;
的代碼畫廊(對不起,這麼長的片段):
//----------------------------------------------------------------------------------------------------
// XMLSlideshow.as
// 19 Feb 2009
// www.simplistika.com
//----------------------------------------------------------------------------------------------------
package com.simplistika
{
import flash.display.*;
import flash.events.*;
import flash.net.URLRequest;
import flash.utils.Timer;
//Color correction
import flash.display.ColorCorrection;
stage.colorCorrection = ColorCorrection.ON;
//----------------------------------------------------------------------------------------------------
// class definition
//----------------------------------------------------------------------------------------------------
public class XMLSlideshow extends cXMLApp
{
//----------------------------------------------------------------------------------------------------
// member data
//----------------------------------------------------------------------------------------------------
private var mTimer : Timer;
private var mPlaceholder1 : Loader = new Loader();
private var mPlaceholder2 : Loader = new Loader();
private var mControl : mcControl = new mcControl();
private var mSlide : int;
//----------------------------------------------------------------------------------------------------
// slideshow setup
//----------------------------------------------------------------------------------------------------
private var mFile : String = "http://www.simplistika.com/files/ssp/Slideshow.xml"; // path to xml file
private var mInterval : uint = 8000; // slide interval
//----------------------------------------------------------------------------------------------------
// constructor
//----------------------------------------------------------------------------------------------------
public function
XMLSlideshow(
) : void
{
trace(this + " " + "XMLSlideshow.constructor");
mTimer = new Timer(mInterval, 0);
mPlaceholder1.contentLoaderInfo.addEventListener(Event.OPEN, fOpen);
mPlaceholder1.contentLoaderInfo.addEventListener(Event.COMPLETE, fResult);
mPlaceholder2.contentLoaderInfo.addEventListener(Event.OPEN, fOpen);
mPlaceholder2.contentLoaderInfo.addEventListener(Event.COMPLETE, fResult);
//this.addEventListener(MouseEvent.MOUSE_OVER, fOnMouseOver);
//this.addEventListener(MouseEvent.MOUSE_OUT, fOnMouseOut);
//this.addEventListener(MouseEvent.CLICK, fOnClick);
mTimer.addEventListener(TimerEvent.TIMER, fTimer);
addChild(mPlaceholder1);
addChild(mPlaceholder2);
addChild(mControl);
mSlide = 0;
mControl.btnForward.alpha = mControl.btnBack.alpha = mControl.btnPause.alpha = 0.0;
//mControl.btnForward.buttonMode = mControl.btnBack.buttonMode = mControl.btnPause.buttonMode = true;
mControl.btnForward.visible = mControl.btnBack.visible = false;
super(mFile);
super.addEventListener("XMLLoaded", fStart);
}
//----------------------------------------------------------------------------------------------------
// fStart
//----------------------------------------------------------------------------------------------------
private function
fStart(
e : Event
) : void
{
trace(this + " " + "XMLSlideshow.fStart");
fLoadImage();
}
//----------------------------------------------------------------------------------------------------
// fOnMouseOver
//----------------------------------------------------------------------------------------------------
/* private function
fOnMouseOver(
e : MouseEvent
) : void
{
switch (e.target.name)
{
case "btnPause":
mTimer.running ? mControl.txtDesc.text = "Pause" : mControl.txtDesc.text = "Play";
break;
case "btnForward":
mControl.txtDesc.text = "Next";
break;
case "btnBack":
mControl.txtDesc.text = "Back";
break;
default:
return;
}
mControl.txtDesc.alpha = 1;
e.target.alpha = 0.7;
}
//----------------------------------------------------------------------------------------------------
// fOnMouseOut
//----------------------------------------------------------------------------------------------------
private function
fOnMouseOut(
e : MouseEvent
) : void
{
switch (e.target.name)
{
case "btnPause":
case "btnForward":
case "btnBack":
e.target.alpha = 0.5;
mControl.txtDesc.alpha = 0;
return;
}
}
//----------------------------------------------------------------------------------------------------
// fOnClick
//----------------------------------------------------------------------------------------------------
private function
fOnClick(
e : MouseEvent
) : void
{
trace(this + " " + "XMLSlideshow.fOnClick " + e.target.name);
switch (e.target.name)
{
case "btnPause":
if (mControl.txtDesc.text == "Pause")
{
mTimer.stop();
mControl.btnBack.visible = mControl.btnForward.visible = true;
mControl.txtDesc.text = "Play";
}
else
{
mTimer.start();
mControl.btnBack.visible = mControl.btnForward.visible = false;
mControl.txtDesc.text = "Pause";
}
return;
case "btnForward":
mSlide == mItems - 1 ? mSlide = 0 : mSlide++;
break;
case "btnBack":
mSlide == 0 ? mSlide = mItems - 1 : mSlide--;
break;
default:
return;
}
fLoadImage();
} */
//----------------------------------------------------------------------------------------------------
// fLoadImage
//----------------------------------------------------------------------------------------------------
private function
fLoadImage(
) : void
{
getChildIndex(mPlaceholder1) != 0 ?
mPlaceholder2.load(new URLRequest(mData.slide[mSlide].url)) :
mPlaceholder1.load(new URLRequest(mData.slide[mSlide].url));
}
//----------------------------------------------------------------------------------------------------
// fTimer
//----------------------------------------------------------------------------------------------------
private function
fTimer(
e : TimerEvent
) : void
{
mSlide == mItems - 1 ? mSlide = 0 : mSlide++;
fLoadImage();
}
//----------------------------------------------------------------------------------------------------
// fOpen
//----------------------------------------------------------------------------------------------------
private function
fOpen(
e : Event
) : void
{
mTimer.stop();
}
//----------------------------------------------------------------------------------------------------
// fResult
//----------------------------------------------------------------------------------------------------
private function
fResult(
e : Event
) : void
{
if (!mControl.btnForward.visible)
mTimer.start();
getChildIndex(mPlaceholder1) == 0 ? fNextImage(mPlaceholder1) : fNextImage(mPlaceholder2);
}
//----------------------------------------------------------------------------------------------------
// fKenBurns
//----------------------------------------------------------------------------------------------------
private function
fNextImage(
vPlaceholder : Loader
) : void
{
setChildIndex(vPlaceholder, this.numChildren - 2);
vPlaceholder.alpha = 0;
vPlaceholder == mPlaceholder1 ? cTween.to(mPlaceholder2, {alpha:0}, 1) : cTween.to(mPlaceholder1, {alpha:0}, 1);
cTween.to(vPlaceholder, { alpha:1 }, 1);
}
//----------------------------------------------------------------------------------------------------
} // class
//----------------------------------------------------------------------------------------------------
} // package
你可以看到我在那裏增加了「色彩校正」,但是當我運行該文件得到這個錯誤:
ReferenceError: Error #1065: Variable stage is not defined.
at global$init()
有什麼建議嗎?謝謝....
我很抱歉成爲這樣的痛苦,但我會在哪裏添加第一部分?當我嘗試#2時,出現此錯誤:ReferenceError:錯誤#1065:變量階段未定義。在全局$ init()-----我將它添加到「private var mSlide:int;」下面。線。 – Sara
看起來像XMLSlideshow正在舞臺前成爲可能。我更新了關於如何在班級中實施#1的答案。 – Obto
謝謝。我想我通過第一步得到了它,並且拾取了正在添加的colorCorrection。但是,我仍然得到錯誤:ReferenceError:錯誤#1065:變量ColorCorrection未定義。 \t at com.simplistika :: XMLSlideshow/_added()----我只是不明白爲什麼它沒有看到ColorCorrection不是變量! – Sara