To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash 8

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 07-13-2006, 06:19 AM   #1
Jaffasoft
Senior Member
 
Jaffasoft's Avatar
 
Join Date: Apr 2001
Location: On Travel
Posts: 1,586
Need script to randomly fade mcs?

I need a script to select a random order of six mcs named mc1 to mc6 (fade each down one at a time one after another) once all six have each faded up from 0 alpha to 100 I want it to randomly fade those six mcs down from 100 alpha to '0' alpha again, all one mc at a time so this loops around and goes through again.

So it selects a randoom order and fades one mc in at a time and once all six faded in all six fade out one at a time.

How can this be done I can get the fade down up thing going but how to do the random thing??
Jaffasoft is offline   Reply With Quote
Old 07-13-2006, 08:44 AM   #2
Jaffasoft
Senior Member
 
Jaffasoft's Avatar
 
Join Date: Apr 2001
Location: On Travel
Posts: 1,586
What can I do to make a gate?

I want a bit of code so that first time it's called it makes something true and the next time it calles through that gate it makes it false.

Kind of like how a two click button code works click once doesnt work and click second time and it does and loops, so on.

I have a trigger that I know when all the clips are down or up but need that alternating gate.

Then I will put:

if (fadeturn=true){
//do fade up
}
if(fadeturn=false){
//do fade down
}
Jaffasoft is offline   Reply With Quote
Old 07-13-2006, 08:56 AM   #3
Jaffasoft
Senior Member
 
Jaffasoft's Avatar
 
Join Date: Apr 2001
Location: On Travel
Posts: 1,586
I wrote this so far can anyone help with a better way i should have done this:

There is just six mcs on stage with a pic in each and named from 'mc6' though to 'mc11'

chechMc = setInterval(nextMC,500);
fadeturn=true;
myRandomMcs = new Array(6, 7, 8, 9, 10, 11);
function nextMc() {
nextMcToFade = myRandomMcs.splice(random(myRandomMcs.length), 1);
trace(["mc_"+nextMcToFade]);
fadeClips();
if (nextMcToFade.length == isNaN(0)) {
trace("Empty array");
//this is where I need the alternating tricker each time to set fadeturn true or false
myRandomMcs.push(6, 7, 8, 9, 10, 11);
nextMcToFade = myRandomMcs.splice(random(myRandomMcs.length), 1);
}
}
MovieClip.prototype.fadeClips = function() {
this.onEnterFrame = function() {
if (fadeturn=true) {
//do fade up
this["mc_"+nextMcToFade]._alpha += 3;
}
if (fadeturn=false) {
this["mc_"+nextMcToFade]._alpha -= 3;
}
};
};

Last edited by Jaffasoft; 07-13-2006 at 10:39 AM.
Jaffasoft is offline   Reply With Quote
Old 07-13-2006, 10:38 AM   #4
cancerinform
Mod
 
cancerinform's Avatar
 
Join Date: Mar 2002
Location: press the picture...
Posts: 12,312
PHP Code:
chechMc = setInterval (nextMC, 500);
fadeturn = false;
myRandomMcs = new Array (6, 7, 8, 9, 10, 11);
function
nextMc ()
{
    
nextMcToFade = myRandomMcs.splice (random (myRandomMcs.length), 1);
    
trace (["mc_" + nextMcToFade]);
    var
myMc:String = "mc_" + nextMcToFade;
    
fadeClips (myMc);
    if (
nextMcToFade.length == isNaN (0))
    {
        
trace ("Empty array");
        
//this is where I need the alternating tricker each time to set fadeturn true or false
        
myRandomMcs.push (6, 7, 8, 9, 10, 11);
        
nextMcToFade = myRandomMcs.splice (random (myRandomMcs.length), 1);
    }
}
function
fadeClips (myMc)
{
    var
mc:MovieClip = eval (myMc);
    
this.onEnterFrame = function ()
    {
        if (
fadeturn == true)
        {
            
//do fade up
            
mc._alpha += 3;
        }
        if (
fadeturn == false)
        {
            
mc._alpha -= 3;
            if (
mc._alpha <= 0)
            {
                
delete this.onEnterFrame;
                
nextMc ();
            }
        }
    };
}
nextMc ();
__________________

- The right of the People to create Flash movies shall not be infringed. -
| www.Flashscript.biz | Help a little girl, Ana, who has cancer. | Flashscript Biz Classes/Components | The new Event design pattern | Clothing for Haiti |
cancerinform is offline   Reply With Quote
Old 07-13-2006, 10:44 AM   #5
Jaffasoft
Senior Member
 
Jaffasoft's Avatar
 
Join Date: Apr 2001
Location: On Travel
Posts: 1,586
Ok you've posted yours and i was just about to post where i was up to. This almost working. Is eval depreciated?

But know it needs to be condensed down but cant work out how??

Code:
myRandomMcsUp = new Array(6, 7, 8, 9, 10, 11);
MovieClip.prototype.nextMc = function() {
	nextMcToFade = myRandomMcsUp.splice(random(myRandomMcsUp.length), 1);
	fadeClips();
	if (nextMcToFade.length == isNaN(0)) {
		trace("Finished fading up will now begin fade down");
		myRandomMcsUp.push(6, 7, 8, 9, 10, 11);
		nextMcToFade = myRandomMcsUp.splice(random(myRandomMcsUp.length), 1);
		nextMcDown();
	}
	trace(["mc_"+nextMcToFade]);
};
MovieClip.prototype.fadeClips = function() {
	this.onEnterFrame = function() {
		this["mc_"+nextMcToFade]._alpha += 5;
		if (this["mc_"+nextMcToFade]._alpha>=100) {
			
			nextMc();
		}
	};
};
MovieClip.prototype.nextMcDown = function() {
	nextMcToFade = myRandomMcsUp.splice(random(myRandomMcsUp.length), 1);
	fadeClipsDown();
	if (nextMcToFade.length == isNaN(0)) {
		myRandomMcsUp.push(6, 7, 8, 9, 10, 11);
		nextMcToFade = myRandomMcsUp.splice(random(myRandomMcsUp.length), 1);
		nextMc();
		trace("Finished fading down will now begin fade down");
	}
	trace(["mc_"+nextMcToFade]);
};
MovieClip.prototype.fadeClipsDown = function() {
	this.onEnterFrame = function() {
		this["mc_"+nextMcToFade]._alpha -= 5;
		if (this["mc_"+nextMcToFade]._alpha<=0) {
			nextMcDown();
		}
	};
};

Last edited by Jaffasoft; 07-13-2006 at 10:50 AM.
Jaffasoft is offline   Reply With Quote
Old 07-13-2006, 11:07 AM   #6
cancerinform
Mod
 
cancerinform's Avatar
 
Join Date: Mar 2002
Location: press the picture...
Posts: 12,312
I don't know your lower script but you can also change the two lines to this:

var myMc:MovieClip = this["mc_" + nextMcToFade];

var mc:MovieClip = myMc;

if you don't like eval.
__________________

- The right of the People to create Flash movies shall not be infringed. -
| www.Flashscript.biz | Help a little girl, Ana, who has cancer. | Flashscript Biz Classes/Components | The new Event design pattern | Clothing for Haiti |
cancerinform is offline   Reply With Quote
Old 07-14-2006, 12:38 AM   #7
Jaffasoft
Senior Member
 
Jaffasoft's Avatar
 
Join Date: Apr 2001
Location: On Travel
Posts: 1,586
That first script I did was just to check with setinterval. But the fades we're not working right.

Second one does fade right but just having a problem with it doing 5 mcs then 8 then 4 then 7. Should be six faded up six faded down just in random order.

And need just one script I think maybee with a function. Not the four differnt functions the way I have it now!

So just looking to tidy up the hack we got now and get a decent working code.
Jaffasoft is offline   Reply With Quote
Old 07-15-2006, 08:41 AM   #8
Jaffasoft
Senior Member
 
Jaffasoft's Avatar
 
Join Date: Apr 2001
Location: On Travel
Posts: 1,586
Flashscipt can you tell me how to use your script. When i have put it in the first frame and with the six mcs on stage with pics in them, the trace goes mad and traces every frame.

It's tracing right but should be finishing fading each clip before next.
Jaffasoft is offline   Reply With Quote
Old 07-15-2006, 12:31 PM   #9
cancerinform
Mod
 
cancerinform's Avatar
 
Join Date: Mar 2002
Location: press the picture...
Posts: 12,312
see attachment.
Attached Files
File Type: zip random_fading.zip (17.5 KB, 12 views)
__________________

- The right of the People to create Flash movies shall not be infringed. -
| www.Flashscript.biz | Help a little girl, Ana, who has cancer. | Flashscript Biz Classes/Components | The new Event design pattern | Clothing for Haiti |
cancerinform is offline   Reply With Quote
Old 07-18-2006, 09:05 AM   #10
Jaffasoft
Senior Member
 
Jaffasoft's Avatar
 
Join Date: Apr 2001
Location: On Travel
Posts: 1,586
Thanks for that flashscript.biz I appreaciate that!
Jaffasoft is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash 8

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 Off

Forum Jump


All times are GMT -4. The time now is 07:05 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.