dimanche 26 mars 2017

How Can I convert Parts of Scripts to where it's Readable

I'm trying to Decode some .as and some .hex in order to get the Codes. This Code is from the Game War Commander.

  private static const const_792:Vector.<uint> = new <uint>[16763904,7535299];

  private static const const_1016:Vector.<uint> = new <uint>[530,530];

The part I need help is, How or Where Can I decode the: [16763904,7535299]; In doing so, I think that might be the Unit codes for the Phantom. Here is the Whole class:

public class PhantomReticle extends class_724 {

  private static const const_4425:String = "ui/phantom_unit/PhantomReticle.xml";

  private static const const_5194:String = "phantomReticleA";

  private static const const_3919:String = "phantomReticleB";

  private static const const_792:Vector.<uint> = new <uint>[16763904,7535299];

  private static const const_1016:Vector.<uint> = new <uint>[530,530];

  private static const const_5133:int = 2;

  private static const const_7028:Number = 10;

  private static const const_5629:Number = 100.0;

  private static const const_4926:int = 100;

  private var var_2288:int;

  public function PhantomReticle()
     this.var_2288 = const_4926;

  public function method_8357(param1:int) : void
     this.var_2288 = param1;

  override public function get maxReticlesUsed() : int
     return const_5133;

  override protected function method_2306() : String
     return const_4425;

  override protected function setup() : void

  protected function method_5112() : void
     var _loc1_:Number = this.var_2288 / const_1016[0];
     var _loc2_:Number = this.var_2288 / const_1016[1];
     var_242[0].container.scaleX = _loc1_;
     var_242[0].container.scaleY = _loc1_ * 0.5;
     var_242[1].container.scaleX = _loc2_;
     var_242[1].container.scaleY = _loc2_ * 0.5;

Parsing Javascript variable to AS3

I'm trying to write a simple 2 way chat but got a problem. I'm sure it's very basic but couldn't figure out since I'm new to this.

Below is my JS code to pass a streamID to AS3:

