  | |  | Re: Animated Menu Example | Re: Animated Menu Example 2004-02-16 - By andrew
Back -- -- Original Message -- -- From: "Andreas Weber" <webweber@(protected)> To: <flashnewbie@(protected)> Sent: Monday, February 16, 2004 9:46 AM Subject: RE: [Flashnewbie] how to exit OnClipEvent()? [was: Animated Menu Example]
> > the buttons move for one onEnterFrame cycle before the onEnterFrame is > killed.... > > Not so, it's never killed. And if you reduce the framerate to lets say fps 4 > you'll see that the button first moves half the distance, than a quarter, > than the eight part and so on. In accordance with this algo: buttons[i]._x = > (buttons[i].newX + buttons[i]._x) / 2; >
I'm almost there, but I'm still having a few last issues.
Depending on what page I'm on, I'm reordering the buttons in the array before doing anything else:
if (subTab != 0) { i = subTab; newPos = buttons[i]; buttons.splice(i, 1); buttons.unshift(newPos); }
so if "subTab" is "2" and my original array was "button0_mc, button1_mc, button2_mc, button3_mc"
my new array is "button2_mc, button0_mc, button1_mc, button3_mc"
and when the SWF loads the buttons are in that new order on the page...which is correct.
The only problem is, when "positionButtons()" runs, it seems to use the original order of the buttons to run the "easing"...so "button2_mc" starts in the third position and then slides left to the first position, when the SWF first initializes.
What I'm trying to do is not have have any motion initially...in effect I want the buttons to be static until something is clicked.
Do I need to separate the initial button-loading function from the positionButtons function?
TIA, Andrew
> To get more easing functions/possibilities: > You could use Robert Penner's functions which are built into Flash MX 2004. > Or you download a 'Tweening engine', like Zeh Fernando's (on > http://proto.layer51.com/) or the new, highly praised one from Lasislav Zigo > (Flash Exchange section on the macromedia site). > > Here another applying a splendid *elastic* easing ( ;-), using Penner's > function, see code below) > > http://www.motiondraw.com/md/as_samples/Testing/naviPos.html > > use the onMotionFinished handler to call the getURL(). > > > Here's some more info on how to use the newly built in Tweening methods: > http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:96393 > > http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:sss:101817:200401:cjlmcpfkd > jgjhbojjoeg#b > > -- ---- ------ > Andreas Weber > motiondraw.com > > > > > > // store references to the button clips in a array (in the order of their > first appearance) > buttons = [clip1_mc, clip2_mc, clip3_mc, clip4_mc]; > // padding/distance between 2 buttons > distance = 10; > // top left corner of navigation > y = 100; x = 50; > > tweens = new Array(); > > // a flag for the first positioning of the buttons > init = true; > buttonClicked = false; > > // bring the buttons into their initial position an attach onRelease > handlers > positionButtons(init); > > function positionButtons(init){ > // a var of successively summing up the width of all buttons > var widthPredecessors = 0; > for(i=0, len = buttons.length; i<len; i++){ > // to store the new position: > buttons[i].newY = y; > buttons[i].newX = x + (i*distance) + widthPredecessors; > > target = buttons[i]; > startPos = buttons[i]._x; > endPos = buttons[i].newX; > seconds = 1; > if(i==0){ > newTween = new mx.transitions.Tween(target, "_x", > mx.transitions.easing.Elastic.easeOut, startPos, endPos, seconds, true); > newTween.onMotionFinished = function (){ > if(buttonClicked){ > trace('getURL'); > // here comes the getURL code! > } > trace('onMotionFinished was called'); > > var j = tweens.length; > while(j--){ > delete tweens[j]; > } > delete this.onMotionFinished; > } > tweens.push(newTween); > }else{ > tweens.push(new mx.transitions.Tween(target, "_x", > mx.transitions.easing.Elastic.easeOut, startPos, endPos, seconds, true)); > } > > widthPredecessors += buttons[i]._width; > if(init){ > buttons[i].onRelease = function(){ > sortButtons(this); > } > } > } > > > // onRelease handlers are only attached the first time > init = false; > } > function sortButtons(clickedButton){ > buttonClicked = true; > for(i=0, len = buttons.length; i<len; i++){ > // find index of the clicked button > if(buttons[i] == clickedButton){break;} > } > // remove this button from the array > buttons.splice(i,1); > // add it at the first position (index 0) of the array > buttons.unshift(clickedButton); > positionButtons(); > } > > > > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ > Supported by Fig Leaf Software > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ > Lower Prices for Certified Training! Check out new lower prices for > Certified Macromedia Training from Fig Leaf Software. Expand your > skill set with courses in ColdFusion, Flash, Rich Internet > Applications and .NET in the new year. Fig Leaf Software provides > the highest caliber instruction at our training centers in Washington > D.C., Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at > your location. > > Get the details at http://training.figleaf.com/ > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- > To unsubscribe, e-mail: flashnewbie-unsubscribe@(protected) > For additional commands, e-mail: flashnewbie-help@(protected) > > >
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ Supported by Fig Leaf Software -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ Lower Prices for Certified Training! Check out new lower prices for Certified Macromedia Training from Fig Leaf Software. Expand your skill set with courses in ColdFusion, Flash, Rich Internet Applications and .NET in the new year. Fig Leaf Software provides the highest caliber instruction at our training centers in Washington D.C., Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location.
Get the details at http://training.figleaf.com/ -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- To unsubscribe, e-mail: flashnewbie-unsubscribe@(protected) For additional commands, e-mail: flashnewbie-help@(protected)
Earn $52 per hosting referral at Lunarpages.
|
|
 |