15.10.2012 Views

Actionscript 3 Entwicklerhandbuch

Actionscript 3 Entwicklerhandbuch

Actionscript 3 Entwicklerhandbuch

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ACTIONSCRIPT 3.0 ENTWICKLERHANDBUCH<br />

Anwenden von Filtern auf Anzeigeobjekte<br />

addChild(stopLight);<br />

addChild(cautionLight);<br />

addChild(goLight);<br />

// Apply a gradient bevel to the traffic light rectangle.<br />

var gradientBevel:GradientBevelFilter = new GradientBevelFilter(distance, angleInDegrees,<br />

colors, alphas, ratios, blurX, blurY, strength, quality, type, knockout);<br />

box.filters = [gradientBevel];<br />

// Create the inner shadow (for lights when off) and glow<br />

// (for lights when on).<br />

var innerShadow:DropShadowFilter = new DropShadowFilter(5, 45, 0, 0.5, 3, 3, 1, 1, true,<br />

false);<br />

var redGlow:GlowFilter = new GlowFilter(0xFF0000, 1, 30, 30, 1, 1, false, false);<br />

var yellowGlow:GlowFilter = new GlowFilter(0xFF9900, 1, 30, 30, 1, 1, false, false);<br />

var greenGlow:GlowFilter = new GlowFilter(0x00CC00, 1, 30, 30, 1, 1, false, false);<br />

// Set the starting state of the lights (green on, red/yellow off).<br />

stopLight.filters = [innerShadow];<br />

cautionLight.filters = [innerShadow];<br />

goLight.filters = [greenGlow];<br />

// Swap the filters based on the count value.<br />

function trafficControl(event:TimerEvent):void<br />

{<br />

if (count == 4)<br />

{<br />

count = 1;<br />

}<br />

}<br />

switch (count)<br />

{<br />

case 1:<br />

stopLight.filters = [innerShadow];<br />

cautionLight.filters = [yellowGlow];<br />

goLight.filters = [innerShadow];<br />

break;<br />

case 2:<br />

stopLight.filters = [redGlow];<br />

cautionLight.filters = [innerShadow];<br />

goLight.filters = [innerShadow];<br />

break;<br />

case 3:<br />

stopLight.filters = [innerShadow];<br />

cautionLight.filters = [innerShadow];<br />

goLight.filters = [greenGlow];<br />

break;<br />

}<br />

count++;<br />

// Create a timer to swap the filters at a 3 second interval.<br />

var timer:Timer = new Timer(3000, 9);<br />

timer.addEventListener(TimerEvent.TIMER, trafficControl);<br />

timer.start();<br />

Letzte Aktualisierung 27.6.2012<br />

301

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!