Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Editing a .swf file using p-code

Skilled Illusionist
Joined
Apr 4, 2013
Messages
377
Reaction score
146
The result could look like this:
ref_2 - Editing a .swf file using p-code - RaGEZONE Forums
ref_1 - Editing a .swf file using p-code - RaGEZONE Forums
In this tutorial we'll be messing with a simple button. You'll need a program called JPEXS Flash Decompiler, which can be found at:

This will be used to de-compile the existing resources and ActionScript. Editing p-code can become nearly indomitable and super disordered, take breaks if you feel like you are not making any progress.

Changing what the "My servers" button does
First we will navigate to scripts > warz > frontend > PlayGameScreen.
Laenoar - Editing a .swf file using p-code - RaGEZONE Forums
THE MOST IMPORTANT THING WHILE EDITING A .SWF FILE:
Never edit ActionScript directly unless you are adding an import! NEVER! It WILL leave your .swf file unusable.

Importing something
Because I want the same window as the "GC Transactions" to show up when I press the My Servers button, I am gonna be needing an import required to add functionality to the scroll bar. This is the "Tweener" import. Press "Edit ActionScript" and add the following code underneath or above all other imports:
Code:
import caurina.transitions.Tweener;

Then press "Save".
Laenoar - Editing a .swf file using p-code - RaGEZONE Forums

I want the client to request 4 values from the server when the user presses the button, so we'll start by adding a private variable which we can use later in the code. Press the "Add trait" button and create a new private variable named anything, in this case "ReferralData".
Laenoar - Editing a .swf file using p-code - RaGEZONE Forums

It will look like this:
Code:
private var ReferralData:int = 0;

Click your mouse anywhere on that line of code, and on the right side of your screen you should notice some p-code shows up.
Laenoar - Editing a .swf file using p-code - RaGEZONE Forums

Press the "Edit P-code" button, and now you are ready to edit. I want the variable to be an array with a value of zero, so I make the code look like following:

Code:
trait slot Qname(PrivateNamespace("warz.frontend:PlayGameScreen"),"ReferralData")
slotid 0
type Qname(PackageNamespace(""),"Array")
value Null
end

Next, I'll add 2 more variables for the scroller that is going to show up when the window opens. One named "Scroller" and the other "ScrollerIsDragging". Respectively they are a MovieClip and Boolean. The code will look like the following:

Scroller
Code:
trait slot Qname(PrivateNamespace("warz.frontend:PlayGameScreen"),"Scroller")
slotid 0
type Qname(PackageNamespace("flash.display"),"MovieClip")
value Undefined
end

​ScrollerIsDragging
Code:
trait slot Qname(PrivateNamespace("warz.frontend:PlayGameScreen"),"ScrollerIsDragging")
slotid 0
type Qname(PackageNamespace(""),"Boolean")
value Undefined
end

Now I am ready to add 3 events, 2 of which are already existing in PlayGameScreen, 1 which isn't. I look at the following 4 lines of code:
Code:
this.PlayGame.BtnSBrowser.Btn.addEventListener(MouseEvent.MOUSE_OVER,this.BtnRollOverFn);         
this.PlayGame.BtnSBrowser.Btn.addEventListener(MouseEvent.MOUSE_OUT,this.BtnRollOutFn);         
this.PlayGame.BtnSBrowser.Btn.addEventListener(MouseEvent.MOUSE_DOWN,this.BtnPressFn);         
this.PlayGame.BtnSBrowser.Btn.addEventListener(MouseEvent.MOUSE_UP,this.BtnPressUpFn);

I "need" (don't actually need because they're only visual effects) BtnRollOverFn and BtnRollOutFn. I am also going to be adding a third, an on-click event.

The de-obfuscated code for the first line looks like the following:
Code:
this.PlayGame.BtnSBrowser.Btn.addEventListener(MouseEvent.MOUSE_OVER,this.BtnRollOverFn);

In p-code, this will look like:
Code:
getlocal_0

getproperty Qname(PackageNamespace(""),"PlayGame")

getproperty Multiname("BtnSBrowser",[PrivateNamespace(null,"18"),PackageNamespace(""),PrivateNamespace(null,"70"),PackageNamespace("warz.frontend"),PackageInternalNs("warz.frontend"),Namespace("http://adobe.com/AS3/2006/builtin"),PackageNamespace("warz.dataObjects"),PackageNamespace("flash.events"),ProtectedNamespace("warz.frontend:PlayGameScreen"),StaticProtectedNs("warz.frontend:PlayGameScreen"),StaticProtectedNs("flash.display:MovieClip"),StaticProtectedNs("flash.display:Sprite"),StaticProtectedNs("flash.display:DisplayObjectContainer"),StaticProtectedNs("flash.display:InteractiveObject"),StaticProtectedNs("flash.display:DisplayObject"),StaticProtectedNs("flash.events:EventDispatcher")])

getproperty Multiname("Btn",[PrivateNamespace(null,"18"),PackageNamespace(""),PrivateNamespace(null,"70"),PackageNamespace("warz.frontend"),PackageInternalNs("warz.frontend"),Namespace("http://adobe.com/AS3/2006/builtin"),PackageNamespace("warz.dataObjects"),PackageNamespace("flash.events"),ProtectedNamespace("warz.frontend:PlayGameScreen"),StaticProtectedNs("warz.frontend:PlayGameScreen"),StaticProtectedNs("flash.display:MovieClip"),StaticProtectedNs("flash.display:Sprite"),StaticProtectedNs("flash.display:DisplayObjectContainer"),StaticProtectedNs("flash.display:InteractiveObject"),StaticProtectedNs("flash.display:DisplayObject"),StaticProtectedNs("flash.events:EventDispatcher")])

