How do you reference a bitmap on a scene in ActionScript?

How do you reference a bitmap on a scene in flash using actionscript 3?

I have a bitmap on stage in flash memory, and at the end of the film I would like to change it to the next one in the sequence before the movie cycles. in my library I have 3 images exported for actionscript with class name img1 / img2 / img3. this is how my layers in flash are set.

layer 5 : mask2:MovieClip
layer 4 : img2:Bitmap
layer 3 : mask1:MovieClip
layer 2 : img1:Bitmap
layer 1 : background:Bitmap

At the end of the movie, I would like to change img1 to img2, so the movie loops smoothly, and then change img2 (at level 4) to img3 and so on until I get to the end of my images.

but I can’t find out how to refer to images that have already been put on the scene (during development), does any of them have any idea how to do this?

The final movie, we hope, will dynamically download images from the web server (I have the code for this bit) and display them, as well as img1 / img2 / img3.

Any help would be appreciated.

EDIT:

@ 81bronco , I tried this, but the instance name is allocated for graphics, this will allow me to do this using movie clips and buttons. I got half the work done by turning them into moveclips and clearing the images in moveclip before adding a new one (using something simpler that vanhornRF suggested ), but for some strange reason, when the mask strikes the images I cleaned, I return to animation masks.

+3
4

- , - .

. . .

.

+3

:

imageHolder.removeChild( imageIndex )

imageHolder.removeChildByName( imageName )

imageHolder.addChild( newImage )
+1

, , -

for(var i:int=0; i<numChildren; i++){
    trace(getChildAt(i),"This is the child at position "+i);
}

, Flash IDE, , , , , .

, , , getChildAt (int), ChildAt (int), ChildAt (displayObject, int) swapChildrenAt ( int, int). Int , , displayObject, , , DisplayObject.

4 , , , .

@81bronco , , ,

0

Hey Re0sless, when you remove these elements from the scene, do they have any event listeners attached to them, any timers or loaders? Any of these things can cause the object to become stuck in flash memory and not delete properly. Also, to just delete an item, maybe try also resetting it to zero? Sometimes it helps to clear links so that they can be properly destroyed.

Of course, it can also be something stupid, like deleting an element in one instance, also does not remove the element from future frames, but I really do not think this case.

0
source

Source: https://habr.com/ru/post/1696670/


All Articles