Jump to content
Search Community

floatingwoo

Members
  • Posts

    6
  • Joined

  • Last visited

floatingwoo's Achievements

0

Reputation

  1. Ok , Heres an example thats about as basic as it gets. This has the background layers reacting to the position of the mouse. So it wouldn't be to much of a jump to have them listen for a mouse click by changing (MouseEvent.CLICK). And having the character moving to the same Event. Am I on the right track? import com.greensock.TweenNano; import com.greensock.easing.*; //ease type var easeType = Expo.easeOut; //xmouse will hold x position of the mouse in relation to the center of the stage. //assuming that the stage center's value is 0; var xmouse:Number = 0; // percentage of the xmouse position var xPct:Number = 0; // speed or durationl var speed:Number = 14; // add event listener based on mouse movement stage.addEventListener(MouseEvent.MOUSE_MOVE, render); function render(e:MouseEvent):void { //if xmouse pos is greater than the center of the stage if( e.stageX > stage.stageWidth/2) { xmouse= -(e.stageX -stage.stageWidth) - stage.stageWidth/2; //-512 } else { xmouse = ((stage.stageWidth/2) - e.stageX); //512 } xPct = Math.round ((xmouse/stage.stageWidth) * 200); //where will the sky moveclip move to... var skyXto:Number = ((xPct/100) * (sky_mc.width - stage.stageWidth)/2) + stage.stageWidth/2; TweenNano.to(sky_mc,speed, {x:skyXto, ease:easeType}); var fieldXto:Number = ((xPct/100) * (field_mc.width - stage.stageWidth)/2) + stage.stageWidth/2; TweenNano.to(field_mc,speed, {x:fieldXto, ease:easeType}); var grassXto:Number = ((xPct/100) * (grass_mc.width - stage.stageWidth)/2) + stage.stageWidth/2; TweenNano.to(grass_mc,speed, {x:grassXto, ease:easeType}); }
  2. Heres a really great example of Parallax scrolling .......http://www.coraline.com/
  3. Hi thanks . That will get me going. This guy had a really nice little parallax engine..http://www.lextalkington.com/blog/2009/12/simple-as3-parallax-system-engine/ I need to start off a little smaller though.
  4. Hi , I'm just looking to have a basic background scrolling motion tied with the movement of the player in Flash using actionscript 3. Mountains in the background ,buildings in the middle and grass in the foreground kind of stuff. The player would be moving horizontally to mouse clicks. I found a post here in the forum but it was for JavaScript . Can someone point me in the right direction for getting more info on using TweenMax for doing this. Sorry about the misspell .Thanks
  5. Thanks Carl ! Yah I need to bone up for sure. I'm hittin it running though.Thanks for the tip.It was the loopLabel that was screwing me up, not loopFrame. After getting into it some more I found I had it spelled it loopLable . Thanks for getting back to me so quick.
  6. I'm almost there with this one. I have an animated walking character called mcPlayer. Inside of it's timeline I have frame labels at various animated states "walkingLeft","walkingRight" and "Idle". The walking animations are of him walking in one spot. I want to be able to use buttons to move the character with actionscript to various targets on the stage and have the corresponding animation play as it moves. I have tried different commands on the mcPlayer timeline,like, putting a stop(); at the beginning of each anima. I have tried putting a gotoandplay(); at the end of each anima so it will go to the beginning and loop.I would like to use the timeline as little as possible. How do I Have the animation play continuously while the tween is in motion? I am not savvy using onUpdate or it's params . The code below was suggested to me to try. I'm not clear with the Error I keep getting around the undefined property "loopFrame". I'm thinking I am supposed to have a label on the "mcPLayer" timeline called loop? btnRight.addEventListener(MouseEvent.CLICK, moveRight); btnLeft.addEventListener(MouseEvent.CLICK, moveLeft); function moveRight(Evt:MouseEvent):void{ // lastframe should be replaced with whatever the frame the walk right animation ends on. TweenLite.to(mcPlayer, 2, {x:450, onUpdate:updateHandler, onUpdateParams:['walkingRight', lastFrame], onComplete:idleHandler); mcPlayer.gotoAndPlay("walkingRight"); } function moveLeft(Evt:MouseEvent):void{ // lastframe should be replaced with whatever the frame the walk left animation ends on. TweenLite.to(mcPlayer, 2, {x:10, onUpdate:updateHandler, onUpdateParams:['walkingLeft', lastFrame], onComplete:idleHandler); mcPlayer.gotoAndPlay("walkingLeft"); } function updateHandler(loopLabel:String, lastFrame:int):void { if (mcPlayer.currentFrame == lastFrame) { mcPlayer.gotoAndPlay(loopLabel); } } function idleHandler():void { mcPlayer.gotoAndPlay("idle"); // this is also where you'd do anything else you need to do when it stops. } I need to read up on using properties like "onUpdate". Something other than just the line in the documentation. if you could point me in the right direction that would be cool!Thanks.
×
×
  • Create New...