Jump to content
Search Community

Flashing Lights with Auto Alpha

phillip_vale test
Moderator Tag

Recommended Posts

Hi there,

 

I am trying to populate a space with Lights at different sizes, blur amounts and alphas. I think I have acheived this.

 

I want the final effect to be that the lights flash and use the random alpha amounts to do so. I hope this explains what I am after.

Not sure if this is a Greensock question and sorry if it isn't.

 

And i'm not sure if the answer lies in auto alpha, yoyo:true, repeat:-1 ???

 

import com.greensock.TweenMax;
import com.greensock.easing.*;
import com.greensock.plugins.AutoAlphaPlugin;
import flash.filters.BlurFilter;


flashingLights = function () { 


TheWidth = 300; // The Width of effect area -> in pixels
Object(this).bg._width = this.TheWidth


TheHeight = 250; // The height of effect area -> in pixels
Object(this).bg._height = this.TheHeight


maxLightsize = 60; // Scaling the cell
NumOfCells = 70; // Quantity of Cells on the stage


for (i=0; i < NumOfCells; i++) { // by using the 'for' looping sequence
TheCell = attachMovie("Light_Cell", "Light_Cell"+i, i); // attaching the 'Light_Cell' from the library (Linkage)
TheCell._alpha = 10+Math.random()*60; // creating random alpha value
RandomSet = 4*Math.random()*4; // Create a random set for amount of blur
TheBlurEffect = new BlurFilter (RandomSet,RandomSet,3); // Create variable with the filter setting (xBlur, yBlur, quality)
TheCell.filters = [TheBlurEffect] // Applies the filter to the object named myObject
TheCell._x = -(TheWidth/2)+Math.random()*(1.5*TheWidth); // positioning the cell on the X axis.
TheCell._y = -(TheHeight/2)+Math.random()*(1.5*TheHeight); // positioning the cell on the Y axis.
TheCell._xscale = TheCell._yscale = 60 + Math.random()*(maxLightsize*10); // determine the scale of the Cell
}


TweenMax.to(Light_Cell, 1, {_alpha: 10});


};


flashingLights();

 

I should add that all of the 'lights' are being placed on the top layer when I run this going over the top of text.

 

Thanks for you help,

 

Phil

Link to comment
Share on other sites

Feel like I might be getting closer.

 

I have the entire 'TheCell' fading in and out.

 

When I trace (TheCell); it shows...

 

_level0.Light_Cell0
_level0.Light_Cell1
_level0.Light_Cell2
_level0.Light_Cell3
_level0.Light_Cell4
_level0.Light_Cell5
_level0.Light_Cell6
_level0.Light_Cell7
_level0.Light_Cell8
_level0.Light_Cell9
_level0.Light_Cell10
_level0.Light_Cell11
_level0.Light_Cell12
_level0.Light_Cell13
_level0.Light_Cell14
_level0.Light_Cell15
_level0.Light_Cell16
_level0.Light_Cell17
_level0.Light_Cell18
_level0.Light_Cell19
_level0.Light_Cell20
_level0.Light_Cell21
_level0.Light_Cell22
_level0.Light_Cell23
_level0.Light_Cell24
 
Is there a way to enter this in a TweenMax call?
 
 
 
i.e. TweenMax.to(_level0.Light_Cell20, 1, {_alpha: a, repeat:-1, yoyo:true});
 
Thanks,
 
Phil
Link to comment
Share on other sites

Feel like there must be a better way to write this...

 

import com.greensock.TweenMax;
import com.greensock.easing.*;
import flash.filters.BlurFilter;


var a = 0+Math.random()*50;
var d = 0+Math.random()*1;


flashingLights = function () { 


TheWidth = 300; // The Width of effect area -> in pixels
Object(this).bg._width = this.TheWidth


TheHeight = 250; // The height of effect area -> in pixels
Object(this).bg._height = this.TheHeight


maxLightsize = 60; // Scaling the cell
NumOfCells = 30; // Quantity of Cells on the stage


for (i=0; i < NumOfCells; i++) {
TheCell = attachMovie("Light_Cell", "Light_Cell"+i, i); // Attaching the 'Light_Cell' from the library (Linkage)
TheCell._alpha = 100; // Creating random alpha value
RandomSet = 4*Math.random()*4; // Create a random set for amount of blur
TheBlurEffect = new BlurFilter (RandomSet,RandomSet,3); // Create variable with the filter setting (xBlur, yBlur, quality)
TheCell.filters = [TheBlurEffect] // Applies the filter to the object named myObject
TheCell._x = -(TheWidth/2)+Math.random()*(1.5*TheWidth); // Positioning the cell on the X axis.
TheCell._y = -(TheHeight/2)+Math.random()*(1.5*TheHeight); // Positioning the cell on the Y axis.
TheCell._xscale = TheCell._yscale = 60 + Math.random()*(maxLightsize*10); // Determine the scale of the Cell
//trace (TheCell);
//trace (d);
}


TweenMax.to(_level0.Light_Cell1, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell2, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell3, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell4, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell5, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell6, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell7, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell8, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell9, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell10, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell11, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell12, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell13, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell14, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell15, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell16, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell17, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell18, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell19, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell20, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell21, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell22, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell23, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell24, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell25, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell26, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell27, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell28, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell29, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell30, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
};


flashingLights();

This is due first thing tomorrow morning so any help would be greatly appreciated! :)

Link to comment
Share on other sites

TweenMax.to(_level0.Light_Cell1, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell2, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell3, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell4, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
TweenMax.to(_level0.Light_Cell5, 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
 
use a loop like.
for(i=1; i < 6; i++){
TweenMax.to(_level0["Light_Cell" + i], 1, {_alpha:a, yoyo:true, repeat:-1, delay:d});
}

Or you can place all the objects in an Array and do pass the whole Array into a tween

var things = [item1, item2, item3]
TweenLite.to(things, 1, {_x:200});

I haven't written AS2 in many years, but the syntax should be pretty close.

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

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