getlex Qname(PackageNamespace("flash.events"),"MouseEvent")

getproperty Qname(PackageNamespace(""),"MOUSE_OVER")

getlocal_0

getproperty Qname(PrivateNamespace(null,"18"),"BtnRollOverFn")

callpropvoid Multiname("addEventListener",[PrivateNamespace(null,"18"),PackageNamespace(""),PrivateNamespace(null,"70"),PackageNamespace("warz.frontend"),PackageInternalNs("warz.frontend"),Namespace("http://adobe.com/AS3/2006/builtin"),PackageNamespace("warz.dataObjects"),PackageNamespace("flash.events"),ProtectedNamespace("warz.frontend:PlayGameScreen"),StaticProtectedNs("warz.frontend:PlayGameScreen"),StaticProtectedNs("flash.display:MovieClip"),StaticProtectedNs("flash.display:Sprite"),StaticProtectedNs("flash.display:DisplayObjectContainer"),StaticProtectedNs("flash.display:InteractiveObject"),StaticProtectedNs("flash.display:DisplayObject"),StaticProtectedNs("flash.events:EventDispatcher")]) 2

I already determined I want the "My Servers" button to get a different function, so the only part of the code I need to edit is:

Code:
getproperty Multiname("[B]BtnSBrowser[/B]",[PrivateNamespace(null,"18"),PackageNamespace(""),PrivateNamespace(null,"70"),PackageNamespace("warz.frontend"),PackageInternalNs("warz.frontend"),Namespace("http://adobe.com/AS3/2006/builtin"),PackageNamespace("warz.dataObjects"),PackageNamespace("flash.events"),ProtectedNamespace("warz.frontend:PlayGameScreen"),StaticProtectedNs("warz.frontend:PlayGameScreen"),StaticProtectedNs("flash.display:MovieClip"),StaticProtectedNs("flash.display:Sprite"),StaticProtectedNs("flash.display:DisplayObjectContainer"),StaticProtectedNs("flash.display:InteractiveObject"),StaticProtectedNs("flash.display:DisplayObject"),StaticProtectedNs("flash.events:EventDispatcher")])

I will change that to BtnMyServers. Next, I'll paste all that code underneath the end of the previous code. I'll do the same for the BtnRollOutFn event, copy the p-code, paste it underneath, and chance BtnSBrowser to BtnMyServers. Now, I'm gonna add a new event, an on-click event. I'll paste the same code again, change BtnSBrowser to BtnMyServers, and also change the following line of code:
Code:
getproperty Qname(PackageNamespace(""),"MOUSE_OUT")

To:
Code:
getproperty Qname(PackageNamespace(""),"CLICK")

Now I'll go to the next getlocal_o and remove the getproperty Qname line, and replace it with the following:
Code:
getproperty Qname(PackageNamespace(""),"ShowRefLogPressFn")

Now I'll copy the Scroller and ScrollerIsDragging p-code from MarketplaceScreen and change any line that says this.Marketplace.Scroller to this.PlayGame.PopupReferrals.Scroller;.

In the previous on-click event I told it to execute a function called ShowRefLogPressFn. This function does not exist yet so I'll have to add it. Once again, I press the "Add trait" button and add a public method called ShowRefLogPressFn.

VERY IMPORTANT: I edit the function and add 3 new lines to it:
Code:
name "warz.frontend:PlayGameScreen/ShowRefLogPressFn"
flag HAS_PARAM_NAMES
param Qname(PackageNamespace("flash.events"),"Event")

You NEED to give it a name and event, otherwise the SWF file won't know what code to execute. Just naming it "ShowRefLogPressFn" is NOT enough. You could theoretically name the public method "ShowIDontCare", as long as you add those 3 pieces of line, it will be named as "ShowRefLogpressFn".

Next, I add the following lines of p-code inside the method:

The end result is a functional button, that executes the ShowRefLogPressFnmethod when pressed. This is not a complete tutorial and copy-pasting this will lead to nothing but errors, it requires a lot more work which I might cover in future tutorials.

Please leave any questions you may have below.
 

Attachments

You must be registered for see attachments list
Newbie Spellweaver
Joined
Jan 19, 2015
Messages
52
Reaction score
43
We need more of this SWF stuff, people(*couch* me) will eventually learn and we will see new stuff.

Super awesome thank you very much lars <3
 
Experienced Elementalist
Joined
May 28, 2017
Messages
225
Reaction score
127
To weird how he do that, I just use Adobe Animated and edit the .as files or if I only want to change the design than I edit it with the editor... to add new tabs to the frontend or some other things are easier than you guys think.
 
Skilled Illusionist
Joined
Apr 4, 2013
Messages
377
Reaction score
146
To weird how he do that, I just use Adobe Animated and edit the .as files or if I only want to change the design than I edit it with the editor... to add new tabs to the frontend or some other things are easier than you guys think.

This is for people who only have the .swf file and not the source files (.as)........
 
Back
Top