Copy link to clipboard
Copied
Hi I have a question on how I can make my code display a total time for a song from a media player I created with Actionscript 3.0, using XML to load the song track.
This is my current function which I have done and I am unsure on what the problem is that is not allowing the elapsed time to display in a textfield on my stage.
stage.addEventListener(Event.ENTER_FRAME, timeElapsed);
function timeElapsed(e:Event):void
{
var minutesCurr:Number = Math.floor((my_channel.position /1000) /60);
var secondsCurr = Math.floor((my_channel.position /1000) % 60);
if (secondsCurr < 10)
{
secondsCurr = "0" + secondsCurr;
}
var minutesTot:Number = Math.floor((my_sound.length /1000) /60);
var secondsTot = Math.floor((my_sound.length /1000) % 60);
if (secondsTot < 10)
{
secondsTot = "0" + secondsTot;
}
completeText_txt.text = minutesCurr + ":" + secondsCurr + "/" + minutesTot + ":" + secondsTot;
}
I tried adding to the stage and I am getting a null object reference.
Thanks Casey
The 1009 error indicates that one of the objects being targeted by your code is out of scope. This could mean that the object....
- is declared but not instantiated
- doesn't have an instance name (or the instance name is mispelled)
- does not exist in the frame where that code is trying to talk to it
- is animated into place but is not assigned instance names in every keyframe for it
- is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).
...Copy link to clipboard
Copied
The 1009 error indicates that one of the objects being targeted by your code is out of scope. This could mean that the object....
- is declared but not instantiated
- doesn't have an instance name (or the instance name is mispelled)
- does not exist in the frame where that code is trying to talk to it
- is animated into place but is not assigned instance names in every keyframe for it
- is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).
If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.
Copy link to clipboard
Copied
Thanks fixed it.
Copy link to clipboard
Copied
You're welcome
Find more inspiration, events, and resources on the new Adobe Community
Explore Now