    url: ajaxurl,
    type: 'POST',
    data: 'action=sd_chat_code&chat_code='+chat_code,
    success: function(data){
    error: function(data) {

and in AS file, I got the streamID passed through as below:

public function streamCompanion(data):void {
    var netStreamObj:NetStream = new NetStream(_nc);

the variable "data" above return "12345" correctly, I tried to output is via JS and there's nothing wrong:

ExternalInterface.class("function() { console.log("+data+") }")

the problem is netStreamObj.play(data) not working, but if I manually type in netStreamObj.play('12345'), it's working correctly.

Any advice would be greatly appreciated.

Array: Term is undefined & has no properties

c is just a letter that I used for the array set. The bold line is the main problem.

function coinsCollect()

    This line simply calls on all the objects in the specified array (i.e. coins) amd applies the codes to all objects in the array.

    for(var c:int = 0; c < coins.length; c++) 
        for more precise collision, use hitTestPoint

sound effect for coin sounds; same sound channel is used for all sound effects
            //frame 2 of coins is a blank keyframe

ActionScript 3 mx mx:HorizontalList set columns per row

I have a Flex HorizontalList like so:

<mx:HorizontalList id="myList" width="1462" height="878" columnCount="3" rowHeight="475" columnWidth="350" dataProvider="{floorPlans}" itemRenderer="FloorplanItems">


I am trying to set 3 columns per a row, I thought columnCount would do it, but either its not working and or is not doing what I thought it would be doing.

How can I set 3 columns per a row?

samedi 25 mars 2017

Actionscript 3 setStyle is not a function

I am trying to style a Flex 4 GridItem using actionscript, I have tried the following:

    height="878" width="1920"
    xmlns:s="library://ns.adobe.com/flex/spark" xmlns:local="*" creationComplete="addStyles()">


            public var selectedLot:String = "";

            private function addStyles():void
                testBorder.setStyle("borderThickness", "3");

but I get the following error:

setStyle is not a function.

Am I missing something?

The GridItem is inside a repeater.

Adobe Flex 4.6 Remove Gap in between GridItems

I am using Flex 4.6 and I am fairly new to it...I am using a Grid and inside my Grid is a GridRow and inside this GridRow are 3 GridItems, each item has a border, but there is a gap in between each item and I can't figure out how to get ride of them...here is my code:

                                                                        <mx:GridItem width="101" height="52.25" horizontalAlign="center" verticalAlign="middle" borderStyle="solid" borderColor="gray">
                                                                            <mx:Image source="assets/ruler-icon.png" />
                                                                            <s:Label text="{r.currentItem.sqft} sq.ft." fontSize="10" color="#808080" fontFamily="Helvetica" />
                                                                        <mx:GridItem width="101" height="52.25" horizontalAlign="center" verticalAlign="middle" borderStyle="solid" borderColor="gray">
                                                                            <mx:Image source="assets/bed-icon.png" />
                                                                            <s:Label text="{r.currentItem.bed}" fontSize="10" color="#808080" fontFamily="Helvetica" />
                                                                        <mx:GridItem width="101" height="52.25" horizontalAlign="center" verticalAlign="middle" borderStyle="solid" borderColor="gray">
                                                                            <mx:Image source="assets/bath-icon.png" />
                                                                            <s:Label text="{r.currentItem.bath}" fontSize="10" color="#808080" fontFamily="Helvetica" />

Any help will be much appreciated.

How can I efficiently update animations in my game?

For each character skin, it has 4 MovieClips corresponding to each possible direction (up, down, left, and right).


For my Player 1 skin, it would be like this.

Player 1 Up Animation (P1UAnim_mc)

Player 1 Down Animation (P1DAnim_mc)

Player 1 Left Animation (P1LAnim_mc)

Player 1 Right Animation (P1RAnim_mc)

Now, the way my movement works is we have a Movieclip that matches the size of the animations (they don't change in size), and this Movieclip is invisible, and this is what moves when we tell it to (I call it a player position keeper). This is done by clicking a direction on the DPAD, where we then move the player in the appropriate direction with the coressponding walkspeed for that direction, then we check if we hit something in my array of obstacles. If we did, we move the player back.

So now that we have that out of the way, I need to have animations that correspond to the direction and character skin the player is using/going in.

One idea I had, had an event listener for every time we enter a frame, where we check what charSkin the player is using, then check the direction, and then add the appropriate animation. We do not need to update the animations x,y coordinates because in their class file it is always updating itself, and knows when to remove itself. So all I need to do is find the appropriate time to add it and leave the rest to the animation's class.

My problem with this technique I tried was the code was really difficult to understand, it was a barrage of if else statements checking the factors mentioned above.

Here is my MovementReworked class which does not include the animations, so that you guys can actually read it. If you want me to edit the post and add the Movement class with sloppy animations code as well, I will, but it's pretty unreadable.

    import flash.display.Stage;
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.TouchEvent;
    import flash.net.dns.AAAARecord;
    import flash.ui.Multitouch;
    import flash.ui.MultitouchInputMode;

    public class MovementReworked extends MovieClip
        public function MovementReworked(main:Game)
            // I will be changing these addChilds in the future
            // Just ignore it for now

            Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

            Game.playerPosKeeper_mc.x = 384;
            Game.playerPosKeeper_mc.y = 46;

            main.up_dpad.x = 55;
            main.up_dpad.y = 336;

            main.down_dpad.x = 57;
            main.down_dpad.y = 432;

            main.left_dpad.x = 19;
            main.left_dpad.y = 372;

            main.right_dpad.x = 118;
            main.right_dpad.y = 372;

            main.menu_dpad.x = 61;
            main.menu_dpad.y = 377;

            main.run_dpad.x = 684;
            main.run_dpad.y = 369;

            main.barrierRoof1_game.x = 0;
            main.barrierRoof1_game.y = 0;

            main.barrierRoof2_game.x = 0;
            main.barrierRoof2_game.y = 470;

            main.barrierRoof3_game.x = 0;
            main.barrierRoof3_game.y = 320;

            main.barrierSide1_game.x = 0;
            main.barrierSide1_game.y = 0;

            main.barrierSide2_game.x = 790;
            main.barrierSide2_game.y = 0;
            // I will be changing these addChilds in the future

            for each (var aButton:MovieClip in main.Buttons)
                aButton.addEventListener(TouchEvent.TOUCH_BEGIN, onDown);
                aButton.addEventListener(TouchEvent.TOUCH_OUT, onUp);
                aButton.addEventListener(TouchEvent.TOUCH_END, onUp);

            function onDown(e:TouchEvent):void
                switch (e.currentTarget)
                    case main.up_dpad :
                        Game.dir = 1;
                        Game._Direction.x = 0;
                        Game._Direction.y = Game.upWalkspeed;
                    case main.down_dpad :
                        Game.dir = 2;
                        Game._Direction.x = 0;
                        Game._Direction.y = Game.downWalkspeed;
                    case main.left_dpad :
                        Game.dir = 3;
                        Game._Direction.x = Game.leftWalkspeed;
                        Game._Direction.y = 0;
                    case main.right_dpad :
                        Game.dir = 4;
                        Game._Direction.x = Game.rightWalkspeed;
                        Game._Direction.y = 0;
                if (Game.idle)
                    Game.idle = false;
                    addEventListener(Event.ENTER_FRAME, onFrame);
            function onFrame(e:Event):void
                movePlayer(Game._Direction.x, Game._Direction.y);

            function onUp(e:TouchEvent):void
                Game.idle = true;
                removeEventListener(Event.ENTER_FRAME, onFrame);

            function movePlayer(movementX:Number, movementY:Number):void
                var originalX:Number = Game.playerPosKeeper_mc.x;
                var originalY:Number = Game.playerPosKeeper_mc.y;
                Game.playerPosKeeper_mc.x +=  movementX;
                if (checkCollision())
                    Game.playerPosKeeper_mc.x = originalX;
                Game.playerPosKeeper_mc.y +=  movementY;
                if (checkCollision())
                    Game.playerPosKeeper_mc.y = originalY;

            function checkCollision():Boolean
                for each (var StageCollisions:MovieClip in main.StageCollisions)
                    if (Game.playerPosKeeper_mc.hitTestObject(StageCollisions))
                        return true;
                        Game.idle = true;
                return false;