Jump to content
Search Community

snick

Members
  • Posts

    6
  • Joined

  • Last visited

snick's Achievements

0

Reputation

  1. I think the problem is related to a screen update that occurs prior to the tween. Probably due to playhead movement in your timeline nav. Try adding the MovieClip to the stage dynamically in a function, and include the TweenMax in the function body. No screen update will occur until the function exits. Not sure how well this will work with timeline navigation.
  2. Here's an example that creates an array from the contents of your movieclip, then tweens that array in a totally cool way. stop(); import com.greensock.*; import com.greensock.easing.*; import flash.display.SimpleButton; var array:Array = new Array(); for (var i:int = 0; i < CR_btnGrp.numChildren; i++) { array.push(CR_btnGrp.getChildAt(i)); } TweenMax.allFrom(array, 2, {autoAlpha:0, y:"-300", rotationY:"-180", rotationX:"-180", ease:Elastic.easeOut}, .05);
  3. I usually start at 60fps in new Flash projects. I refer to my CPU meter while testing Flash projects; if it exceeds 30%, I reduce the framerate and/or look for more optimizations. There is also the issue of display synchronization; even multiples of common display refresh rates will result in better mapping of the frames to the display buffer. ie: 12,15, 30, and 60fps work well because 60hz is a common LCD refresh rate, and is an even multiple of those numbers. Not sure where the "30fps" axiom regarding the limits of human perception and framerates comes from though, but I see it too often in first person shooter videogame forums. In that context (interactive video games), it's incorrect to assert that humans cannot perceive the difference between 60fps and 90fps, or 90fps and 120fps. The differences are very noticeable and the assertion is easily debunked. Even 240fps would be a welcome improvement in games, assuming a display existed that could refresh that quickly. In the context of video, television, compiled animations, 30fps works well enough because the viewer's brain is not interacting with the content.
  4. I'm going to chime here with a possible solution in case someone else has a similar issue. I do this with segmented MovieClip animations, so I would expect the same technique to work with loaded swf file animations. This basically loads all of the swf files up front and pushes them into an Array, then starts a looping sequence of the swf files from the Array. Setup the XML file with the swfloaders: <?xml version="1.0" encoding="UTF-8"?> load="true" name="blue" url="blue.swf"/> load="true" name="green" url="green.swf"/> load="true" name="red" url="red.swf"/> Load the swf files with XMLLoader, push them into an array, then start the loop. import com.greensock.*; import com.greensock.easing.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import com.greensock.loading.display.*; import flash.display.MovieClip; LoaderMax.activate([sWFLoader]); var sprite:Sprite; var selector:int; var swfArray:Array = new Array(); var len:int; var xml:XML; var xmlLoader:XMLLoader = new XMLLoader("data/nav.xml",{name:"xmlData",maxConnections:1,onComplete:initApp,onChildComplete:pushToArray}); xmlLoader.load(); function pushToArray(e:LoaderEvent):void { var swf:MovieClip = e.target.rawContent as MovieClip; swfArray.push(swf); } function initApp(e:LoaderEvent):void { sprite = new Sprite(); selector = 0; len = swfArray.length-1; sprite.addChild(swfArray[selector]); addChild(sprite); addEventListener("next swf", loadNext); } function loadNext(e:Event):void { if (selector < len) { selector++; } else { selector = 0; } trace("selector:" + selector); while (sprite.numChildren > 0) { sprite.removeChildAt(0); } var _swf:MovieClip = MovieClip(swfArray[selector]); _swf.gotoAndPlay(1); sprite.addChild(swfArray[selector]); } At the end of the timeline of each swf file, stop the timeline and dispatch an event. The main timeline is listening for this event, which will trigger the removal of the old swf, and addition of the next swf in the Array. stop(); dispatchEvent(new Event("next swf", true));
  5. Thanks guys. I put this little script at the beginning of my enter frame loop to solve the problem. Basically, I'm checking if landscape.x is equal to its negative width, then setting its x value to 0 if it's true. It's visually seamless and the hitTest works on subsequent loops. Hope I'm not creating another problem by doing it this way. I assume I am still leveraging the performance benefits of the BlitMask, although I am technically kludging a bit here. function scrollPanel(e:Event):void { if (landscape.x == -landscape.width) { landscape.x = 0; lsm.update(null,true); } Love the new classes, especially LoaderMax. Great tutorials Carl!
  6. I'm having trouble with the BlitMask "wrap" feature in a game Im working on. Basically, the game is a car on a scrolling landscape, with obstacles to avoid hitting using the UP and DOWN arrow keys; the "road" is actually an empty strip in the scrolling landscape) http://www.byrographics.com/flash/drivingGame/ Once the scrolling MovieClip (the landscape) has reached the end of the first loop (scrolled on the x-axis to the actual length of the horizontal panel being scrolled; about 6000 pixels), my hitTest function completely stops working. The masking, wrapping and runtime performance continue to function perfectly. Just the hitTest fails. Thanks Here's the code for the BlitMask: lsm = new BlitMask(landscape,0,0,stage.stageWidth,stage.stageHeight,true,true,0,true); lsm.enableBitmapMode(); Here's the bitmapData code for the hitTest: var carRect:Rectangle = car.getBounds(this); var carBmpData = new BitmapData(carRect.width,carRect.height,true,0); carBmpData.draw(car); var landscapeRect:Rectangle = landscape.getBounds(this); var landscapeBmpData = new BitmapData(landscapeRect.width,landscapeRect.height,true,0); landscapeBmpData.draw(landscape); Here's the scrolling function (enter frame loop) that contains the hitTest: function scrollPanel(e:Event):void { if (up) { car.y -= speed; } if (down) { car.y += speed; } if (carBmpData.hitTest(new Point(car.x,car.y),255,landscapeBmpData,new Point(landscape.x,landscape.y),255)) { gamestarted = false; timer.stop(); stage.removeEventListener(Event.ENTER_FRAME, scrollPanel); controls.txt.text = "You Crashed!"; car.gotoAndStop(2); TweenMax.to(car, 1, {scaleX:10, scaleY:10, alpha:0, ease:Quad.easeOut}); if (highscore < score) { highscore = score; controls.highScoreText.text = "High Score: " + highscore.toString(); } score = 0; } else { controls.txt.text = "Drive Safely!"; landscape.x -= speed * 4; lsm.update(null, true); } }
×
×
  • Create New...