Copy link to clipboard
Copied
I have a Dynamic Text Box (image_in) to receive a URL entered for an image to be loaded into a movie clip (pic) when a Button (b_load) is pressed.
I cannot get it to work, the code seems pretty straightforward:
var image_url:String = image_in.text;
b_load.addEventListener(MouseEvent.CLICK, Load_URL);
function Load_URL(event:MouseEvent):void
{
var i =new Loader();
i.load(new URLRequest(image_url));
pic.addChild(i)
}
This code gives me: Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
This code DOES work when I declare the var as a URL:
var image_url:String = "http://website.com/image.jpg";
What is the difference if I enter http://website.com/image.jpg into the Dynamic Text Field? Why does that not work?
Any help would be appreciated, thanks!
Are you declaring the variable image_url after the dynamic text is entered? If not then the value of that variable is going to be an empty string. Put the variable declaration inside the function and it should work as expected.
Copy link to clipboard
Copied
Are you declaring the variable image_url after the dynamic text is entered? If not then the value of that variable is going to be an empty string. Put the variable declaration inside the function and it should work as expected.
Copy link to clipboard
Copied
I knew I was making a rookie mistake, that's exactly it, I had all the code on the same frame, when I changed it so the button went to the next frame, the code evaluated the variable there and now the pic shows in the movieclip!
Thanks man!
Which presents a new problem, nearly identical to this, should I create a new thread for it, or continue on here?
Copy link to clipboard
Copied
Best to start a new thread.