# Lighthouse-type Beam of Light

**URL:** <https://forum.kirupa.com/t/lighthouse-type-beam-of-light/245982>\
**Category:** open source\
**Created:** [December 6, 2007, 1:40am UTC](https://forum.kirupa.com/t/lighthouse-type-beam-of-light/245982 "2007-12-06T01:40:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmo518](https://avatars.discourse-cdn.com/v4/letter/r/f19dbf/32.png) [@rmo518](https://forum.kirupa.com/u/rmo518)\
**Post date:** [December 6, 2007, 1:40am UTC](https://forum.kirupa.com/t/lighthouse-type-beam-of-light/245982/1 "2007-12-06T01:40:12Z")

</div>

I had to make with a lighthouse-like beam of light, and this is what I came up with.  
[http://www.humblevoice.com/AlcabyBee/lighthouse](http://www.humblevoice.com/AlcabyBee/lighthouse)

One thing I’d like to do - use lineGradientStyle instead of just lineStyle to make the individual rays fade from 100% to 0% opacity. When I tried to do it I just got lost in the matricies, interpolationMethods, and focalPointRatios. I couldn’t get it to do what I wanted. So if there are any lineGradientStyle gurus out there, feel free to modify this accordingly.

[FONT=Courier New][LEFT][AS]Stage.scaleMode = “noScale”;  
//  
import flash.filters.BlurFilter;  
var blurX:Number = 8;  
var blurY:Number = 8;  
var quality:Number = 1;  
var filter:BlurFilter = new BlurFilter(blurX, blurY, quality);  
var filterArray:Array = new Array();  
filterArray.push(filter);  
//  
import flash.filters.GlowFilter;  
//  
var color:Number = 0xFFFFFF;  
var alpha:Number = .8;  
var blurX:Number = 16;  
var blurY:Number = 16;  
var strength:Number = 2;  
var quality:Number = 2;  
var inner:Boolean = false;  
var knockout:Boolean = false;  
var filter:GlowFilter = new GlowFilter(color, alpha, blurX, blurY, strength, quality, inner, knockout);  
//  
filterArray.push(filter);  
node.filters = filterArray;

// TESTING VARIABLES  
\_root.createEmptyMovieClip(“node”, 1);  
node.filters = filterArray;  
node.\_x = Stage.width/2;  
node.\_y = Stage.height/2;  
RAD\_DEG = Math.PI/180;  
main\_theta = 0;  
// Functions  
function createBeams(tgt, r, range, spokes) {  
k = 0;  
for (i=0; i\<360; i += 360/spokes) {  
// Draw initial spokes in a circle  
clip = tgt.createEmptyMovieClip(“point”+k, k);  
clip.\_x = Math.cos(i_RAD\_DEG)r;  
clip.\_y = Math.sin(iRAD\_DEG)r;  
tgt.lineStyle(1, 0xFFFFFF);  
tgt.moveTo(0, 0);  
tgt.lineTo(clip.\_x, clip.\_y);  
// Assign a theta value to each clip  
clip.theta = Math.asin(clip.\_x/range)/RAD\_DEG;  
k++;  
}  
beamInt = setInterval(beamMotion, 10, tgt, range, spokes);  
}  
function beamMotion(tgt, range, spokes) {  
tgt.clear();  
// Scale the entire spotlight  
// to approximate perspective  
main\_theta++;  
factor = Math.cos(main\_thetaRAD\_DEG);  
tgt.\_xscale = tgt.\_yscale = 60 + (30_factor);  
// Move individual rays  
for (i=0; i\<spokes; i++) {  
clip = tgt[“point”+i];  
clip.theta += 1;  
if (clip.theta\>360) {  
clip.theta -= 360;  
}  
clip.\_x = Math.sin(clip.theta\*RAD\_DEG)\*range;  
tgt.lineStyle(1,0xFFFFFF);  
tgt.moveTo(0, 0);  
tgt.lineTo(clip.\_x, clip.\_y);  
}  
updateAfterEvent();  
}  
createBeams(node, 40, 400, 30);  
[/AS]  
[/LEFT]  
[/FONT]
