Jump to content
Search Community

BladePoint

Members
  • Posts

    42
  • Joined

  • Last visited

Everything posted by BladePoint

  1. import flash.geom.Matrix3D; import flash.geom.Vector3D; import flash.display.Shape; import com.greensock.*; import com.greensock.easing.*; import com.greensock.plugins.*; TweenPlugin.activate([QuaternionsPlugin]); var rectShape:Shape = new Shape(); rectShape.graphics.beginFill(0x000000); rectShape.graphics.drawRect(0,0,100,200); rectShape.graphics.endFill(); rectShape.x = 225; rectShape.y = 100; rectShape.z = 0; addChild(rectShape); var rectObj:Object = new Object(); var decompose:Vector.<Vector3D> = rectShape.transform.matrix3D.decompose("quaternion"); rectObj.quat = decompose[1]; trace("x:" + rectObj.quat.x + ",y:" + rectObj.quat.y + ",z:" + rectObj.quat.z + ",w:" + rectObj.quat.w); //x:0,y:0,z:0,w:1 TweenLite.to(rectObj, 2, {quaternions:{quat:{x:1, y:0.5, z:0.25, w:0.5}}, onUpdate:recompose}); function recompose():void { decompose[1] = rectObj.quat; rectShape.transform.matrix3D.recompose(decompose,"quaternion"); } * I get this error a bunch of times: * ReferenceError: Error #1069: Property x not found on Number and there is no default value. at com.greensock.plugins::QuaternionsPlugin/_initQuaternion() at com.greensock.plugins::QuaternionsPlugin/_onInitTween() at com.greensock::TweenLite/_initProps() at com.greensock::TweenLite/_init() at com.greensock::TweenLite/render() at com.greensock.core::SimpleTimeline/render() at com.greensock.core::Animation$/_updateRoot()
  2. I found the QuaternionsPlugin, but it seems to require a Quaternion class from an outside library? Is there a way to make it work with Vector3D instead?
  3. I have a 3D object that is rotating randomly about it's x, y, and z axes. I want to be able to stop it in place, then tween its rotation it to a specified rotation taking the shortest possible route. It seems quaternions are the right tool for the job, but I'm not sure how to tween it properly. I'm trying to tween axis-angle rotations, then convert it to a quaternion. Here's my test code so far. var startV3DV:Vector.<Vector3D> = new <Vector3D>[positionV3D, new Vector3D(0,1,0,0), scaleV3D]; var endV3DV:Vector.<Vector3D> = new <Vector3D>[positionV3D, new Vector3D(0,1,0,Math.PI), scaleV3D]; var recomposeV3DV:Vector.<Vector3D> = new <Vector3D>[positionV3D, new Vector3D(0,0,0,0), scaleV3D]; TweenMax.to(startV3DV[1], 2, {x:endV3DV[1].x, y:endV3D[1].y, z:endV3D[1].z, w:endV3D[1].w, onUpdate:quat}); var quatV3D:Vector3D = new Vector3D(); function quat():void { quatV3D.x = currentV3D[1].x * Math.sin(currentV3D[1].w * .5); quatV3D.y = currentV3D[1].y * Math.sin(currentV3D[1].w * .5); quatV3D.z = currentV3D[1].z * Math.sin(currentV3D[1].w * .5); quatV3D.w = Math.cos(currentV3D[1].w * .5); recomposeV3DV[1] = quatV3D; myMatrix3D.recompose(recomposeV3DV,"quaternion"); } It actually tweens the rotation of the object about its y axis for a little while, but when it hits PI/2, it bugs out and I get "ArgumentError: Error #2004: One of the parameters is invalid" on the recompose line, which I think means one of the quatV3D properties doesn't fit the quaternion formula. Any ideas on how to do this properly?
  4. In my game's title screen, I've got some display objects in the background which are all covered by a large partially transparent curtain that fills the screen. Then on top of that I have a large, detailed piece of vector artwork for my game's title. When the game starts, I fade out the title by tweening its alpha from 1 to 0 over 2 seconds or so. The problem is this gets rather choppy on low end systems, I imagine because I'm tweening a transparency over a transparency. I've tried converting my title into a bitmap, and that helps somewhat, but it's still not very smooth on a Pentium 4. Are there any good, fast alternatives to the fading out effect I'm looking for? Like maybe a dissolve effect where every other pixel disappears in a checkerboard pattern, or something like that.
  5. I think I got it now. I need to use Matrix3D.decompose() and Matrix3D.recompose() instead.
  6. Bump from the dead. I am having similar issues with my 3D object. I can rotate it with Matrix3D by doing this: matrix3D.appendRotation(15,Vector3D.X_AXIS); matrix3D.appendRotation(30,Vector3D.Y_AXIS); matrix3D.appendRotation(45,Vector3D.Z_AXIS); But I'm not sure how exactly to tween those 3D rotations instead. I tried messing with my matrix3D.rawData, but it seems only the scale values work as expected. If I change any of the other values, my object gets extremely skewed in weird directions. Edit: It seems working with the rawData is not very intuitive. This is what my trace(matrix3D.rawData) looks like before applying any rotations: 1,0,0,0, 0,1,0,0, 0,0,1,0, 320,180,200,1 And then after doing this matrix3D.appendRotation(15,Vector3D.Z_AXIS); 0.9659258127212524,0.258819043636322,0,0, -0.258819043636322,0.9659258127212524,0,0, 0,0,1,0, 262.5088195800781,256.6887512207031,200,1 I suppose I could find the correct matrix3D.rawData beforehand, and then tween every element to match it? Still, I was hoping there was an easier way. Edit#2: I did just that and it sort of works. My object rotates from the original position to the correct rotation, but along the way it gets squished and scales and translates oddly before it gets there.
  7. Is there a way to detect if an object has a glowFilter applied to it? I would rather not add another property to the object and set it to true/false myself. TweenMax.getTweensOf() doesn't work because the glowFilter isn't tweening, it's just set to a value.
  8. Lets say I've got 10 functions, and each one does some stuff and does a tween, and I want to execute the functions in succession. If I use onComplete on each function's tween to call the next function, will I end up with a huge call stack? Would using delayedCall instead also result in a big call stack? If I used addEventListener and dispatchEvent to call the successive function instead, would that not create a large call stack?
  9. I currently have a sprite that is being translated and rotated: TweenMax.to(mySprite,1,{transformMatrix:{x:100,rotation:-45,ease:Linear.easeNone}}); I want the translation part to use Linear.easeNone and the rotation part to use Cubic.easeOut. If I try to break it up into two different lines, the first line gets ignored: TweenMax.to(CSbinder,.5,{transformMatrix:{x:39.4,ease:Linear.easeNone}}); TweenMax.to(CSbinder,.5,{transformMatrix:{rotation:-45,ease:Cubic.easeOut}}); Does anyone know how I can do this? Thanks.
  10. Thanks, but I just got a better MP3 encoder and dropped the whole AAC thing. I can just put them in the library now.
  11. Yeah, that's exactly what was happening. My [embed]s are actually all FLV videos, so I guess if I replaced those all with LoaderMax's VideoLoaders, that would solve my problems, but I would prefer not to have the FLVs as external files. It seems most Flash portal sites only allow you to upload one SWF, so the external files would have to be hosted elsewhere. That's also why I can't use an external preloader. Here's my whole situation. My Flash webgame is going to have a lot of voiced dialogue, and I wanted at least the beginning parts to be embedded in the SWF. Depending on the total filesize, I might load the rest later or just embed them as well. I found that the AAC audio codec has really good quality at low bitrates versus MP3, but Flash Professional CS6 doesn't natively support AAC so I have to do some workarounds. I have to create an FLV video that has no video track and just my AAC audio track. Then I embed the FLV and make a Video: [Embed(source = "myAudio.flv",mimeType = "application/octet-stream")] public var myAudio:Class; public var fakeFLV:Video = new Video(0,0); Then do the whole NetConnection and NetStream thing: nc = new NetConnection(); nc.connect(null); ns = new NetStream(nc); Make a ByteArray out of my embedded FLV and append it to the NetStream to play it: var myAudioByteArray:ByteArray = new myAudio(); ns.play(null); ns.appendBytes(myAudioByteArray); fakeFLV.attachNetStream(ns); If someone has an idea of how to do what I want to do (1 single SWF with all assets and preloader), I'm open to suggestions. I think there's a way to do it in Flash Builder with the [Frame(factoryClass="")] tag, which does not work in Flash Pro CS6, so I would have to learn how to use Flash Builder instead.
  12. I need my SWF to display a loading progress screen, and the loader cannot be an external SWF file. Also, I have a lot of assets with the [Embed] tag, which caused problems with other internal preloader methods. Will LoaderMax's SelfLoader solve all those problems for me?
  13. Thanks for the reply. That's interesting that motionless vector art still requires a lot of CPU for just sitting there on the screen. The vector art that I've been testing has 2500 points and nearly fills the screen. Turning it into a bitmap makes things significantly smoother. But I just read that BitmapData is uncompressed, and I noticed that my Flash file's memory usage jumped by 10 MB. It seems everything has it's pros and cons. To summarize: 1. Keep it as vector art. PROS: The artwork looks crisp and keeps the file size down. CONS: Very CPU intensive so animation will be choppy on less powerful systems. 2. Convert it to a Bitmap. PROS: Animates faster. File size still low. CONS: Looks fuzzy when zoomed in on high resolution devices. Also eats up a lot of memory. 3. Export/Import as PNG. PROS: Animates faster, but increases file size. Does not use a lot of memory. CONS: Looks fuzzy when zoomed in on high resolution devices.
  14. I have not yet decided to take the plunge into Starling, but my Flash game doesn't have a crazy amount of stuff flying around so I'm hoping I won't really need it. However, it does have vector artwork that tweens through a lot of translating, rotating, scaling, and opacity changes. I recently tested it out on a Pentium 4, and the animation gets rather choppy. If I was using Bitmaps with TweenMax, would it improve performance? My other concern is how the Bitmaps would look at higher resolutions. If I scaled up my vector to 1920x1080 and made my Bitmap at the same resolution, then used TweenLite to shrink it down, would that work? var myVectorArt:Sprite = new vectorArt(); var bmd:BitmapData = new BitmapData(1920,1080); bmd.draw(myVector) myBitmap = new Bitmap(bmd); TweenLite.to(myBitmap, 0, {width:1280,height:720});
  15. I have a rectangular sprite that I want to turn in 2 dimensions so it looks like a card. It begins with rotationX:90 so you only see the edge and tweens to rotationX:0 so its flat. Then I want it to rotate it 180 degress using transformMatrix so it's nice and smooth. TweenLite.from(card, 2, {rotationX:90, onComplete:rotateCard}); function rotateCard():void { TweenMax.from(card, 2, {transformMatrix:{rotation:180}); } That kicks up this error though: TypeError: Error #1009: Cannot access a property or method of a null object reference. at com.greensock.plugins::TransformMatrixPlugin/onInitTween() at com.greensock::TweenLite/init() at com.greensock::TweenMax/init() at com.greensock::TweenMax/renderTime() at com.greensock.core::SimpleTimeline/renderTime() at com.greensock::TweenLite$/updateAll() I read that you can't combine transformMatrix tweens with other transform property tweens so that is probably why. I'm trying to find a way around it though. Here's what I have come up with. 1. After the rotationX, remove card and replace it with a duplicate card in the exact same spot and apply the transformMatrix rotation to the duplicate card. 2. Just use the regular rotation instead of the transformMatrix rotation. 3. Kill the rotationX tween after it's done so it doesn't interfere with the transformMatrix rotation. I couldn't get this to work though. Any other ideas?
  16. I had been using Adobe's Tween class for everything until just now when I discovered TweenMax, and I have to say TweenMax is far superior! But anyways, I had been using a black rectangle to cover the screen and then Tween its alpha from 0 to 1 as a fade to black effect. Should I just keep doing the same thing with TweenMax, or maybe use the TintPlugin on all the objects on the screen? What do you guys think?
×
×
  • Create New...