...

View Full Version : AS Concatenate input box



MrLFenner
06-18-2012, 03: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.

Thanks


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

<div>
<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" />
</form>
</div>

adaminaudio
06-18-2012, 06: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

ie:


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.

javascript:


function gohere(userName) {
var url="http://dida.wildern.org/";
window.parent.location.href=url+userName+"/";
}

actionscript


if(ExternalInterface.available)
{
ExternalInterface.call('gohere', myTextField.text);

}

hope that helps!!

MrLFenner
06-19-2012, 09:37 AM
Thanks!

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!! :)

adaminaudio
06-19-2012, 01: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!

-Adam



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum