Jump to content
xisto Community
shadowx

Flash And Transparency

Recommended Posts

Hi folks. I want to know if its possible to modify the transparency of an image in flash to give a gradual transparent gradient? EG like the T17 banner where the text "Xisto" reflects. I know i can do this in the GIMP but i need the background of the image/text to be transparent, and GIF is the onyl format i can do that reliably and of course GIF is indexed and so i cant have a gradual fade effect. Im really stuck on this one and im no Flash expert so any ideas? Ive attached a screenie. Thats the effect i want (the black background is there so the effect is easy to see, i want it to be transparent) and its fine in JPG format, but in GIF the gradual effect goes away and i just get a sharp line which is no good. If there is a work around for this in the GIMP, that still leaves the background transparent, or a way of getting the same effect in flash (i have a transparent BG for the movie itself from the publish settings, its only this image that i need to configure) then please let me know!

post-21719-1220555667_thumb.jpg

Share this post


Link to post
Share on other sites

I haven't used Flash in a while, so I may be missing something obvious here, but can't you use a PNG file? PNG will support transparency, and should carry that over to being imported into Flash (unless Adobe haven't implemented it correctly).

Share this post


Link to post
Share on other sites

Pain.net aint for me. I avoid downloading anything from microsoft! All my stuff, except the OS is open source and free :)Ill try a PNG later, going fishing today so ill have to try it when i get back :) Thanks. I assumed PNG was the same as GIF in that you couldnt have a smooth transition into transparency, but ill try it.

Share this post


Link to post
Share on other sites

I've ActionScripted up a solution!

import flash.geom.Rectangle;function transparency (MC, s, e, g){	h = Math.ceil (MC._height);	w = MC._width;	xp = MC._y;	var window:Rectangle = new Rectangle (0, 0, w, g);	for (c = g; c <= h; c += g)	{		//when g is small (i.e. 1) and the MC is high, this might lag!		duplicateMovieClip (MC, 'dupe' + c, _root.getNextHighestDepth ());		//is it possible to stick them in a container and simply count up the depth - getNext is a bit silly..		_root['dupe' + c].scrollRect = window;		//i'm not sure if this would work well with vector drawings, i tested on your bitmap :P		_root['dupe' + c]._y = c - g + xp;		t = s * (1 - c / h) + e * c / h;		if (t < 100)		{			if (t < 0)			{				_root['dupe' + c]._alpha = 0;			} else			{				_root['dupe' + c]._alpha = t;			}		}		var window:Rectangle = new Rectangle (0, c, w, g);	}	MC._visible = false;	//if we remove MC, then the dupes are removed}//usage: transparency(MC, s, e, g)//MC: movie clip name//s: starting alpha (100 for not transparent, 0 for invisible - can be set outside)//e: ending alpha - gradient is made from s to e, if outside of [0,100], will be set to 0 or 100. you can have e>s for increasing alpha.//g: gap - the size in pixels of each block. 1 or 2 for a smooth gradient, high number for a nice blocky effecttransparency (MV,20,120,6);//i have a clip on stage called MV :)//the clip is split into 6-pixel blocks starting from 20% alpha, and going to 100% alpha for the last 1/5 of the picture... i think..

There you go! If anyone can find a better way, feel free to inform me!

In case you don't know Flash that well, here's what you need to do to get it working:
1: Are you using a movie clip? Yes -> 5, No -> 2
2: Bitmap -> 3, or vector -> 4.
3: So it's a bitmap. Right click on it and hit 'Convert to Symbol...'. Make it a movie clip and name it whatever you want. -> 5
4: Highlight everything and do step 3 starting from 'Right click'... -> 5
5: Click on your movie clip. There should be 5 text-boxes in the properties panel at the bottom. Four of them describe size and location. In the fifth (topmost) one, type in whatever you want (MV in my example.) -> 6
6: Click on the background. Hit F9 if the actions panel isn't open. Pasta my code in. Change that last line outside the braces that isn't a comment to what you want. Feel free to remove the comments. -> ?????? -> PROFIT!

If you need help, just ask =| If you've already solved the problem... damn!

..I just realised I used xp as the variable name (i.e. x position) when it refers to the y position =.= Can't be bothered changing it now.

edit) changed 'it is' to 'is it'.. bloody grammar!
Edited by Nabb (see edit history)

Share this post


Link to post
Share on other sites

Damn thanks! lol I think this topic is now solved!Ill have a play and see what happens, but for now, thanks everyone!

Share this post


Link to post
Share on other sites

Seeing as you know PHP it should make some sense, which is good.

It's probably not the best method, but I couldn't find a way to use duplicateMovieClip and attach the duplicate inside another movie-clip (something that is easily done with attachMovie - you could change it to createEmptyMovieClip on the first run, change the input parameter to a linkage id, and use attachMovie to attach the clips into the container...)

 

If you need to use it on multiple clips, then you'd need to define another variable (say k) outside of the function call (alternatively check if its defined inside the function call and if not define it). Then change 'dupe' + c to 'dupe' + k and increment k somewhere inside the loop.

 

..and if it lags, try making the image smaller and then scaling it up via a html parameter.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.