Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

Over Shadow your content

This is a discussion on Over Shadow your content within the Tutorials forums, part of the Flash English category; Often I have received requests in which they asked some tips on how to overshadow all the contents of the ...


Go Back   Forum Flash CS3 Flash CS4 > Flash CS3 Flash CS4 > Flash English > Tutorials

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 15-07-08, 11:34
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,535
Rep Power: 6
Flep is on a distinguished road
Over Shadow your content

Often I have received requests in which they asked some tips on how to overshadow all the contents of the SWF by clicking a button and then bring up a popup ( always inside Flash) or anything like that.
So I decided to create a couple of examples.
The first is whether all content is composed of different objects and therefore without a container.
The second is whether you have all the contents of the SWF in a MovieClip, which serves as a container (always better choice).
In the second case we can also apply a slight BlurFilter to all content while in the first case apply only a sort of semi-transparent film.

Example 1:









Code:
var film_mc:MovieClip;
var pop:PopUp;

pop_btn.addEventListener(MouseEvent.MOUSE_DOWN,openPopUp);

function openPopUp(evt:MouseEvent):void
{
	createFilm();
	attachPopUp();
}

function createFilm():void
{
	film_mc=new MovieClip();
	film_mc.graphics.beginFill(0xFFFFFF,1);
	film_mc.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
	film_mc.alpha=0.5;
	addChild(film_mc);
}

function attachPopUp():void
{
	pop=new PopUp();
	pop.x=stage.stageWidth/2-pop.width/2;
	pop.y=stage.stageHeight/2-pop.height/2;
	addChild(pop);
	
	pop.close_mc.mouseChildren=false;
	pop.close_mc.buttonMode=true;
	pop.close_mc.addEventListener(MouseEvent.MOUSE_DOWN,closePopUp);
}

function closePopUp(evt:MouseEvent):void
{
	removeChild(pop);
	pop=null;
	removeChild(film_mc);
	film_mc=null;
}

Let's see the code.

We have 4 functions:



  1. openPopUp: this function is called when the POPUP button has been clicked and also will call 2 more functions ( createFilm and attachPopUp ).

  2. createFilm: this function creates a MovieClip, draws a rectangle ( stage dimensions, 0.5 alpha and white color ).

  3. attachPopUp: this is the past attachMovie method of the previous version of Actionscript. I just have a MovieClip in library (mc_pop) that is my window. So this MovieClip is associated to a class I called PopUp.

    Then I add a listener of MOUSE_DOWN event to the close_mc MovieClip. At the click will close the window calling the function closePopUp.

  4. closePopUp: this function removes the MovieClip that has been created within the createFilm function and also removes the window ( PopUp ).


Example 2:









Code:
var film_mc:MovieClip;
var pop:PopUp;

container_mc.pop_btn.addEventListener(MouseEvent.MOUSE_DOWN,openPopUp);

function openPopUp(evt:MouseEvent):void
{
	applyBlur();
	createFilm();
	attachPopUp();
}

function createFilm():void
{
	film_mc=new MovieClip();
	film_mc.graphics.beginFill(0xFFFFFF,1);
	film_mc.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
	film_mc.alpha=0.3;
	addChild(film_mc);
}

function applyBlur():void
{
	var blurX:Number=3;
	var blurY:Number=3;
	var filter_array:Array=new Array();
	var blur:BlurFilter=new BlurFilter(blurX,blurY,BitmapFilterQuality.HIGH);
	filter_array.push(blur);
	container_mc.filters=filter_array;
}

function attachPopUp():void
{
	pop=new PopUp();
	pop.x=stage.stageWidth/2-pop.width/2;
	pop.y=stage.stageHeight/2-pop.height/2;
	addChild(pop);
	
	pop.close_mc.mouseChildren=false;
	pop.close_mc.buttonMode=true;
	pop.close_mc.addEventListener(MouseEvent.MOUSE_DOWN,closePopUp);
}

function closePopUp(evt:MouseEvent):void
{
	removeChild(pop);
	pop=null;
	removeChild(film_mc);
	film_mc=null;
	container_mc.filters=[];
}

