Announcement

Collapse
No announcement yet.

Simple Multiple Panel Sorting and Panel Detect Area with Resize Effect

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    This is awesome, Thanks. I have been watching your updates to your scaleform stuff for a while, been trying to figure it all out. You did a really great job, and thanks for releasing this.

    Leave a comment:


  • replied
    Thank you very much.

    but doesn't work in my case.

    Leave a comment:


  • replied
    Nice contribution.

    Leave a comment:


  • Simple Multiple Panel Sorting and Panel Detect Area with Resize Effect

    I hope this will useful for somebody.

    Multiple Panel Sorting

    1. Separate Layer each of Panel Object ( look in picture ).
    2. Customize this ActionScript.

    Code:
    var ArrayOfInstance:Array = new Array();
    ArrayOfInstance[0] = new Array();
    ArrayOfInstance[0][0] = _root.MainObject.Inventory;//Instance Object.
    ArrayOfInstance[0][1] = 0;//Depth Setup.
    ArrayOfInstance[1] = new Array();
    ArrayOfInstance[1][0] = _root.MainObject.Equipment;
    ArrayOfInstance[1][1] = 1;
    ArrayOfInstance[2] = new Array();
    ArrayOfInstance[2][0] = _root.MainObject.Stats;
    ArrayOfInstance[2][1] = 2;
    ArrayOfInstance[3] = new Array();
    ArrayOfInstance[3][0] = _root.MainObject.Shop;
    ArrayOfInstance[3][1] = 3;
    
    var CurrentTopObject:Object = new Object();
    CurrentTopObject = ArrayOfInstance[3][0]; // Set default top Instance.
    Code:
    function DoTopLayer(Instance:Object):Boolean
    {
    	if(Instance != CurrentTopObject)
    	{
    		for(var i:Number = 0; i < ArrayOfInstance.length ; i++)
    		{
    			if(ArrayOfInstance[i][0] == Instance)
    			{
    				for(var k:Number = 0; k < ArrayOfInstance.length ; k++)
    				{
    					if(ArrayOfInstance[i][1] == (ArrayOfInstance[k][1] - 1) )
    					{
    						Instance.swapDepths(ArrayOfInstance[k][0]);//Swap Panel Layer
    						var TempIndex:Number = ArrayOfInstance[i][1];//Swap Index.
    						ArrayOfInstance[i][1] = ArrayOfInstance[k][1];
    						ArrayOfInstance[k][1] = TempIndex;
    						DoTopLayer(Instance);//Recursion
    						CurrentTopObject = ArrayOfInstance[i][0];
    						return true;
    					}
    				}
    				return true;
    			}
    		}
    	}
    	return true;	
    }
    3. Set this code to each of Panel.

    Code:
    //Example : OnPress Background of Panel do top layer.
    _root.MainObject.Inventory.InventoryBG.onPress = function(){
    	_root.DoTopLayer(_root.MainObject.Inventory);
    }
    
    and etc
    
    _root.MainObject......onPress = function(){
    	_root.DoTopLayer(_root.MainObject.....);
    }
    4. Result. You can click and bring that Panel Object to top layer and sort order.



    ---------------------------------------------------------------------
    Panel Detect Area with Resize Effect.

    1. Customize this ActionScript.

    Code:
    var InvBuff:MovieClip = _root.MainObject.Inventory;
    var EquipBuff:MovieClip = _root.MainObject.Equipment;
    var StatsBuff:MovieClip = _root.MainObject.Stats;
    var ShopBuff:MovieClip = _root.MainObject.Shop;
    
    ArrayOfInstance[0] = new Array();
    ArrayOfInstance[0][0] = InvBuff;
    ArrayOfInstance[0][1] = 0;//Buffer End Position X.
    ArrayOfInstance[0][2] = 0;//Buffer End Position Y.
    ArrayOfInstance[0][3] = 0;//Depth
    ArrayOfInstance[0][4] = 280;//Real Width of 100% Scale X
    ArrayOfInstance[0][5] = 480;//Real Height of 100% Scale Y
    ArrayOfInstance[1] = new Array();
    ArrayOfInstance[1][0] = EquipBuff;
    ArrayOfInstance[1][1] = 0;
    ArrayOfInstance[1][2] = 0;
    ArrayOfInstance[1][3] = 1;
    ArrayOfInstance[1][4] = 280;//Width
    ArrayOfInstance[1][5] = 480;//Height
    ArrayOfInstance[2] = new Array();
    ArrayOfInstance[2][0] = ShopBuff;
    ArrayOfInstance[2][1] = 0;
    ArrayOfInstance[2][2] = 0;
    ArrayOfInstance[2][3] = 2;
    ArrayOfInstance[2][4] = 580;//Width
    ArrayOfInstance[2][5] = 480;//Height
    ArrayOfInstance[3] = new Array();
    ArrayOfInstance[3][0] = StatsBuff;
    ArrayOfInstance[3][1] = 0;
    ArrayOfInstance[3][2] = 0;
    ArrayOfInstance[3][3] = 3;
    ArrayOfInstance[3][4] = 280;//Width
    ArrayOfInstance[3][5] = 480;//Height
    2. Set Resize function.

    Code:
    function ResizeUI(ScaleX:Number,ScaleY:Number):Void{
    	for(var i:Number = 0;i< ArrayOfInstance.length;i++)
    	{	
    		ArrayOfInstance[i][0]._xscale = ScaleX;
    		ArrayOfInstance[i][0]._yscale = ScaleY;
    		ArrayOfInstance[i][0].W = ArrayOfInstance[i][4] * (ArrayOfInstance[i][0]._xscale / 100);
    		ArrayOfInstance[i][0].H = ArrayOfInstance[i][5] * (ArrayOfInstance[i][0]._yscale / 100);
    	}
    }
    Don't forgot

    Code:
    import flash.external.ExternalInterface;
    3. Detect Area method.

    Code:
    var detectInventory:Object = new Object();
    detectInventory.onMouseMove = function()
    {	
    	var Check:Boolean = false;
    	for(var i:Number = 0;i< ArrayOfInstance.length;i++)
    	{	
    		//End X
    		ArrayOfInstance[i][1] = ArrayOfInstance[i][0]._x + ArrayOfInstance[i][0].W;
    		//End Y
    		ArrayOfInstance[i][2] = ArrayOfInstance[i][0]._y + ArrayOfInstance[i][0].H;
    		if(_root._xmouse >= ArrayOfInstance[i][0]._x && _root._xmouse <= ArrayOfInstance[i][1]
    		   && _root._ymouse >= ArrayOfInstance[i][0]._y && _root._ymouse <= ArrayOfInstance[i][2])
    		{
    			if(ArrayOfInstance[i][0]._visible)
    			{
    				Check = true;
    				break;
    			}
    			else
    				Check = false;
    		}
    	}
    	
    	if(Check)
    		ExternalInterface.call( "IsDetectArea", true );	
    	else
    		ExternalInterface.call( "IsDetectArea", false );
    
    	updateAfterEvent();
    };
    Mouse.addListener(detectInventory);
    4. Add this to UnrealScript
    Code:
    var bool bIsDetectArea;//Check for detect UI. use for allow click to select object in world
    
    function IsDetectArea(bool bIsDetect)
    {
    	bIsDetectArea = bIsDetect;
    }
    The End
Working...
X