Jump to content
Search Community

Cant get next label via current time [SOLVED]

doyaydesign test
Moderator Tag

Recommended Posts

I just looked at a recent post and thought I was doing this right but I get an error for .time

 

private function stepnext(e:MouseEvent):void {

var getlabel:String = mainTimeline.getLabelAfter(mainTimeline.time); //error here

if (ppause == false) {

mainTimeline.gotoAndPlay(getlabel);

}else {

mainTimeline.gotoAndStop(getlabel);

}}

 

 

Thanks, jim

Link to comment
Share on other sites

Sorry for any confusion this caused, but I JUST changed the "time" property to be "currentTime". That would explain the error :) I noted the change in the changelog.txt. Again, my apologies for the confusion it caused, but I think "currentTime" makes more sense seeing as how there's also a "totalTime" property and a "currentLabel" property as well.

Link to comment
Share on other sites

No problem, I think I had tried it butr still didn't work.

 

I just did this:

 

private function stepprev(e:MouseEvent):void {

var getlabelp:String = mainTimeline.getLabelBefore(mainTimeline.currentTime);

if (ppause == false) {

mainTimeline.gotoAndPlay(getlabelp);

}else {

mainTimeline.gotoAndStop(getlabelp);

}}

 

This keeps going back to label 1.

 

This method had worked but I need to do it with a time variable now.

private function step3down(e:MouseEvent):void {

if (ppause == false) {

mainTimeline.gotoAndPlay("Step3");

}else {

mainTimeline.gotoAndStop("Step3");

}}

Link to comment
Share on other sites

I'd recommend doing a trace() to see what time you're making the call at. I suspect you're just visualizing the labels wrong. For example, let's say that you put a "Step4" label at exactly 4-seconds into the timeline. If your function gets called when the timeline is at a currentTime of 4.001 or something, then getLabelBefore() will return "Step4" because it's the first label that it encounters before the 4.001 time. So trace() the currentTime to see if it's what you expected. Remember, you can feed any number to getLabelBefore(), so if you want to subtract 0.2 seconds or something just to be sure you're going backwards enough, you could do myTimeline.getLabelBefore(myTimeline.currentTime - 0.2).

Link to comment
Share on other sites

Yes I see your point and actually adjusted addLable insertion points before.

 

But there are 6 labels throughout and even if I wait until its complete (or past several steps) it still goes all the way back to Step1.

 

I just did a trace on currentTime when I click the button and it is ok. It just doesn't want to see the Labels? The first label is at the very beginning of mainTimeline, so it could just be going to the beginning and not the first label.

 

//This loops 6 times-------------------------------------------------------

mainTimeline.append(new TweenMax(array[getobjid].ObjectContainer3D, 0, { visible:false } ));

mainTimeline.addLabel("Step"+stepnumber, mainTimeline.duration);

//Then 2 more tweens appended to mainTimeline

 

//End loop----------------------------------------------------------------------

 

FlashConnect.trace(mainTimeline.currentTime);

var getlabelp:String = mainTimeline.getLabelBefore(mainTimeline.currentTime);

if (ppause == false) {

mainTimeline.gotoAndPlay(getlabelp);

}else {

mainTimeline.gotoAndStop("Step3"); //Hardcode of label works perfect

}}

 

 

thanks

Link to comment
Share on other sites

//Away3D project using FlashDevelop

//Objects get placed onstage hidden, become visible, move to intermediate position then to final position

//Setup: puts them into position - already visible false

//First main append - added because it seemed to make things work right for first label

 

 

 

setupTimeline.append(new TweenMax(array[getobjid].ObjectContainer3D, 0, {x:intropos_x, y:intropos_y, z:intropos_z, rotationX:introrot_x, rotationY:introrot_y, rotationZ:introrot_z}));

 

mainTimeline.append(new TweenMax(array[getobjid].ObjectContainer3D, 0, { visible:false } ));

 

mainTimeline.addLabel("Step"+stepnumber, mainTimeline.duration); //This seems to pick up and add the next delay value

 

FlashConnect.trace(mainTimeline.duration);

 

//This adds delay before move and onStart makes visible and sets start color

