• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Time Counter

Explorer ,
Aug 12, 2019 Aug 12, 2019

Copy link to clipboard

Copied

So I'm converting my SWFs into MP4s and composing HTML/CSS/JS to restore user control.  This entails designating the seconds of playback where the MP4s need to stop.  Is it possible to program a counter in the ActionScript, so that if the first stop occurs after 6 seconds, the counter would report that?  If the second stop occurs at 8.5 seconds, it reports that, and so on.  If so how?

TOPICS
ActionScript

Views

771

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2019 Aug 12, 2019

Copy link to clipboard

Copied

you can't use actionscript in mp4's and you can't use actionscript in js so i'm not sure what you're trying to do.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 13, 2019 Aug 13, 2019

Copy link to clipboard

Copied

I'm converting the SWFs into MP4s.  Then I'm composing HTML/CSS/JS to control the MP4s.  So no, I'm not trying to control an MP4 with ActionScript; I'm replacing ActionScript with JS.  Trouble is with JS you can't designate frames to stop or goto the way you can with ActionScript.  With JS you have to designate playback time, and determining those time points has proven to be a very cumbersome and time consuming process.  So I'm searching for a more efficient method.  My idea is to use actionscript to program an SWF to report how much playback time has elapsed when a stop point is reached.  So if the first stop point occurs at 6 seconds, the number 6 would appear somewhere on the screen.  Then, after I convert the swf into an mp4, I can use JS to program the mp4 to stop at 6 seconds.  So my question for the forum is, is it possible to program an swf to report how much playback time has elapsed.

I hope that clarifies the question.  If not please let me know.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 13, 2019 Aug 13, 2019

Copy link to clipboard

Copied

RE: "My idea is to use actionscript to program an SWF to report how much playback time has elapsed when a stop point is reached. "

what's the 'stop' point?

and is the 'stop point' a property of your mp4's? eg, a cuepoint?  something else?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 13, 2019 Aug 13, 2019

Copy link to clipboard

Copied

I have composed a series of animated lessons.  They progress from one stop point to the next.  I designate the stop points by simply inserting stop(); commands in the timeline.  At the stop points explanatory text appears to explain what's displayed.  So the stop points are analogous to slides in a slide show.

The stop points are not a property of MP4s.  They are programed into SWFs.  After I convert the SWFs into MP4s I need to reprogram the stops into the JS to control the MP4s. 

I don't know what a cuepoint is, but it sounds interesting.  Could it be another method to do what I need?

To avoid going down a rabbit hole I should make it clear that I am not asking for help with the JS.  We've developed the HTML/CSS/JS code to do what I need.  What I'm looking for is a facile method to determine when the stop points occur in the timeline, so we can transfer that information to the JS. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 13, 2019 Aug 13, 2019

Copy link to clipboard

Copied

you can use;

var stopA:Array = [];

var index:int = 0;

var putativeStopFrame:int = 0

this.addEventListner(Event.ENTER_FRAME,enterframeF);

function enterframeF(e):void{

if(this.currentFrame==putativeStopFrame){

if(stopA.indexOf(this.currentFrame==-1){

stopA.push(this.currentFrame);

}

}

putativeStopFrame=this.currentFrame;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 13, 2019 Aug 13, 2019

Copy link to clipboard

Copied

Thank you so much for your help kglad; it is always appreciated.  However, there seems to be a problem with the code you sent.  I copied and pasted it into the first frame of one of my animations, but when I published it as an swf I got the following error message

Filename,Layer'Layer_2, Frame 1, Line 13, Column 40 1084:Syntax error:expecting rightparen before leftbrace.

I have studied the code and for the life of me I can't figure out where to put a right parentheses, particularly because there's no left parentheses to match it with.  Just to be sure I also tried putting a parentheses at space 40 of line 13 of thecode, but of course that resulted in multiple error messages.

Any suggestions?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 13, 2019 Aug 13, 2019

Copy link to clipboard

Copied

if(stopA... needs another ) before }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 13, 2019 Aug 13, 2019

Copy link to clipboard

Copied

I hate to have to keep bothering you, but when I put in the second ) symbol the animation just opens to the first frame and stops.  I'm also getting the following error message in the Output box.

TypeError: Error #1006: addEventListner is not a function.

at filename_fla::MainTimeline/frame1()

I tried inserting a play(); command to force it to proceed, as well as a button with a play function, but neither helped.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Aug 13, 2019 Aug 13, 2019

