View Full Version : AS Concatenate input box

06-18-2012, 04:44 PM
Hi all, I currently have this code working on a site so that a user can input their username, it gets added to http://dida.wildern.org/ and then the user is redirected to that particular webpage.

Please could you advise on how to EITHER, allow this code to work in a Flash Movie (that will be published to the web) OR a suitable alternative written in actionscript.


<script type="text/javascript"><!--
function gohere() {
var url="http://dida.wildern.org/";
var addon=document.getElementById('AddMe').value;

<form id="form" action="javascript:gohere();">
View a user's DiDA page:
<input type="text" id="AddMe" format="a" maxlength="20" size="8" />

<input type="submit" value="Go" />

06-18-2012, 07:53 PM
here's how you would do it in Actionscript.

1. make a text input/text field and a button on the stage.
2. put a listener/handler on the button that will redirect you


myButton.addEventListener(MouseEvent.CLICK, function(){

var url="http://dida.wildern.org/";
var addOn = myTextField.text;

navigateToUrl(new URLRequest(url + addOn + "/"));


to call JavaScript from Flash, you use external interface. Modify the function to accept a parameter and call it from flash.


function gohere(userName) {
var url="http://dida.wildern.org/";


ExternalInterface.call('gohere', myTextField.text);


hope that helps!!

06-19-2012, 10:37 AM

Sorry, I am not a very experienced coder and am using a flash template and javascript from a previous html site.

Please could I have just slightly more guidance on where to add this code?

Sorry to be a pain!! :)

06-19-2012, 02:36 PM
no probs, we all have to start somewhere :)

To code in Actionscript you just have to open up the template, go to the first frame, and open up the actions panel (F9). You can place all your code there. This is what is referred to as 'coding on the main timeline'. Not sure what your template looks like but some templates are subclassed. If this is the case, just add the code to the document class (probably called 'Main' or something like that)

Most likely it's just on the main timeline.

Hope that helps!