Copy link to clipboard
Copied
Hi,
I'm learning AC3. I'm using the script in an AS file to read cue points in milliseconds. These cue points are set by code in a frame script in the main timeline like this:
// Create an instance of SoundSync
var ss:SoundSync = new SoundSync();
// Use instance to add cue points to sound file
//puts a cuePoint in the soundtrack at the millisecond location indicated after the commass.addCuePoint("someString1",01969);
Here is the AS file script that reads these cue points:
package net.quip.sound
{
import flash.events.Event;
import flash.events.TimerEvent;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundLoaderContext;
import flash.media.SoundTransform;
import flash.net.URLRequest;
import flash.utils.Timer;
public class SoundSync extends Sound
{
// PROPERTIES
private var _cuePoints:Array;
private var _currentCuePoint:uint;
private var _timer:Timer;
private var _timerInterval:uint;
private var _startTime:Number;
private var _loops:uint;
private var _soundChannel:SoundChannel;
// CONSTRUCTOR
public function SoundSync(stream:URLRequest = null, context:SoundLoaderContext = null) {
super(stream, context);
init();
}
// METHODS
// init
private function init():void {
_cuePoints = new Array();
_currentCuePoint = 0;
_timerInterval = 50;
_startTime = 0.0;
}
// Add Cue Point
public function addCuePoint(cuePointName:String, cuePointTime:uint):void {
_cuePoints.push(new CuePointEvent(CuePointEvent.CUE_POINT, cuePointName, cuePointTime));
_cuePoints.sortOn("time", Array.NUMERIC);
}
// Get Cue Point
public function getCuePoint(nameOrTime:Object):Object {
var counter:uint = 0;
while (counter < _cuePoints.length) {
if (typeof(nameOrTime) == "string") {
if (_cuePoints[counter].name == nameOrTime) {
return _cuePoints[counter];
}
} else if (typeof(nameOrTime) == "number") {
if (_cuePoints[counter].time == nameOrTime) {
return _cuePoints[counter];
}
}
counter++;
}
return null;
}
// Get Current Cue Point Index
private function getCurrentCuePointIndex(cuePoint:CuePointEvent):uint {
var counter:uint = 0;
while (counter < _cuePoints.length) {
if (_cuePoints[counter].name == cuePoint.name) {
return counter;
}
counter++;
}
return null;
}
// Get Next Cue Point Index
private function getNextCuePointIndex(milliseconds:Number):uint {
if (isNaN(milliseconds)) {
milliseconds = 0;
}
var counter:uint = 0;
while (counter < _cuePoints.length) {
if (_cuePoints[counter].time >= milliseconds) {
return counter;
}
counter++;
}
return null;
}
...
Here's my problem: When I set a cue point that is a minute or more (in milliseconds) as in:
ss.addCuePoint("someString1", 107055); //this isn't processed by the AS script
...the cue points aren't read (nothing happens).
Probably it's because I need to allow for that possibility in that AS file above. (It's not my script so I don't know how to adjust it. It's from a great tutorial by David Stiller on the Adobe site: http://www.adobe.com/devnet/actionscript/articles/cue_points_audio.html).
Can anyone tell me how to adjust the AS script so I can read a cue point that goes beyond 5 places?
Thanks much!
Human error. I was not understaning millisecond conversion. SoundSync AS code is is good. I need the work.
Copy link to clipboard
Copied
Human error. I was not understaning millisecond conversion. SoundSync AS code is is good. I need the work.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now