Ultrashock Forums > Flash > ActionScript
AS2 - loop a function ??
Member Blogs
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
AS2 - loop a function ??
Old 2008-07-07

hi guys i ahve this code

Code:
#include "lmc_tween.as"

customEasing = "Linear";

function regMe ()
{

	mc.tween ("_alpha",20,1,customEasing);
	mc.alphaTo (100,1,customEasing,4);
	mc.rotateTo (360,1,customEasing,4);
	mc.scaleTo (250,1,customEasing,4);
	mc.scaleTo (50,0.5,customEasing,5);

}

runMe = regMe ();

for (i = 1; i < 4; i++)
{
	mc = "mc" + i;
	_root[mc].onEnterFrame = function ()
	{
gotoAndPlay("runMe");
	};
}
i have written a function and am trying to loop it ??

any ideas big thx to all who post
postbit arrow 6 comments | 201 views postbit arrow Reply: with Quote   
itsglitzy
Registered User
itsglitzy is offline
seperator
Posts: 216
2005-05-28
Age: 29
itsglitzy lives in United Kingdom
seperator

Ultrashock Member Comments:
Isocase Isocase is offline Isocase lives in United States 2008-07-07 #2 Old  
Its not working because you are using gotoAndPlay(). When you add in the parameter "runMe" Flash sees that as the name of a label on the timeline instead a method name. From the looks of your code since your using the tween class you don't need to have an onEnterFrame method in your loop. Try this

Code:
#include "lmc_tween.as"

var customEasing:String = "Linear";

for(var i:Number = 1; i < 4; i++)
{
	var mc:MovieClip = _root[ "mc" + i ];
	
	regMe( mc );
}

function regMe( target:MovieClip ):Void 
{

	target.tween("_alpha",20,1,customEasing);
	target.alphaTo(100,1,customEasing,4);
	target.rotateTo(360,1,customEasing,4);
	target.scaleTo(250,1,customEasing,4);
	target.scaleTo(50,0.5,customEasing,5);

}
Reply With Quote  
itsglitzy itsglitzy is offline itsglitzy lives in United Kingdom 2008-07-08 #3 Old  
hi isocase, big thx for your reply but its doesnt work??? any ideas or am i doing something wrong my clip on stgae is called mc
Reply With Quote  
Isocase Isocase is offline Isocase lives in United States 2008-07-08 #4 Old  
How man clips do you have on the stage?
Reply With Quote  
itsglitzy itsglitzy is offline itsglitzy lives in United Kingdom 2008-07-08 #5 Old  
just 1 called mc...
Reply With Quote  
Isocase Isocase is offline Isocase lives in United States 2008-07-08 #6 Old  
Ahh thats why it wasn't working because you were looking for mc0, mc1...which don't even exist. Try the below out, and if your only using one mc what are you looping through?

Code:
#include "lmc_tween.as"

var customEasing:String = "Linear";

for(var i:Number = 1; i < 4; i++)
{
	regMe();
}

function regMe():Void 
{
	trace( "regMe method is running" );
	
	mc.tween("_alpha",20,1,customEasing);
	mc.alphaTo(100,1,customEasing,4);
	mc.rotateTo(360,1,customEasing,4);
	mc.scaleTo(250,1,customEasing,4);
	mc.scaleTo(50,0.5,customEasing,5);

}
Reply With Quote  
itsglitzy itsglitzy is offline itsglitzy lives in United Kingdom 2008-07-08 #7 Old  
i was trying to build a set of tasks (regMe function ) with tween classes and then just loop for ever or by action. basically trying to loop my function...thx for all your help btw top man
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: