Jump to content
Search Community

Math.random [SOLVED]

vdheyning test
Moderator Tag

Recommended Posts

I have a whole bunch of movieclips that I'd like to randomly alpha in and then randomly alpha out, but within a timeframe of say 3 seconds each way,

I achieved more or less what I wanted by naming and tweening each individual movieclip, (About 50 of them, took forever...) but I'm sure it can easily be optimised...

Could you lead the way for me to do this?

please find attached the file with the very amateurisch code...

Thanks, Fam

Link to comment
Share on other sites

Yep, there's a much more efficient way to do that. Like:

 

var logo:DisplayObject;
for (var i:int = 1; i     logo = this.getChildByName("logo" + i);
   TweenLite.from(logo, 2, {alpha:1, width:1, height:1, x:360, y:270, delay:Math.random()});
   TweenLite.to(logo, 2, {alpha:0, width:1, height:1, x:360, y:270, delay:7 + Math.random(), overwrite:false});
} 

Link to comment
Share on other sites

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at gs::TweenLite/init()

at gs::TweenLite/renderTime()

at gs.core.tween::SimpleTimeline/renderTime()

at gs::TweenLite$/updateAll()

 

 

Dear Greensock, thank you for your very fast reply, how do you do that?

 

I am getting an error message though...what am I doing wrong?

 

Thanks, Fam

Link to comment
Share on other sites

My script assumed you had 78 logos on the screen, all labeled as such like "logo1", "logo2", etc. The error indicates there's probably at least one of those logos missing. You could track it down I putting a trace(i + ": "+logo) right after the logo variable is set so that you can see the number at which it gets a null value.

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...