Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)

Reply
 
Thread Tools Rate Thread Display Modes
Old 09-24-2003, 01:54 PM   #1
hwormser
Registered User
 
Join Date: Sep 2003
Posts: 14
Default "gotoAndPlay" from link in external txt file?

I'm loading dynamic text from an external txt file and I'm trying to set it up so that when a user clicks on a bit of text it will show a particular MC (either by going to a different frame on the timeline or by making an MC _visible). I can see how to link to a URL using the <a href> code, but is it possible to make a link that will just take you to another frame of the movie? Or is there some other way I should be doing this?

(The text is needs to be editable by the client which is why I'm using an external txt file.)
hwormser is offline   Reply With Quote
Old 09-24-2003, 02:23 PM   #2
webguy
Senior Member
 
webguy's Avatar
 
Join Date: May 2003
Location: west palm beach
Posts: 1,652
Send a message via ICQ to webguy Send a message via AIM to webguy
Default

sure..

ActionScript Code:
targ = "thisFrameLabel"; this.gotoAndStop(targ);

ActionScript Code:
targ = 2 this.gotoAndStop(Number(targ));

Pretty sure each of those will work.

web
__________________
Reality is merely an illusion, albeit a very persistent one.
webguy is offline   Reply With Quote
Old 09-24-2003, 02:38 PM   #3
hwormser
Registered User
 
Join Date: Sep 2003
Posts: 14
Default

Sorry for being an idiot but I'm pretty new to this stuff. Could you be a little more specific? What exactly am I putting in my txt file? If I put in <target="framelabel"> when I click on the link it just opens my browser and tries to find a url called "framelabel".
hwormser is offline   Reply With Quote
Old 09-24-2003, 04:51 PM   #4
webguy
Senior Member
 
webguy's Avatar
 
Join Date: May 2003
Location: west palm beach
Posts: 1,652
Send a message via ICQ to webguy Send a message via AIM to webguy
Default

Sorry about that. I guess you need to know how to import a text file and all that. Well there are some helpful tutorials on this site that will guide you through the process of importing text.

I'll give some insight along with some tidbits of code that will help you understand the tutorials you should read after this.

First things first. Formatting data to be loaded into Flash. Well there are a few ways to go about this, the easiest being URL encoded text file. This is easiest because Flash automatically parses it and browsers automatically format it.

A URL encoded text file is in this form.

?name=Ken Elliott&likes=camels&age=24

(look at the address in your address bar right now. Everything after php3? are variable definitions being passed to the php program)

? simply tells flash that everything after it is url encoded and Flash should parse it.

name,likes & age are variable names

Ken Elliott,camels & 24 are values attached to the variables.

You can use the LoadVars object to load an external text file into flash. For testing we will say that the above URL encoded text is in a text file called 'info.txt'.

ActionScript Code:
// here I simply create a new LoadVars object myInfo = new LoadVars(); // now I load our text file into my new // loadVars object myInfo.loadVars("info.txt"); // and you can't access the information until // it has finished loading so i utilize // the onload event to trigger it to // move the _root playhead to the frame // number corresponding to my age (24) myInfo.onLoad = function () { // I use Number() to ensure that it is // a number _root.gotoAndStop(Number(this.age)); }

See what is going on here? When I load the information into my loadVars object flash automatically parses the URL encoded text and assigns it in the scope of that object. So I can access all of the variables in that text file by referencing the loadVars object.

ActionScript Code:
trace(myInfo.name); // Ken Elliott trace(myInfo.likes); // camels trace(myInfo.age); // 24

Hope that helps.
web
__________________
Reality is merely an illusion, albeit a very persistent one.
webguy is offline   Reply With Quote
Old 09-24-2003, 05:17 PM   #5
hwormser
Registered User
 
Join Date: Sep 2003
Posts: 14
Default

Thanks for hanging in there with me on this. Let me try to be as specific as I can given that I don't really know what I'm talking about.

I know how to load a txt file. I know the basics of how to do URL encoding, assign variables, etc. What I'm trying to do is have a link appear within the text that I'm loading from the text file. I know that I can do something like this:

Go to <A HREF="http://www.macromedia.com">Macromedia's website</A>

and that will give me a link within the text to Macromedia's website.

But what I want to do is have a link within the text so that when the user clicks on the link, a popup window will appear within the flash movie (either by advancing the movie to another frame, or by making a previously invisible movie visible).

I can see how your example is causing the movie to advance to another frame when the text is done loading, but is there a way to make it advance to a specific frame when the user clicks on a link within the text?

Perhaps you've already answered my question but I'm just too dense to see it.
hwormser is offline   Reply With Quote
Old 09-24-2003, 05:26 PM   #6
webguy
Senior Member
 
webguy's Avatar
 
Join Date: May 2003
Location: west palm beach
Posts: 1,652
Send a message via ICQ to webguy Send a message via AIM to webguy
Default

That is a good one, that I am currently working on. There are some prototypes over at proto.layer51.com but they are a little advanced and still don't do what you need them to do. So you need to attach some code to some text in a textField so that when it is clicked it executes some actionscript...hmm.

I know that it can be done, but it would be difficult. Simply because Text is text.. not a movieClip or a button. So onEnterFrame, onPress and onRelease do not exist for it. The only way to do it is to parse the text looking for something that signifies text to be made into a link. Then that text is either extracted and placed in an MC which is then placed in the spot where the text was, or an MC is created and placed overtop of the text with 0% alpha so that it can be clicked, mimicking clickable text.

The problem lies in finding the right coordinates for the selection of text.

As you can tell the only way I see of doing it is slightly complicated, and borderline improbable. Hopefully someone can set me straight.

web
__________________
Reality is merely an illusion, albeit a very persistent one.
webguy is offline   Reply With Quote
Old 09-24-2003, 05:38 PM   #7
hwormser
Registered User
 
Join Date: Sep 2003
Posts: 14
Default

That's what I was afraid of. Thanks for confirming it and saving me from beating my head against the wall trying to figure it out.
hwormser is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:32 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.