Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    AS Concatenate input box

    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

    Code:
    <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>

  • #2
    New Coder
    Join Date
    Jan 2012
    Location
    Columbus, Ohio, U.S.A
    Posts
    41
    Thanks
    0
    Thanked 8 Times in 8 Posts
    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:

    Code:
    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:

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

    Code:
    if(ExternalInterface.available)
    {
       ExternalInterface.call('gohere', myTextField.text);
    
    }
    hope that helps!!

  • #3
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!!

  • #4
    New Coder
    Join Date
    Jan 2012
    Location
    Columbus, Ohio, U.S.A
    Posts
    41
    Thanks
    0
    Thanked 8 Times in 8 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •