# How to get a package being able to access library symbols?

**URL:** <https://forum.kirupa.com/t/how-to-get-a-package-being-able-to-access-library-symbols/325813>\
**Category:** flash\
**Created:** [November 6, 2011, 2:25am UTC](https://forum.kirupa.com/t/how-to-get-a-package-being-able-to-access-library-symbols/325813 "2011-11-06T02:25:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lazarusomega200](https://avatars.discourse-cdn.com/v4/letter/l/d6d6ee/32.png) [@lazarusomega200](https://forum.kirupa.com/u/lazarusomega200)\
**Post date:** [November 6, 2011, 2:25am UTC](https://forum.kirupa.com/t/how-to-get-a-package-being-able-to-access-library-symbols/325813/1 "2011-11-06T02:25:48Z")

</div>

Ok, been googling my but off over this. I have a package that extends my sound class that I want to also control the alpha of an existing symbol on my stage. I have read that this would be ideally done through some sort of event listener but I can’t find a way to do it. Basically, my package generates a wavelength that I want to control the alpha of an existing library symbol. I have gotten examples to work the way I wish but can’t seem to get my package to access the main .swf’s library.

Here’s the code:

> package { import flash.events.SampleDataEvent;  
> import flash.media.Sound;

```
/**
* A dynamically generated binaural beat carrier wave Sound with frequency easing.
*/
public class Binaural extends Sound {
	// Frequency-easing parameters
	private var carrier:Number; // Scaled frequency of carrier wave
	private var binStart:Number; // Starting scaled binaural difference
	private var binDif:Number; // Ending scaled binaural difference
	private var endPos:int; // Total samples in sound
	private var easing:Function;
	private var lPhase:Number = 0, rPhase:Number = 0; // Current angular positions

	/**
	* Creates a Binaural instance with the specified behavior.
	* @param carrier Carrier wave frequency
	* @param binStart initial binaural frequency
	* @param binEnd final binaural frequency
	* @param time Length of sound in seconds
	* @param easing Easing function for the frequency shift. Default is linear.
	*/
	public function Binaural(carrier:Number, binStart:Number, binEnd:Number, time:Number, easing:Function = null) {
		var scale:Number = 2 * Math.PI / 44100;
		this.carrier = scale * carrier;
		this.binStart = scale * binStart;
		binDif = scale * (binEnd - binStart);
		endPos = time * 44100;
		this.easing = easing || defaultEasing;
		addEventListener(SampleDataEvent.SAMPLE_DATA, onSampleData);
	}

	// Standard linear ease
	public function defaultEasing(position:Number, frequency:Number, totalchange:Number, totaltime:Number):Number {
		return frequency + totalchange * position / totaltime;
	}

	// Generator
	private function onSampleData(e:SampleDataEvent):void {
		var maxPos:int = e.position + 8192;
		if (maxPos &gt;= endPos) maxPos = endPos;
		for (var position:int = e.position; position &lt; maxPos; position++) {
			var halfDiff:Number = easing(position, binStart, binDif, endPos);
			e.data.writeFloat(Math.sin(lPhase += carrier + (halfDiff/2)));
			e.data.writeFloat(Math.sin(rPhase += carrier - (halfDiff/2)));
			// LibraryObject.alpha = (halfDiff+1)/2;
		}
	}
}

```

}

The

> // LibraryObject.alpha = (halfDiff+1)/2;  
> is what worked in the main .swf when I was testing the basic concept.

Thanks,  
Pete
