A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: getbounds problem with tweenlite

  1. #1
    Member
    Join Date
    Jun 2011
    Posts
    85

    Unhappy getbounds problem with tweenlite

    Hi,

    I have a bitmapData that I want to scale with TweenLite but when applying
    the transformaroundcenter plugin I get this error message:

    "Property getBounds not found on flash.display.BitmapData and there is no default value."

    What am I doing wrong and where do I have to place the "activate" line (e.g. into the constructor, other functions, etc.)?

    Can anyone help, please? Thanks.

    Code:
    import com.greensock.*;
    import com.greensock.TweenLite;
    import com.greensock.plugins.TweenPlugin;
    import com.greensock.plugins.TransformAroundCenterPlugin;
    TweenPlugin.activate([TransformAroundCenterPlugin]);
    
    TweenLite.to(tempScore.bitmapData, 2, {transformAroundCenter: {scale:2}});
    Last edited by drpelz; 07-13-2011 at 09:56 PM.

  2. #2
    Junior Member
    Join Date
    Feb 2010
    Posts
    28
    You should import like this:
    Actionscript Code:
    import com.greensock.*;
    import com.greensock.easing.*;
    import com.greensock.plugins.*;
    TweenPlugin.activate([TransformAroundCenterPlugin,TransformAroundPointPlugin]);
    along with TransformAroundPointPlugin, it works for me like this..If You set the bitmapData correctly, it should work..

  3. #3
    Member
    Join Date
    Jun 2011
    Posts
    85
    Sorry for my late reply. It's not working. I still get error-messages. Tweenlite does not work.
    The bitmaps use some transparency. Please - has anyone any ideas why it's not working?

    When using a getBounds-Method I get this (working):

    Code:
    tempScore.bitmap.getBounds(this)(x=2.35, y=-0.45, w=25, h=18)
    There's another strange error message now:

    Code:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    	at com.greensock.plugins::TransformAroundPointPlugin/onInitTween()
    	at com.greensock.plugins::TransformAroundCenterPlugin/onInitTween()
    	at com.greensock::TweenLite/init()
    	at com.greensock::TweenLite/renderTime()
    	at com.greensock.core::SimpleTimeline/renderTime()
    	at com.greensock::TweenLite$/updateAll()
    My imported and activated libraries look like this:
    Code:
    import com.greensock.*;
    	import com.greensock.TweenLite;
    	import com.greensock.plugins.TweenPlugin;
    	import com.greensock.plugins.TransformAroundCenterPlugin;
    	import com.greensock.plugins.TransformAroundPointPlugin;
    	import com.greensock.easing.*;
    	import com.greensock.plugins.AutoAlphaPlugin;
    	import com.greensock.plugins.ColorTransformPlugin;
    	import com.greensock.plugins.ColorMatrixFilterPlugin;
    	
    	TweenPlugin.activate([TransformAroundCenterPlugin, TransformAroundPointPlugin, ColorTransformPlugin,
    						  ColorMatrixFilterPlugin]);
    This is the part where I try to use TweenLite on my object (tempScore.bitmap):

    Code:
    var scoreTextLength:int = scoreManager.scores.length - 1;
    			for (var counter:int = scoreTextLength; counter >= 0; counter--)
    			{
    					
    					tempScore = scoreManager.scores[counter];
    					tempScore.startDelay = true;
    					
    					TweenLite.to(tempScore.bitmap, 2, {transformAroundCenter: {scale:2}});
    					trace("tempScore.bitmap.getBounds(this)" + tempScore.bitmap.getBounds(this));
    					
    					if (tempScore.update())
    					{
    						
    						disposeScore(counter);
    						
    					}
    			}

    So far as I can see the getBounds-values are ok. My game is based on a gameframework. There's a renderer inside of it.
    Call me an idiot if I'm wrong but is it possible that the renderer of the framework and tweenlite are getting
    in each other's way??

    TweenLite has problems with other similar objects like tempAsteroid. A lot of objects are drawn onto
    a canvas with copyPixels.

    Here is some code of the BasicBlitArrayObject (tempScore rests upon that):

    Code:
    package com.framework_mod.src
    {
    	import flash.display.BitmapData;
    	import flash.geom.Point;
    	import flash.events.EventDispatcher;
    	import flash.geom.Rectangle;
    	import flash.display.Bitmap;
    
    		public class BasicBlitArrayObject extends EventDispatcher{
    		
    		public var x:Number = 0;
    		public var y:Number = 0;
    		public var nextX:Number = 0;
    		public var nextY:Number = 0;
    		public var dx:Number = 0; 
    		public var dy:Number = 0;
    		public var frame:int = 0;
    		public var bitmapData:BitmapData;
    		public var bitmap:Bitmap;
    		public var animationList:Array = [];
    		public var testList:Array = [];
    		
    		public var point:Point = new Point(0, 0);
    		public var speed:Number = 0;
    		
    		public var xMax:int = 0;
    		public var yMax:int = 0;
    		public var xMin:int = 0;
    		public var yMin:int = 0;
    		
    		public var aniType:int = 1;
    		
    		public var health:int = 0;
    		public var _size:int = 0;
    		public var score:int = 0;
    		public var _damage:int = 0;
    		public var count:int = 0;
    		public var bitmapSize:int = 0;
    		public var life:int = 0;
    		public var lifeCount:int = 0;
    		public var startCount:Boolean;
    		public var _delay:int = 0;
    		public var delayCount:int = 0;
    		public var startDelay:Boolean;
    		public var _stop:int;
    		public var stopAni:Boolean;
    		public var stopAniCount:int = 0;
    		public var _type:int = 0;
    		public var shield:int = 0;
    		public var healthPoints:int = 0;
    		public var widthObject:int;
    		public var heightObject:int;
    		public var boost:Number;
    		public var boostLfe:int;
    		public var weaponLfe:int;
    		public var _projXAdjust:Number;
    		public var _projYAdjust:Number;
    		public var number:int;
    		public var _offset:int;
    		public var marked:Boolean;
    		public var objMove:Boolean;
    		
    		public var removeObj:Boolean;
    		public var finished:Boolean;
    		
    		
    		
    		public function BasicBlitArrayObject(xMin:int, xMax:int, yMin:int, yMax:int) 
    		{
    			this.xMin = xMin;
    			this.xMax = xMax;
    			this.yMin = yMin;
    			this.yMax = yMax;
    			//trace("basicblittarrayobject");
    		}
    		
    		
    		
    		public function updateFrame(inc:int, aniType:int = 1):void
    		{
    			frame += inc;
    			switch (aniType) {
    			case 1:	
    					if (frame > animationList.length - 1){
    						frame = 0;
    					}
    					bitmapData = animationList[frame];					
    					break;
    					
    					
    			case 2:	
    					if (frame > animationList.length - 1){
    						frame = 0;
    					}
    					bitmapData = animationList[1][frame];
    					
    					
    					break;
    			}
    			
    			
    		}	
    		
    		
    		
    		public function render(canvasBitmapData:BitmapData):void {
    			x = nextX;
    			y = nextY;
    			point.x = x;
    			point.y = y;			
    			
    			canvasBitmapData.copyPixels(bitmapData, bitmapData.rect, point);
    		}
    		
    		
    		public function dispose():void {
    			bitmapData.dispose();
    			bitmapData = null;
    			bitmap = null;
    			animationList = null;
    			point = null;
    		}
    		
    	}
    
    }
    Last edited by drpelz; 07-18-2011 at 01:14 PM.

  4. #4
    Junior Member
    Join Date
    Feb 2010
    Posts
    28
    I dont know if this can be done?
    Actionscript Code:
    var bitmapBounds:Rectangle = tempScore.bitmap.getBounds(this)...
    bitmapBounds.contains(bla,bla)...
    And to Tweenlite that?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center