Forum Moderators: open

Message Too Old, No Replies

Dynamic images won't load

createEmptyMovieClip and loadMovie

         

CtrlAltDimension

1:11 am on Nov 5, 2005 (gmt 0)

10+ Year Member



I am trying to load an image dynamically into Flash, but it's not working for me.

Ideally, I'd like it to load along with the commented out section of code, but in the line below that one, I even explicitly state: I WANT BUTTON-IMG1.JPG TO LOAD HERE! But it doesn't show up.

I traced the width and height after setting it, but they end up equalling 0, and I traced the positioning and they equal 300 each.

So therefore, the empty movie clip is being created, but it's not loading the image.

What's the deal?

onClipEvent(load){

createEmptyMovieClip("container", 1);
//loadMovie("button-img"+myCount+".jpg", "container");
loadMovie("button-img1.jpg", "container");
container._width=500;
container._height=500;
container._x=300;
container._y=300;
}

Richard_N

7:21 am on Nov 5, 2005 (gmt 0)



onClip event handlers are assigned to the clips timeline not the root movie. and I am not clear where you are trying to load the image.

Personally I would write a function on the main timeline

whateverclip_mc.onLoad = function() {
_root.createEmptyMovieClip("container_mc", 1);
container_mc._x= 300;
container_mc._y= 300;
container_mc.loadMovie("button-img1.jpg");
}

This was a quick 2 minute look, not checked or tested and should when whateverclip_mc loads create a new movie clip container_mc on the root timeline, position it at x and y 300 and load button-img1.jpg into it.

Was not sure if you were trying to create the container clip inside the loaded clip and if so were you trying to create a few of them (judging from the commented out code). If so its going to be a fair bit more complex.

BTW this is AS2 player 7 was not sure what platform you were trying to publish on.

CtrlAltDimension

6:03 pm on Nov 5, 2005 (gmt 0)

10+ Year Member



Ah yes, "be more specific":

I am using ActionScript 2 in MX 2004.

This code is assigned to a movie clip, "buttonImage". I am trying to load the image inside a new movie clip, "container", which will be inside "buttonImage."

Eventually, I would like the image to load dynamically, but I am trying to keep it simple for now and just load one movie clip into a specific place.

Hope that clears things up a bit.

Richard_N

5:53 pm on Nov 6, 2005 (gmt 0)



whateverclip_mc.onLoad = function() {
whateverclip_mc.createEmptyMovieClip("container_mc", 1);
container_mc._x= 300;
container_mc._y= 300;
whateverclip_mc.container_mc.loadMovie("button-img1.jpg");
}

CtrlAltDimension

7:33 pm on Nov 6, 2005 (gmt 0)

10+ Year Member



Okay, the image is loading now, but there's still something funky going on.

If I just load it, it looks fine, but I'm also trying to resize it dynamically.

When I adjust either the _width, however, the image rotates 90 degrees. The width will adjust to the correct size, but the rotation was not designated. If I try to adjust both width and height in sequence, the image doesn't show up at all.

Likewise, when I try to adjust the _width and then the _rotation, the image doesn't show up anymore. Is Flash just that poor with dynamic images, or am I doing something wrong?

I am trying to adjust the container's width to be equal to that of another Movie Clip, which is being resized via frame animaiton.

onClipEvent(enterFrame){
container._width=_parent.buttonAni._width;
//container._height=_parent.buttonAni._height;
}

Richard_N

8:58 pm on Nov 6, 2005 (gmt 0)



Surely you need a function to first get the clips width your trying to match write it as a variable, then define a listener to detect change, then you need to pass that change to the variable which then resizes the other clip, this is not as simple a job as your trying to make it I think.

plus an onEnterFrame action is very processor intensive, so its better done with listeners at a quick guess.

CtrlAltDimension

9:15 pm on Nov 6, 2005 (gmt 0)

10+ Year Member



But wouldn't a listener require onEnterFrame code, anyway?

Maybe I just don't understand what you mean by listener. How would you write one of those?