Jump to content
Search Community

MutleyDog

Members
  • Posts

    21
  • Joined

  • Last visited

MutleyDog's Achievements

0

Reputation

  1. Great stuff. I've attached my final .fla which contains all the solutions to the questions raised in this thread. Thanks for the help and support MutleyDog Keywords: hitTestObject, AS3, TweenMax, pass variables, character rotation
  2. I've attached the file that doesnt work to illustrate that TweenMax.killTweensOf(Badger) doesnt appear to work when I'm passing a variable into the tweenUpdateHandler function.
  3. Well, I’ve attached a file which has the badger moving and managing to ‘bounce’ off irregular shaped objects. Hope it’s of use to someone. ... there’s one small snag though, and after a few hours it’s either complex – or I’m missing something. I need to pass a variable to the ‘tweenUpdateHandler’ so that I can tell it which direction the badger is moving to ‘bounce’ it the opposite direction (i.e. off the object it’s just hit). There are 8 possible directions (up, down, left, right and four diagonals). I’ve added the value ‘direction’ to be parsed into the tweenUpdateHandler ('direction' is an integer going from 1 to 8 representing 8 directions the badger could be moving in) – once parsed into the tweenUpdateHandler it stops the killTweensOf from working. My code is: stop(); import com.greensock.*; import com.greensock.easing.*; stage.addEventListener(MouseEvent.CLICK,ChangeMyBadgerLocation, false, 0, true); function ChangeMyBadgerLocation(e:Event):void { var direction:int = 6; // quick fudge as the code for getting the direction and 'turning' the badger is quite long - happy to submit it if intersted? TweenMax.to(Badger,1,{x:stage.mouseX, y:stage.mouseY,ease:Sine.easeInOut, onUpdate:tweenUpdateHandler(direction)}); } function tweenUpdateHandler(direction):void { if (Badger.hitTestObject(BIGobject1)||Badger.hitTestObject(BIGobject2)||Badger.hitTestObject(BIGobject3)||) { trace("Ouch - hit the object!"); TweenMax.killTweensOf(Badger); //this doesnt work once I've parsed the 'direction' variable in Badger.x = Badger.x - 20; //nudge the badger a little to the left - off the object it's hit. But this could be any one of 8 directions so I need to parse the direction variable. } }
  4. The only thing I might 'add' is if I use TweenMax and do: if (Badger.hitTestObject(BIGobject)) { trace("Ouch - hit the object!"); TweenMax.killTweensOf(Badger); } This causes the badger to gets 'embedded' into the BIGobject and it takes several clicks to un-stick him. I think the way round this is to set Boolean to overwrite the killTweensOf and do a little bit of trigonometry to make the badger 'bounce' a small distance off the big object. Also, as the shapes in the game are irregular I believe I should make several smaller hit objects to mark out the boundary - this is how it's done is AS2.
  5. Thanks Jack - that's exactly what I wanted. Make sense now. There's not a lot out there on hitTestObject with AS3 and this thread seems to be the only Google result. Great stuff! Andy
  6. Great Stuff Jack - my output reads (on one mouse click): Ouch - hit the object! Ouch - hit the object! Ouch - hit the object! Ouch - hit the object! Ouch - hit the object! Ouch - hit the object! Ouch - hit the object! Ouch - hit the object! Ouch - hit the object! Ouch - hit the object! Ouch - hit the object! Ouch - hit the object! Ouch - hit the object! Ouch - hit the object!
  7. sorry - working from home and got distracted by my 2 year old daughter playing. I've got a game where the player can be a range of animals. In my simplified version they have to miss objects, by clicking on the screen and TweenLiting to a different area. The problem I'm having is sometimes they pass through the object when the hitTestObject should return trace("Ouch - that hurt!"). I've attached my .fla in case it's of interest? Andy PS: They really need to stop when they hit the object which I think is TweenMax function.
  8. Hi, I've got a game coming on quite nicely in AS3 and it requires people to navigate objects. I'm using hitTestObject on a vew simple shapes - sometimes it returns 'hit' and othertimes not. i've simplified the code to: import com.greensock.TweenLite; import com.greensock.easing.*; stage.addEventListener(MouseEvent.CLICK,ChangeMyBadgerLocation, false, 0, true); //Stage_mc.addEventListener(MouseEvent.CLICK,ChangeMyBadgerLocation, false, 0, true); function ChangeMyBadgerLocation(e:Event):void { var myBadgerX:int = 0; var myBadgerY:int = 0; myBadgerX = stage.mouseX; myBadgerY = stage.mouseY; TweenLite.to(Badger,1,{x:myBadgerX, y:myBadgerY, ease:Cubic.easeInOut}); if (Badger.hitTestObject(BIGobject)) { trace("Ouch - hit the object!"); } }
  9. Perfect! - I think you're building more of the website than I am. I'll put you in the credits
  10. Hi, How do you do Tweening with conditional logic. For example Tween if something is true, dont Tween if it's false. I've set a global variable which should effect movies being loaded. I've tried putting functions into the Tween expression etc. The variable is working but not effecting the Tweens - a simplified version would be (AS2 I'm afraid): import com.greensock.*; import com.greensock.easing.*; var Bool:Boolean = false; if (Bool == true){ trace(Bool); this.Holder.circle.onRollOver = function() { TweenMax.to(this, 0.5, {_xscale:120, _yscale:120, _rotation:-3, ease:Elastic.easeOut}); }; this.Holder.circle.onRollOut = this.Ernst_mc.onReleaseOutside = function() { TweenMax.to(this, 0.3, {_xscale:100, _yscale:100, _rotation:0, ease:Bounce.easeOut}); }; }; this.Button_mc.onRelease = function() { Bool = true; trace(Bool); };
  11. ... no worries, got it working and thanks for pointing me in the right direction. I think killChildTweens kills tweens that are running whilst I call the 'killChildtweens' method - which is not what I'm after - you're right.
  12. Thanks for the advice, but I think killChildTweens is what i'm after. I'm trying to replicate exactly the site: www.amazing-academy.com. When you first visit the site a yellow post-it-note flies across the screen, all the background tweens are killed off until the user 'closes' the post-it note.. I'm happy to use conditional logic and think I can see how it could be done (global variable, few 'if's etc.) Andy
  13. I've checked the forum and the site - but wouldnt mind an examlpe of killChildTweensOf. I've got a movie clip loading into another movieclip. At times I need to stop all the animations in the loaded movieclip. I also need to resume the movieclips when the user has read the notice appearing on the stage. My code is: TweenMax.killChildTweensOf(AA_All_mc.holder_mc.loader_mc,false); ..but the Tweens keep happening. To illustrate my point I've made a simplified version as an attachment, but the only code is: import com.greensock.*; import com.greensock.easing.*; this.Holder.circle.onRollOver = function() { TweenMax.to(this, 0.5, {_xscale:120, _yscale:120, _rotation:-3, ease:Elastic.easeOut}); }; this.Holder.circle.onRollOut = this.Ernst_mc.onReleaseOutside = function() { TweenMax.to(this, 0.3, {_xscale:100, _yscale:100, _rotation:0, ease:Bounce.easeOut}); }; this.Button_mc.onRelease = function() { //trace("killing tweens"); TweenMax.killChildTweensOf(Holder,false); };
  14. Thanks for getting back so soon. I've included the smoothing as recommended - thanks for the tip. I've smoothed everything with no real visible improvement though I've found a great article on a Nokia forum named 'Flash Lite: Optimization Tips and Tricks' which I'm currently working through (http://tinyurl.com/33zvdd3). The problem appears to be with the background green tiles - if I remove it everything's fine - but it's just a simple repeating square made from a few vectors - As for the other two questions: I had a conflict between running defeerent versions of ActionScrip movies inside each other - thanks for pointing me in the right direction I'll try the killChildTweensOf() method when this machine cools off. All this tweening is cooking it's insides. Andy
  15. Hi, I've posted this question a couple of weeks ago - but after trying the advice I still cant find a solution. I've also pasted two related questions below as I couldnt find answers anywhere. Basically I've got to replicate a website exactly (long story but the original developer has all the .fla files and has left the country) and the tweening is prooving a real nightmare. The site I've got to replicate is here: http://www.amazing-academy.com/ and you'll see my attempt here: http://www.doogle.com/AmazingAcademy/MovieClips/AA.html I've tried Tweenlite and Caurina and Mc Tween with no real improvement. The images are all exactly the same file size and the framerate is quite low. However, my *version* runs all clunky and juddery - Any advice??? _________________________ Another question: How do you reference a tween in anther movie clip (AS2). I've tried: TweenLite.to(_root.MovieClip_mc,0.3,{_x:120, _y:50}; but nothing happens - although this is the correct target path _________________ Final question before I go, but is there a way to stop all Tweens in a movieclip. My example has a pop-up which blurs the background. I also need to turn all the Tweening off in the background Thanks - Andy!!
×
×
  • Create New...