Re: [Flashcoders] e.target subobjects how do I refrence?? - slight digression
It certainly works if the type matches up, but it runs faster/is more optimized if you do strongly type myObj. The other thing that would probably speed up execution is if you assign myObj.menuSquare_mc to a local variable. It takes more time to do the dot lookup on the item you're referencing each time than if you'd do the lookup once and use the local var to reference it. If you intend to reference a variable more than a few times, store it in a local var. You can do it the other way, but I've found it's a pretty good habit to get into as you don't have to change your methodology once you're working on projects that are iterating through a lot of data. The most obvious example is if you define a variable like "arrayLength" equal to array.length and use that in your for loop, you get a performance gain: var arrLength:uint = array.length; for(i:uint=0;ihttp://e.currenttarget.name/>); break; case "mouseOut": TweenMax.to(mySquare, .3, {alpha:0, delay:0, ease:Sine.easeOut}); TweenMax.to(myObj, .3, {x:30, delay:0, ease:Sine.easeOut}); TweenMax.to(mySquare, .3, {x:0, delay:0, ease:Sine.easeOut}); break; } --Matt On Tue, May 12, 2009 at 5:32 AM, wrote: > This is the code I used to solve it. I used currentTarget, and I had my > movieclips already on stage, so I guess I didn't need to refrence them as > MovieClips? either way it works... do i need to set my type to the var > myObj? it works regardless. > > function leftmenu($e:MouseEvent ):void { > var myObj = $e.currentTarget; > trace($e.type + " : " +$e.currentTarget.name ) ; >if ($e.type == "mouseOver") { >TweenMax.to(myObj.menuSquare_mc, .3, {alpha:.06, > delay:0, > ease:Sine.easeOut}); >TweenMax.to(myObj, .3, {x:60, delay:0, > ease:Sine.easeOut}); >TweenMax.to(myObj.menuSquare_mc, .3, {x:-60, > delay:0, > ease:Sine.easeOut}); >} >if ($e.type == "mouseDown") { >trace($e.currentTarget.name); >} >if ($e.type =="mouseOut") { >TweenMax.to(myObj.menuSquare_mc, .3, {alpha:0, > delay:0, > ease:Sine.easeOut}); >TweenMax.to(myObj, .3, {x:30, delay:0, > ease:Sine.easeOut}); >TweenMax.to(myObj.menuSquare_mc, .3, {x:0, delay:0, > ease:Sine.easeOut}); >} > } > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] e.target subobjects how do I refrence??
This is the code I used to solve it. I used currentTarget, and I had my movieclips already on stage, so I guess I didn't need to refrence them as MovieClips? either way it works... do i need to set my type to the var myObj? it works regardless. function leftmenu($e:MouseEvent ):void { var myObj = $e.currentTarget; trace($e.type + " : " +$e.currentTarget.name ) ; if ($e.type == "mouseOver") { TweenMax.to(myObj.menuSquare_mc, .3, {alpha:.06, delay:0, ease:Sine.easeOut}); TweenMax.to(myObj, .3, {x:60, delay:0, ease:Sine.easeOut}); TweenMax.to(myObj.menuSquare_mc, .3, {x:-60, delay:0, ease:Sine.easeOut}); } if ($e.type == "mouseDown") { trace($e.currentTarget.name); } if ($e.type =="mouseOut") { TweenMax.to(myObj.menuSquare_mc, .3, {alpha:0, delay:0, ease:Sine.easeOut}); TweenMax.to(myObj, .3, {x:30, delay:0, ease:Sine.easeOut}); TweenMax.to(myObj.menuSquare_mc, .3, {x:0, delay:0, ease:Sine.easeOut}); } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] e.target subobjects how do I refrence??
Try var _obj:Button = e.target as Button; instead. Jason Merrill Bank of America Global Learning Shared Services Solutions Development Monthly meetings on the Adobe Flash platform for rich media experiences - join the Bank of America Flash Platform Community chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] e.target subobjects how do I refrence??
Or if they are MovieClips, then: var _obj:Button = e.target as MovieClip; Jason Merrill Bank of America Global Learning Shared Services Solutions Development Monthly meetings on the Adobe Flash platform for rich media experiences - join the Bank of America Flash Platform Community -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason Sent: Monday, May 11, 2009 5:57 PM To: Flash Coders List Subject: RE: [Flashcoders] e.target subobjects how do I refrence?? Try var _obj:Button = e.target as Button; instead. Jason Merrill Bank of America Global Learning Shared Services Solutions Development Monthly meetings on the Adobe Flash platform for rich media experiences - join the Bank of America Flash Platform Community chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] e.target subobjects how do I refrence??
Liutoday, you sent me this line of code below. Unfortunetally in AS3 it fails. a) where is the var _obj you have a underscore, and then in tweenmax you have obj with no underscore? is this correct? b) you have _obj as a Button... these are movieclips. they have a name Btn for refrence, but they link to a menusSquare_mc which is a movie clip... can you re-write it with MovieClip c) you have e.target "space" Button; this line throws a error. why the space, and why the word Button? 1086: Syntax error: expecting semicolon before Button. If i remove the Button, I get this error... 1046: Type was not found or was not a compile-time constant: Button. if i CHANGE button to MovieClip (which is what it is suppose to be...) I get this error. 1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display:MovieClip. liutoday Sun, 10 May 2009 18:59:46 -0700 function down(e:MouseEvent):void{ var _obj:Button = e.target Button; TweenMax.to(obj.menuSquare_mc, .3, {alpha:.06, delay:0, ease:Sine.easeOut}); } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] e.target subobjects how do I refrence??
function down(e:MouseEvent):void{ var _obj:Button = e.target Button; TweenMax.to(obj.menuSquare_mc, .3, {alpha:.06, delay:0, ease:Sine.easeOut}); } > Date: Thu, 7 May 2009 09:29:05 -0500 > From: zu...@zadesigns.com > To: flashcoders@chattyfig.figleaf.com > Subject: [Flashcoders] e.target subobjects how do I refrence?? > > > > I have a loop that is assigning event listeners to "target". My targets > are named btn1, btn2, btn3, etc etc. > > inside each btn, I have a movie clip called "menuSquare_mc" which I want > to animate. how can I target menuSquare_mc of each button using only 1 > function??? > > function down($e:MouseEvent ):void { > > trace($e.type + " : " +$e.target ) ; > > if ($e.type == "mouseOver") { > > TweenMax.to($e.target.menuSquare_mc, .3, {alpha:.06, delay:0, > ease:Sine.easeOut}); > > } > > } > > the above code fails... I want it to say btn1.menuSquare_mc, > btn2.menuSquare_mc, etc) using just 1 function... > > in fact, my idea would be to use if $e.type == "mouseDown" do another > function just like the over and one just like the out. > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _ 上MClub和Messenger好友一起都市寻宝! http://club.msn.cn/?from=1 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] e.target subobjects how do I refrence??
I have a loop that is assigning event listeners to "target". My targets are named btn1, btn2, btn3, etc etc. inside each btn, I have a movie clip called "menuSquare_mc" which I want to animate. how can I target menuSquare_mc of each button using only 1 function??? function down($e:MouseEvent ):void { trace($e.type + " : " +$e.target ) ; if ($e.type == "mouseOver") { TweenMax.to($e.target.menuSquare_mc, .3, {alpha:.06, delay:0, ease:Sine.easeOut}); } } the above code fails... I want it to say btn1.menuSquare_mc, btn2.menuSquare_mc, etc) using just 1 function... in fact, my idea would be to use if $e.type == "mouseDown" do another function just like the over and one just like the out. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders