DEPAdmin
asked on
Using text in AS3 to gotoAndPlay a frame label
Hello, I'm working in Adobe Flash CS5/AS3 for the Mac. I was wondering how I can use TLF or dynamic text to "gotoAndPlay" a frame label in my document. There is an option to specify a link URL under the "Link" field, however, I need the text to jump to a frame label when it is clicked on, NOT open up a URL.
This text is also located within a movieclip that is already on the main timeline. It would need to communicate with the main timeline and jump to a frame label on there.
I've worked around this before by creating buttons that jump to a different frame when they are clicked on, but I figured there's got to be an easier way to do this via text.
Thanks in advance.
This text is also located within a movieclip that is already on the main timeline. It would need to communicate with the main timeline and jump to a frame label on there.
I've worked around this before by creating buttons that jump to a different frame when they are clicked on, but I figured there's got to be an easier way to do this via text.
Thanks in advance.
ASKER
I noticed that the 2 links you posted are in reference to navigating to other html web pages. I need to navigate to a "frame label" in my document on the main timeline from the inside of a movieclip. Is it possible to do this?
I posted the links to show you how TextEvent works. Now in the event handler function user your script instead of navigateToURL.
Use gotoAndPlay("labelName");
Warm Regards
Deepanjan Das
Use gotoAndPlay("labelName");
Warm Regards
Deepanjan Das
ASKER
I'm completely lost (I guess I should have mentioned I'm relatively new to programming lol). I honestly don't understand the difference between public and private class, and I get the Syntax Error "package is unexpected."
Here's a break down of what I am trying to do.
- I have a text field on the stage already (not sure if it should be dynamic, or TLF text) with the instance name of "section1_txt", and the text on the stage reads "Section 1."
- When this text field is clicked on, I want it to gotoAndPlay the frame label named "s1summary" on the timeline.
Seems easy enough, but I wasn't sure if this was possible, or if I need to create a button instead to do what I need it to do.
Here's a break down of what I am trying to do.
- I have a text field on the stage already (not sure if it should be dynamic, or TLF text) with the instance name of "section1_txt", and the text on the stage reads "Section 1."
- When this text field is clicked on, I want it to gotoAndPlay the frame label named "s1summary" on the timeline.
Seems easy enough, but I wasn't sure if this was possible, or if I need to create a button instead to do what I need it to do.
Hope this helps :)
Warm Regards
Deepanjan Das
import flash.events.TextEvent;
field.htmlText="This is a test.";
field.addEventListener(TextEvent.LINK,clickin);
function clickin(evt:TextEvent):void
{
trace(evt.text);
gotoAndPlay("labelName");
}
Warm Regards
Deepanjan Das
ASKER
I did try your code and it does place "This is a test" on the stage, however, it does not do anything when you try to click on it.
I was supposed to replace "field" with "section1_txt" correct?
Also, what kind of text should it be (TLF, dynamic, static, etc.)?
Thanks.
I was supposed to replace "field" with "section1_txt" correct?
Also, what kind of text should it be (TLF, dynamic, static, etc.)?
Thanks.
ASKER
I played around with the code and got the following to work (when the user clicks on "Section 1" it takes them to the frame label "s1summary"...I changed it to a MouseEvent and it appears to work):
import flash.events.TextEvent;
section1_txt.htmlText="Section 1";
section1_txt.addEventListener(MouseEvent.CLICK,clickin);
function clickin(event:MouseEvent):void
{
gotoAndPlay("s1summary");
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah OK, I get it now. I tried out your code and that does work also.
Thanks for your help :)
Thanks for your help :)
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/TextEvent.html#includeExamplesSummary
http://www.flepstudio.org/forum/tutorials/410-textevent-link-actionscript-3-0-a.html
Warm Regards
Deepanjan Das