Jump to content
Search Community

AS3 Lightbox

barryg test
Moderator Tag

Recommended Posts

I'm currently clicking on a photo on a site and using a javascript window.open to display an enlargement in its own window. What I would like to do is use a javascript "Lightbox" effect written in AS3 as a class. I know as a minimum a tween would be used. I'm currently using tweenLite for a number of alpha effects.

 

Anyone have any suggestions to get started.

Link to comment
Share on other sites

I assume your photo on your site is displayed with flash player, right? Then you'd add a MouseEvent.CLICK event listener to that sprite displaying the photo and in the handler function create a loader instance that loads the larger version.

photo.addEventListener(MouseEvent.CLICK, onPhotoClick);

function onPhotoClick(event:MouseEvent):void
{
var loader = new Loader();
loader.load(new URLRequest("url_of_your_larger_photo");
addChild(loader);
}


That should display your larger photo. If you want a nice border and a close button you have to do extra work. I can post an simple example if you want.
Link to comment
Share on other sites

Hi,

 

I've put together a little example. I hope this explains enough what you have to do. Personally I would create a custom class for the Lightbox which makes it easy to reuse it.

 

Look at it and let me know if you have problems understanding it.

 

trispo

 

PS: The image used is "borrowed" from google images. It is not mine and may not be used in your projects without asking the copyright owner.

Link to comment
Share on other sites

  • 3 years later...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...