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

Animate CC HTML5 - Load image from url into movie clip

Engaged ,
Oct 03, 2018 Oct 03, 2018

Copy link to clipboard

Copied

Simply put, when a frame is jumped to, it contains this code:

this.p_Image.children[0].image.src = "http://website.com/image.jpg";

My Movie Clip's instance name is "p_Image", it contains a placeholder bitmap within it and nothing else. It is a layout element which needs to display a specific image depending on which frame is currently displayed.

the console error I get is:

Cannot read property 'children' of undefined

What is not defined here? Shouldn't this be a very simple?

Any insight would be helpful, thanks!

Views

893

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 , Oct 04, 2018 Oct 04, 2018

Okay, this is very important. When I asked you to insert alert(this.p_Image); preceding your image-setting code, did you place it immediately before it? There was nothing in between? Nothing that would change the value of this? Because what you're describing is exactly what would happen if someone messed up using an event handler to target an instance.

Votes

Translate

Translate
LEGEND ,
Oct 03, 2018 Oct 03, 2018

Copy link to clipboard

Copied

When in doubt, always confirm your assumptions. Stick an alert(this.p_Image); in front of that code. Maybe an alert(this); too for good measure.

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 ,
Oct 03, 2018 Oct 03, 2018

Copy link to clipboard

Copied

I don't know how helpful this alert is:

[MovieClip (name=p_Image)]

What is it supposed to do?

Thanks.

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 ,
Oct 03, 2018 Oct 03, 2018

Copy link to clipboard

Copied

It's supposed to confirm that the object you're trying to access actually exists, of course.

This is confusing though, because your error message above clearly indicates that an attempt to access the "children" property of p_Image is failing because p_Image is undefined, yet apparently alert(this.p_Image) is not returning undefined.

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 ,
Oct 04, 2018 Oct 04, 2018

Copy link to clipboard

Copied

It certainly does exist, so this should work, right?

But for some reason it doesn't.

This sums up the entirety of my experience with Animate CC nicely.

Does anyone know if there is a FLA file somewhere that shows this seemingly very common feature actually working?

I can't be the only one who would like to see that.

Have you ever been able to get this to work?

Thanks.

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 ,
Oct 04, 2018 Oct 04, 2018

Copy link to clipboard

Copied

Okay, this is very important. When I asked you to insert alert(this.p_Image); preceding your image-setting code, did you place it immediately before it? There was nothing in between? Nothing that would change the value of this? Because what you're describing is exactly what would happen if someone messed up using an event handler to target an instance.

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
New Here ,
Jul 19, 2021 Jul 19, 2021

Copy link to clipboard

Copied

LATEST

Hi ClayUUID!
I'm stuck in the same place 

 

My alert(mc); trow me there it is // [MovieClip (name=mc)]

but next to it the code 
this.mc.children[0].image.src="images/test.jpg";

Trow me error : 

[Error] TypeError: undefined is not an object (evaluating 'this.mc.children[0].image') 

 

this.stop();
alert(this.mc);
this.mc.children[0].image.src="images/test.jpg";

 

Any help would be much apreciated

 

Thanks

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