Same logics of the first example, but we have a function more: applyBlur that apply a BlurFilter to the MovieClip container.


Source files:
Attached Files
File Type: zip OverShadow.zip (1.65 MB, 160 views)

__________________

 


I recommend: Essential Actionscript 3.0

- I do not reply technicians pvt messages. Open a thread !
- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2 (permalink)  
Old 18-07-08, 10:41
Member
 
Join Date: Jan 2008
Posts: 38
Rep Power: 0
Maldor is on a distinguished road
Re: Over Shadow your content

thx for this flep....got my problem finally solved from before but this always comes in handy.........
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 22-07-08, 14:35
Junior Member
 
Join Date: Jul 2008
Posts: 1
Rep Power: 0
rafusea is on a distinguished road
Re: Over Shadow your content

I haven't worked with Flash in a long time, so it is taking me a bit to get back into the swing of things. Also, I didn't really get the chance to get deep into ActionScript at all when I worked with Flash before.

This idea is EXACTLY what my friend had in mind for the website she is doing, and I am trying to help her get it done. But, I am not really sure how to manipulate the code so it will work for us, because i don't really know action script. This is PERFECT, now I just need to make it work for us!!!!

Can you give me some pointers?

Thanks! :)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 31-07-08, 04:12
Junior Member
 
Join Date: Nov 2007
Posts: 4
Rep Power: 0
nilayvakil is on a distinguished road
Re: Over Shadow your content

Great Tool Flep.

You are the best. Can we apply this to Elastic Gallery to open pop up for bigger picture?

Thanks in advance
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 20-08-08, 20:46
..confused..
 
Join Date: Jun 2008
Posts: 4
Rep Power: 0
Arcane001100 is on a distinguished road
Re: Over Shadow your content

I am able to add another button and associate it with the function "opnPopUp"-- which then loads the same mc_pop (instance pop_btn). how can I change the association of the second button to a different movie clip "mc_pop2" (instance pop2_btn)?

Should I just create a separate class for each button instance? would this be the most efficient approach?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 20-08-08, 21:16
..confused..
 
Join Date: Jun 2008
Posts: 4
Rep Power: 0
Arcane001100 is on a distinguished road
Re: Over Shadow your content

More specific: where can I find the association of the button instance to the movie clip?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 27-08-08, 06:22
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,535
Rep Power: 6
Flep is on a distinguished road
Re: Over Shadow your content

Hi,
you can create a second PopUp in the library. Associate it to a new class: PopUp2.
So:
var pop_up:PopUp;
var pop_up_2:PopUp2

...
__________________

 


I recommend: Essential Actionscript 3.0

- I do not reply technicians pvt messages. Open a thread !
- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 15-12-08, 09:55
Junior Member
 
Join Date: Sep 2008
Posts: 1
Rep Power: 0
elus is on a distinguished road
Re: Over Shadow your content

hi
plz i need help for this script , i am AS2.0 user and i wana get the script in the as2.0 version if these is possible plz send to me at eluss@hotmail.com
thank's a lot
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 28-12-08, 14:30
Junior Member
 
Join Date: Dec 2008
Posts: 1
Rep Power: 0
Kroco is on a distinguished road
Re: Over Shadow your content

It's really useful.
But, If I don't want the do it with a button on the stage, but buttons create by a xml file (for a photo gallery)?
Every "button" will have a different name, but create by the program, not by hand.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
Flash CS3 Problem with a hitch in loading xml-content alxpalm Actionscript 3.0 newbies 1 27-10-08 14:26
Trucco del giorno - Loader.content Flep Articoli e tutorials 7 29-06-08 16:24
Flash CS3 crate expanding box to reveal content danmo advanced Actionscript 3.0 2 14-06-08 10:54
Loading Dynamic Content Onto Scrollpane jimbosun advanced Actionscript 3.0 0 02-04-08 05:23
Tips abd Tricks Actionscript 3.0 - Loader.content Flep Tutorials 0 27-09-07 09:44


All times are GMT. The time now is 18:42.

Powered by vBulletin version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap