views:

336

answers:

1

Hi can anyone offer some help please ? I have two images on my flash stage (A camera image and a scenery image) The idea is that the camera is in front of the scenery. The problem is although both images are on my stage the camera is completely transparent and looks wrong . How can I set the cannon image transparency so that it is a solid image on top of the background image . Thanks in advance for any tips !, Mick

    // add images 

var cannon = new mc_cannon ;
var backGround = new mc_scene ;        


backGround.x = 200 ;
backGround.y = 200 ; 
addChild (backGround) ; 

setChildIndex(cannon,numChildren - 1);
cannon.alpha = 1 ;
cannon.x = 200 ;
cannon.y = 200 ; 
addChild (cannon) ;
+1  A: 

Just looking at your code, I would guess that your code causes a runtime error, as you are trying to use the setChildIndex() method with a display object that has yet to be added to the stage (cannon). I can't remember ever accidentally doing this, so I'm not sure that an error is indeed thrown, but doing so would be consistent with other display-list related programmer errors.

Because you are adding the background first, and then the cannon, you shouldn't have to use setChildIndex() at all. The cannon will be added on top of the background.

Furthermore, you speak of transparent JPEG images, something that (while it does exist in an addition to the JPEG spec) is almost never used. You should use PNG images for bitmaps that have transparency. Then, in Flash CS4, set the compression of the imported image to "Photo (JPEG)", and it will be encoded by Flash as a JPEG, but keeping the transparency intact.

If removing setChildIndex() doesn't help, and you are indeed able to import the alpha channel in your images, I'm finding it really hard to imagine what the problem might be. Could you maybe supply a screen shot of the camera being "completely transparent" and "looking all wrong"?

Cheers

richardolsson
Thanks for your reply, There are no errors reported with this code. Here is a link to the picture http://img24.imageshack.us/img24/4480/camerakr.jpgI do not want any transparency just a solid image of a camera over the background strip. Thanks for your help anyway !
Mick
Are you sure that the image asset (PNG/JPEG) you are using is not transparent? And have you also checked that the content of the mc_cannon symbol is not transparent inside Flash CS4?
richardolsson
Btw, I was puzzled by your assertion that no errors are reported by your code, so I created my own test case. Running code that's equivalent to yours, I get "ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller." because of the setChildIndex() call. Are you sure you're not getting this error trace in the output window? Cheers
richardolsson