mainTimeline.append(new TweenMax(array[getobjid].ObjectContainer3D, 0, {delay:beforedelayseconds, x:intropos_x, y:intropos_y, z:intropos_z, rotationX:introrot_x, rotationY:introrot_y, rotationZ:introrot_z, onStart:startcolor, onStartParams:[getobjid, stepnumber] }));

 

//First object has no intermediate pos, checkagain checks xml, problem: object picks up time in Not Equal statement!

if ( checkagain != "qq" ) {

mainTimeline.append(new TweenMax(array[getobjid].ObjectContainer3D, tointerseconds, {x:interpos_x, y:interpos_y, z:interpos_z, rotationX:interrot_x, rotationY:interrot_y, rotationZ:interrot_z}));

} else {

mainTimeline.append(new TweenMax(array[getobjid].ObjectContainer3D, tofinalseconds, {x:finalpos_x, y:finalpos_y, z:finalpos_z, rotationX:finalrot_x, rotationY:finalrot_y, rotationZ:finalrot_z, onComplete:changecolor, onCompleteParams:[stepnumber, getobjid]}));

}

 

mainTimeline.append(new TweenMax(array[getobjid].ObjectContainer3D, tofinalseconds, {x:finalpos_x, y:finalpos_y, z:finalpos_z, rotationX:finalrot_x, rotationY:finalrot_y, rotationZ:finalrot_z, onComplete:changecolor, onCompleteParams:[stepnumber, getobjid]}));

 

//Finish adding tweens - Loops 6 times

 

 

Button calls function-------------------------------------------------------------------------

 

private function stepprev(e:MouseEvent):void {

//var gettime

var getct:String = new String(mainTimeline.currentLabel);

//var lt:Number = mainTimeline.getLabelTime(getct);

//var getct:Number = mainTimeline.currentTime;

//var getlabelp:String = new String (mainTimeline.getLabelBefore(lt));

//var zz:Number = new Number(thestep);

//var newstep:Number = zz - 1;

//var makestring:String;

//makestring = String(newstep);

FlashConnect.trace(getct); //RETURNS NULL

var getlabelp:String = mainTimeline.getLabelBefore(mainTimeline.currentTime);

if (ppause == false) {

mainTimeline.gotoAndPlay(getlabelp);

}else {

mainTimeline.gotoAndStop("Step3"); //WORKS PROPERLY

}}

Link to comment
Share on other sites

I was really hoping you'd be able to post a simple FLA that demonstrates the issue. Frankly, I'm not an Away3D guy and I'm not looking to download the stuff, become familiar with it, etc. Can you reproduce the problem in a super-simple FLA that just tweens a couple of MovieClips or something? When I run into trouble, that's typically what I do - start with a super basic foundational part, and see if it works. If so, I start adding logic/components until it breaks. So in this case, I'd recommend creating the timeline and doing some basic animation and see if the labels work as expected. If so, great. Start adding Away3D stuff and see if it breaks. There certainly shouldn't be any conflicts with Away3D specifically, just for the record.

 

Also, just for the record, if you're going to use tweens with a duration of 0, and you're putting them into a timeline, you should set immediateRender:false, otherwise they'll render immediately.

 

Oh, and ASO files are basically like a cache for ActionScript files. If you're using FlashDevelop, I'm really not sure how that works exactly. There's a menu in the Flash IDE that allows you to delete ASO files. Do you think that maybe FlashDevelop is caching some old files?

Link to comment
Share on other sites

UGH! I just noticed that when I did a search/replace changing "time" to "currentTime", it affected one variable in the label-related function responsible for the functionality you're describing. It was working perfectly before that night, and the change did indeed break it. My bad! Sorry 'bout that. It's fixed now. I think you'll find that all the label navigation stuff works now. :oops:

Link to comment
Share on other sites

  • 1 year later...

Hello

 

I wanted to read currentTime in order to imageTimeline.getLabelBefore(imageTimeline.currentTime);

 

But I took a while to figure out that I could, because I read the docs too carefully - the docs say that currentTime is write only !

currentTime property

currentTime:Number [write-only]

 

A tiny error in your docs. Not wanting to be fussy, but might save someone a few minutes someday.

 

Jason

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...