Copy link to clipboard

Copied

it's "addEventListener" and not "addEventListner"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 13, 2019 Aug 13, 2019

Copy link to clipboard

Copied

:

var stopA: Array = [];

var index: int = 0;

var terminateBool:Boolean;

var putativeStopFrame: int = 0

this.addEventListener(Event.ENTER_FRAME, enterframeF);

function enterframeF(e: Event): void {

if (this.currentFrame == putativeStopFrame) {

if (stopA.indexOf(this.currentFrame == -1)) {

stopA.push(this.currentFrame);

}

}

putativeStopFrame = this.currentFrame;

if(terminateBool){

this.removeEventListener(Event.ENTER_FRAME, enterframeF);

trace("stopA: " + stopA);

}

if (this.currentFrame == this.totalFrames) {

terminateBool = true

}

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 14, 2019 Aug 14, 2019

Copy link to clipboard

Copied

Well, I copied the code provided above into the first frame of one of the animations, and it eliminated the error message, so that's progress.  However, no counter appeared.  Basically it's running as it did without the code.  Any ideas for where to go from here?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 14, 2019 Aug 14, 2019

Copy link to clipboard

Copied

in the output panel, did you see:

stopA: [...some sequence of numbers]?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

No, with the most recent draft of the code nothing appears in the Output panel.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

then you did something wrong or there are no frames that stop on the timeline that contains that code or your output panel has 'show output' unticked:

Screenshot - 8_15_2019 , 8_29_31 AM.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

As we were having problems getting the code to work, I pursued another avenue by searching Google. I found the following solution, but there’s still one problem that I hope you can help me with. 

The solution I found is to enter dynamic text into the first frame, with a number in the text box, along with the following code. 

var Numb:Number = 0;

var MyTimer:Timer = new Timer(1000, Numb);

DynText.text = Numb.toString();

MyTimer.start();

MyTimer.addEventListener(TimerEvent.TIMER, countdown);

function countdown(e:TimerEvent):void

{

Numb++;

DynText.text = Numb.toString();

}

It works fine except that when the playback comes to a stop point the timer keeps counting.  I need it to stop counting at the stop points, and resume counting when playback resumes, so I can write down the time at each stop point, and so the count will be accurate at each stop point.  Do you have any suggestions for getting this timer to stop while the playback is stopped, and resume when the playback resumes?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

that code is irrelevant to your question:  it displays the (approx) number of seconds the code has been executing.  ie, it doesn't have anything to do with finding the frames where stops are located on the timeline that contains that code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

Your response tells me what the problem is.  I failed to communicate what I need.  The question I asked was how to "use actionscript to program an SWF to report how much playback time has elapsed when a stop point is reached."  So I don't need to find frames where stops are located on the timeline, I need to know how much time has elapsed in the playback when a stop is reached.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

the only way that would make sense would be if the video is attached to a timeline.  but then when a stop() is reached and the timeline (and video stop), something must occur (eg, button click) to cause the timeline (and video) to continue play.  the time required for you to click that button is irrelevant to anything you might want to obtain.

so you actually want the frames where the stop()'s are located and then convert those stop() frames to the time between those frames:

var stopA: Array = [];

var index: int = 0;

var terminateBool:Boolean;

var putativeStopFrame: int = 0

this.addEventListener(Event.ENTER_FRAME, enterframeF);

function enterframeF(e: Event): void {

if (this.currentFrame == putativeStopFrame) {

if (stopA.indexOf(this.currentFrame == -1)) {

stopA.push(this.currentFrame);

}

}

putativeStopFrame = this.currentFrame;

if(terminateBool){

this.removeEventListener(Event.ENTER_FRAME, enterframeF);

convertFramesToTimeF(stopA);

}

if (this.currentFrame == this.totalFrames) {

terminateBool = true

}

}

function convertFramesToTimeF(stopA:Array):void{

var a:Array = [];

a.push[stopA[0]/stage.frameRate);

for(var i:int=1;i<stopA.length;i++){

a.push((stopA-stopA[i-1])/stage.frameRate);

}

trace('stopA: "+stopA)

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

LATEST

I still haven't communicated what I need.  I am not trying to determine the time required to click a button.  However, I have worked out the code that I listed above.  I'm on my way to bed right now, but in a day or two I will describe the process in a separate posting, in case anyone might be interested.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines