• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Load Image from URL entered into Dynamic Text Box

Engaged ,
Feb 12, 2015 Feb 12, 2015

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!


TOPICS
ActionScript

Views

415

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Feb 12, 2015 Feb 12, 2015

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.

Votes

Translate

Translate
LEGEND ,
Feb 12, 2015 Feb 12, 2015

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 16, 2015 Feb 16, 2015

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 16, 2015 Feb 16, 2015

Copy link to clipboard

Copied

LATEST

Best to start a new thread.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines