A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Input TextBox Music Stream (URLRequest)

  1. #1
    Junior Member
    Join Date
    Jan 2008
    Location
    Somerset, UK
    Posts
    25

    Unhappy Input TextBox Music Stream (URLRequest)

    Ok, I'm fed up of searching, apparently this subject is not frequently talked about!

    Basically, I have a text box in a flash, and the user can write a music file, or music URL in it, so the flash can play that music file from that location.

    When the user clicks the play button, flash takes the text in the input box, turns it into a string, and uses that string, for the location / name of the file it needs to play.

    For some reason, it isnt working.
    I've tried many different combinations, but to no avail. And just when I thought I had strings and variables down.

    Here is the code, the code i have so far, I will comment it as best I can.

    Code:
    //Start button is pressed.
    function startoption(evt:MouseEvent):void {
    
    // Next, flash is meant to create a string out of the text in the input box.
    	var music_string:String = music_url.text;
    
    // Then flash uses this string to play the song.
    	var s:Sound = new Sound(new URLRequest(music_string)); 
    
    	s.play(0, 5);
    }
    This doesn't work at all. It works when I specify the string, but not when the variable comes form the Input box. There must be something stupidly obvious I'm missing, can anyone help me out?

  2. #2
    Junior Member
    Join Date
    Jan 2008
    Location
    Somerset, UK
    Posts
    25
    OK, I figured it out. It was a rookie mistake. I will post it here, just in case anyone else has this problem. The code int he previous post is correct. There's nothing wrong with it.

    When doing something like this, make sure there are no spaces, or new lines in the text box. I was using a multi-line text box in case of long URLs.

    Rookie I know. But something to look out for all the same.

    Thanks anyway =D

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center