A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Need help with glowing problem in AS3 - will pay

  1. #1
    Registered User
    Join Date
    Jan 2014
    Posts
    1

    Need help with glowing problem in AS3 - will pay

    Hi all,

    I need help as I've got a problem with my AS3 game that I'm making.

    I've got a function that make my items glow when you drag them on an other item.
    Unfortunately, filters are not supported in GPU render mode on mobile device (Android and IOS).
    And I can't use "Auto" or "CPU" as animation goes a lot smoother with GPU render mode.

    Can someone help me (I'll pay you of course), by making the item glows when you drag them on an other item on mobile device ?
    (it works with the simulation device on a computer but not on an actual device...).

    Here's what it's in my draggeditem.as file (see the function "itemGlow") :

    I just need to know what are your prices and I'll send you my fla project.

    Thank you.



    Code:
    	public class DraggedItem extends MovieClip{
    		
    		private var stageRef:Stage;
    		private var draggedItem:MovieClip;
    		private var newFriend:MovieClip;
    		private var itemRef:Object;
    		private var timer:Timer;
    		private var playerAction:PlayerAction;
    		private var toolbar:Toolbar;
    		private var inv:Inventory;
    		private var player:Player;
    		private var usableItems:Array = new Array;
    		private var speech:Speech;
    		private var puzzle:Puzzle;
    		private var dialog:Dialog;
    		private var linesData:Object;
    		
    		private var itemScale:Number = .75;
    		
    		public function DraggedItem(stageRef:Stage, grabbedItem:Object){
    			
    			this.stageRef = stageRef;
    			toolbar = Engine.toolbar;
    			usableItems = Engine.usableItems;
    			inv = Engine.inv;
    			puzzle = Engine.puzzle;
    			player = Engine.player;
    			linesData = Engine.linesData;
    			timer=new Timer(500, 1);
    
    			
    			inv.draggingItem = true;
    			Mouse.hide();
    			
    			itemRef = getDefinitionByName(grabbedItem.displayName.toLowerCase()+"Proper");
    			draggedItem = new itemRef;
    			stageRef.addChild(draggedItem);
    			draggedItem.displayName = grabbedItem.displayName;
    			if (grabbedItem.lookTag)
    				draggedItem.lookTag = grabbedItem.lookTag;
    			draggedItem.x = stageRef.mouseX;
    			draggedItem.y = stageRef.mouseY;
    			draggedItem.scaleX = itemScale;
    			draggedItem.scaleY = itemScale;
    			stageRef.addEventListener(MouseEvent.MOUSE_MOVE, dragItem, false, 0, true);
    			stageRef.addEventListener(Event.ENTER_FRAME, itemHitTest, false, 0, true);
    			draggedItem.addEventListener(MouseEvent.MOUSE_DOWN, itemClick, false, 0, true);
    			stageRef.addEventListener(MouseEvent.MOUSE_DOWN, removeDraggedItem);
    		}
    		private function dragItem(e:MouseEvent):void{
    			draggedItem.x = stageRef.mouseX;
    			draggedItem.y = stageRef.mouseY;
    		}
    		private function itemHitTest(e:Event):void{
    			newFriend = null;
    			itemGlow(false);
    			for (var i in usableItems){
    				var thi****Area = usableItems[i];
    				if (usableItems[i].usableArea)
    					thi****Area = usableItems[i].usableArea;
    				if (draggedItem.hitTestObject(thi****Area) && usableItems[i].visible){
    					itemGlow(true);
    					newFriend = usableItems[i];
    					var currentText:String = "Use "+draggedItem.displayName+" on "+newFriend.displayName;
    				}
    			}
    		}
    		public function itemClick(e:Event):void{
    			inv.draggingItem = false;
    			var nameofMC:String;
    			var tempMC;
    			var draggedName:String = draggedItem.displayName;
    			if (draggedItem.lookTag)
    				draggedName = draggedName + draggedItem.lookTag;
    			if (newFriend){
    				nameofMC = "action_"+draggedName+"_"+newFriend.displayName;
    				//trace ("Looking for "+nameofMC);
    				try {
    					tempMC = getDefinitionByName(nameofMC);
    					//trace ("MC found.");
    					removeobjet();
    					if (speech)
    						speech.dispatchEvent(new Event("stopTalking"));
    					tempMC = new tempMC;
    					playerAction = new PlayerAction(stageRef, draggedItem, newFriend, tempMC, false);
    				}
    				catch(e){
    					//trace ("No MC found.  Checking for dialog option...");
    					try {
    						var tempData = linesData.dialog[newFriend.displayName].useObject[draggedItem.displayName];
    						if (tempData != "" && tempData != null){
    							//trace ("Dialog option found.");
    							removeobjet();
    							alignPlayer();
    							if (speech)
    								speech.dispatchEvent(new Event("stopTalking"));
    							dialog = new Dialog(stageRef, newFriend, draggedItem, false);
    						} 
    					}
    					catch(e){
    						//trace ("No dialog option found.  Defaulting to player line.");
    						alignPlayer();
    						if (speech)
    							speech.dispatchEvent(new Event("stopTalking"));
    						var actionName:String = "Use_"+newFriend.displayName;
    						if (newFriend.lookTag)
    							actionName = actionName+newFriend.lookTag;
    						speech = new Speech(stageRef, draggedItem, actionName);
    					}
    						
    				}
    			} 
    				
    		}
    		
    private function removeDraggedItem(e:MouseEvent){
                 if(timer.running==true)
                {
                      if(e.buttonDown)
                    {
                stageRef.removeEventListener(MouseEvent.MOUSE_MOVE, dragItem);
                stageRef.removeEventListener(Event.ENTER_FRAME, itemHitTest);
                draggedItem.removeEventListener(MouseEvent.MOUSE_DOWN, itemClick);
     
               if( draggedItem.parent )
    {
        draggedItem.parent.removeChild(draggedItem);
    }
     
                if (stageRef.contains(this))
                    stageRef.removeChild(this);
     
                Mouse.show();
                Engine.playerControl = true;
                    }
                }
     
                else   if(e.buttonDown)
                {
                    timer.start();
                }
            }
    		private function removeobjet():void{
    			stageRef.removeEventListener(MouseEvent.MOUSE_MOVE, dragItem);
    			stageRef.removeEventListener(Event.ENTER_FRAME, itemHitTest);
    			draggedItem.removeEventListener(MouseEvent.MOUSE_DOWN, itemClick);
    				
    			stageRef.removeChild(draggedItem);
    
    				
    			if (stageRef.contains(this))
    				stageRef.removeChild(this);
    				
    			Mouse.show();
    			Engine.playerControl = true;
    		}
    			
    		
    		private function alignPlayer():void{
    			// Make sure the player is looking at the thing
    					
    			if (newFriend.x > player.x && player.scaleX < 0){
    				player.scaleX = -player.scaleX;
    			}
    			if (newFriend.x < player.x && player.scaleX > 0){
    				player.scaleX = -player.scaleX;
    
    			}
    		}
    		
    		public function itemGlow(isGlowing:Boolean):void{
    			if (isGlowing){
    				var glow:GlowFilter = new GlowFilter();
    				glow.color = 0xFFFF00;
    				glow.alpha = .75;
    				glow.blurX = 10;
    				glow.blurY = 10;
    				glow.quality = BitmapFilterQuality.MEDIUM;
    
    				draggedItem.filters = [glow];
    				
    			} else {
    				draggedItem.filters = null;
    			}
    		}
    	}//end class
    }//end package
    
    
    Thank you very much,

  2. #2
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,145
    You can get free help for this. Just post in AS3 or Gaming.

    For optimization, you can create whatever you want in normal flash and create bitmaps out of the movieclips. Remove all the movieclips and use the bitmaps. Normally, you can move the bitmaps around like regular movieclips and you'll be fine. You can learn stage3D and blitting if you need more optimization.

    One big point that isn't given its due is never make the bitmaps larger in dimensions than the device's screen (check for max bitmap size).

    gotoandlearn.com has great game coding tutorials - bitmap handling.

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