Skip to main content
Participant
October 6, 2013
Question

AS3 fade in out external .png or movie clip

  • October 6, 2013
  • 1 reply
  • 1580 views

Hi there all,

I am trying to code a light box in AS3. I can get it to work on 1 click of a specified movie clip, but i have 6 movie clips on my stage myCLIP_1 .to.myCLIP_6 with 6 different targets m1 .to. m6. I just cant get it to work for all 6 buttons at once. I am at my wits end..... please please help.

thanks in advance

p.s. I have only been coding for 6 months.

CAN'T paste the code i have already

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
October 6, 2013

You'll need to show your code, otherwise you need to show/describe how you coded the different buttons in some manner.  Consider using pastebin.com if you canb't figure out how to paste it into your posting. 

If you cannot show your code due to contractual reasons, then create code like it and show that.  You may only need to display two of the six for the problem to be determinable.

Do you get any error messages?  If so, you need to include those as well.

Participant
October 6, 2013

6 movie clips on stage myCLIP_1 ..to..myCLIP_6

6 images in MOVIES/1/ .. m1 ..to..m6

this works for 1 movie but cant get it to fork for all 6

hope you can help

stop();

import com.greensock.*;

import com.greensock.easing.*;

import flash.display.MovieClip;

var lightbox : Sprite;

var darkener : Shape;

var thumbnail = myCLIP_1

thumbnail.addEventListener(MouseEvent.CLICK, onThumbnailClick);

function onThumbnailClick(event:MouseEvent):void

{

darkener = new Shape();

darkener.graphics.beginFill(0x000000, .6);

darkener.graphics.drawRect(0,0,320,280);

darkener.graphics.endFill();

addChild(darkener);

TweenLite.from(darkener, .5, {alpha: 0});

loadImage("MOVIES/1/m1.png");

}

function loadImage(url : String) : void

{

var loader : Loader = new Loader();

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);

loader.load(new URLRequest(url));

}

function onImageLoaded(event:Event):void

{

thumbnail.mouseEnabled = false;

LoaderInfo(event.target).removeEventListener(Event.COMPLETE, onImageLoaded);

var image:Bitmap = Bitmap(Loader(LoaderInfo(event.target).loader).content);

image.x = image.y = 0;

lightbox = new Sprite();

lightbox.graphics.beginFill(0xFFFFFF, 1);

lightbox.graphics.drawRect(0,0,image.width, image.height);

lightbox.graphics.endFill();

lightbox.x = 10;

lightbox.y = 10;

lightbox.buttonMode = true;

lightbox.addChild(image);

addChild(lightbox);

TweenLite.from(lightbox, 1, {alpha:0});

lightbox.addEventListener(MouseEvent.CLICK, onCloseLightbox);

}

function onCloseLightbox(event:MouseEvent):void

{

lightbox.mouseEnabled = false;

var timeline : TimelineLite = new TimelineLite({onComplete: removeLightbox});

timeline.insert(new TweenLite(lightbox, 1, {alpha:0}));

timeline.append(new TweenLite(darkener, .3, {alpha:0}));

}

function removeLightbox():void

{

lightbox.removeEventListener(MouseEvent.CLICK, onCloseLightbox);

removeChild(lightbox);

lightbox = null;

thumbnail.mouseEnabled = true;

}

Ned Murphy
Legend
October 6, 2013

I only see one object with code for clicking.  If that is the code that works, that is not going to help to solve the problem.

How do you implement the code for one of the objects that does not work?