If you are looking for the decompiler itself, visit https://github.com/jindrapetrik/jpexs-decompiler
NEW : We have got a new blog where we post some interesting SWF internals info.

#306 editing AS directly bug
Author:
honfika

Date created:
Type: bug
Visibility: Everybody
Assigned to:
JPEXS

Labels: AS1/2Direct Editation
State: closed 

> What steps will reproduce the problem?
Try to save the following:
function test()
{
var myArray = new Array();
myArray.push({id:1,value:"value"});
return myArray;
}
> What is the expected output? What do you see instead?
Currently saved:
function test()
{
var _loc1_ = new Array();
_loc1_.push(2);
return _loc1_;
}
Expected: parameter of the push call is an object, not number 2.
> What version of the product are you using? On what operating system?
1.7.0
> Please provide any additional information below. Attach the file you have problem with
if neccessary. If you do not want to publish files YOU CAN CHANGE VISIBILITY TO PRIVATE
Another issue:
Open attached file
find: 100000.swf\scripts\__Packages\DenomButton.as
Edit AS then save it.
Check SetValue method.
Original:
Utils.AutoScale(this.m_Button.texts.denomination,Utils.MoneyToString(amount,Utils.OPT_DECI
MALS));
After save:
this.Utils.AutoScale(this.m_Button.texts.denomination,this.Utils.MoneyToString(amount,this
.Utils.OPT_DECIMALS));
Utils was anouther class. now it is added as a variable.

Another issue (v1.7.0):
try to save the following code:
function test()
{
var a = 1;
var b = 2;
var c = 3;
var d = (a = a + b) + c;
return d;
}
Result:
function test()
{
var _loc1_ = 1;
var _loc2_ = 2;
var _loc3_ = 3;
var _loc4_ = _loc1_ = _loc1_ + _loc2_ + _loc3_;
return _loc4_;
}
Should be:
var _loc4_ = (_loc1_ = _loc1_ + _loc2_) + _loc3_;
Open attached swf.
Find scripts / definesprite 27 / doaction
try to edit and save
result: bit a command on line 173

bit = not
5th issue:
Try to save the following code:
mx.controls.Button.prototype = (new mx.controls.SimpleButton()).init;
result:
mx.controls.Button.prototype = new mx.controls.SimpleButton().init;
which can't be parsed again.
6th issue:
open attached swf
open mx.transitions.BroadcasterMX class
press edit in AS source editor
press save
=> nothing happens, can't exit from editing mode, no error message
Exception in console:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at
com.jpexs.decompiler.flash.action.model.clauses.ClassActionItem.detectUnitializedVars(Clas
sActionItem.java:152)
at
com.jpexs.decompiler.flash.action.model.clauses.ClassActionItem.detectUnitializedVars(Clas
sActionItem.java:145)
at
com.jpexs.decompiler.flash.action.model.clauses.ClassActionItem.detectUnitializedVars(Clas
sActionItem.java:153)
at
com.jpexs.decompiler.flash.action.model.clauses.ClassActionItem.<init>(ClassActionItem.jav
a:82)
at
com.jpexs.decompiler.flash.action.parser.script.ActionScriptParser.traits(ActionScriptPars
er.java:483)
at
com.jpexs.decompiler.flash.action.parser.script.ActionScriptParser.command(ActionScriptPar
ser.java:937)
at
com.jpexs.decompiler.flash.action.parser.script.ActionScriptParser.commands(ActionScriptPa
rser.java:166)
at
com.jpexs.decompiler.flash.action.parser.script.ActionScriptParser.treeFromString(ActionSc
riptParser.java:1830)
at
com.jpexs.decompiler.flash.action.parser.script.ActionScriptParser.actionsFromString(Actio
nScriptParser.java:1857)
at
com.jpexs.decompiler.flash.gui.action.ActionPanel.actionPerformed(ActionPanel.java:660)
...

I pushed some changes to the repository.
It should be much better now.
Try it. And find more bugs if possible! :-)
Ok, I found new problem:)
Open as2.swf (test swf from repository)
Find com.jpexs.MyTest
Click Edit then Save (AS source panel)
It will show 2 constructors.
Click Edit-Save again => 3 constructors.
Everytime a new constuctor is added:)
State: upgraded→returned
Fixed in the repository
State: returned→upgraded
NEw issuse in the same (test) swf:
Open frame 35, edit-save, result:
Parsing finished before end of the file.
Something is wrong withthe following line:
targetPath(f);
targetPath added to actionscript parser.
Please check my changeset: http://code.google.com/p/asdec/source/detail?r=92c51d86b5d159194eacbe91e7911cd8537efd64
Now there is no error after saving, but all the actions are lost after
trace("loaded");
line.
Try to save the following:
var x = true;
while(x)
{
}
Result: Expression expected on line 2
Try to save the following line:
function easeInExpo(t, b, c, d)
{
return t != 0?c * Math.pow(2,10 * (t / d - 1)) + b - c * 0.001:b;
}
Result:
COLON exprected but MULTIPLY found on line 3
I tried to compile it as an AS3 script, there was no compile error. I haven't tried to
compile it as AS2. Is this a valid AS2 function? If it is, then it is a parsing problem,
otherwise it is a decompile problem, and i'll attach the sample swf.
State: upgraded→returned
These should be fixed too in the repository.
State: returned→upgraded
New problem:)
Try to edit and save.
class ball_obj extends MovieClip
{
function ball_obj()
{
super();
this.onEnterFrame = this.enterFrameHandler;
}
}
This was working some checkins ago (today), and working in latest stable build, too.
State: upgraded→returned
Result (for the previous post):
CURLY_CLOSE expected but SUPER found on line 5
Another:
for(;i < 10;i++)
{
}
This one is working in stable build, too.
3rd:
if(!mx.managers.FocusManager)
{
mx.managers.FocusManager.prototype = new mx.core.UIComponent().__get__defaultPushButton
= function()
{
return this.__defaultPushButton;
};
}
Result:
CURLY_CLOSE expected but ASSIGN found on line 3
I pushed some changes to the repository regarding expressions.
The problems you posted should be fixed.
Please run your tests again as this may break some things...
State: returned→upgraded
Now:
if(!mx.skins.halo.RectBorder)
{
mx.skins.halo.RectBorder.prototype = new mx.skins.RectBorder().init = function(Void)
{
this.borderWidths.default = 3;
super.init();
};
}
IDENTIFIER or THIS or SUPER or GLOBALFUNC or GLOBALCONST expected but DEFAULT found
State: upgraded→returned
And:
IDENTIFIER expected but STOP found on line 3
class xx
{
function stop()
{
}
}
where you got "this.borderWidths.default = 3;" command?
Is it present in a SWF file?
Because compiling this in CS6 give me error too as default is reserved word and cannot be
used as variable name.
/www.free-decompiler.com/flash/issues.html?action=downloadFile&fileId=8
mx.skins.halo.RextBorder, line 17
Then maybe it is not a parsing problem, it is a decompile problem
it should be fixed in repository now. (the default is decompiled as ["default"])
State: returned→upgraded
New problem:)
if(!mx.controls.listclasses.DataSelector)
{
mx.controls.listclasses.DataSelector = function()
{
super();
}.Initialize = function(obj)
{
var _loc3_ = mx.controls.listclasses.DataSelector.mixinProps;
return true;
};
}
Result: CURLY_CLOSE expected but SUPER found on line 5
State: upgraded→returned
hmm.. this last is ok now, probably you fixed it with the last push
State: returned→upgraded
Try to edit and save (multiple times) the following AS2 script:
function run_mo(x, y)
{
switch(x)
{
case "x":
if(y.x >= y.y)
{
delete bg.onEnterFrame;
}
break;
case "y":
if(y.x >= y.y)
{
delete bg.onEnterFrame;
}
break;
}
}
The source will be longer and longer. It adds unnecessary if statements. Ok, it is
equivalent with the original code, but this should be a bug.
State: upgraded→returned
Fixed in the repo
State: returned→upgraded
Similar to issue "03/02/2014, 12:05:18 pm"
function baoloiurl(phu)
{
if(ddo.cf.crosserror == true)
{
var _loc3_ = 0;
for(ir in _parent.trackerror)
{
_loc3_ = _loc3_ + 1;
}
if(_loc3_ < _parent.playlist.length)
{
_parent.playbaitiep();
return undefined;
}
}
}
Creates new if branches for every saving.
State: upgraded→returned
The above problem was in 2.swf (71401 bytes) \DefineSprite_27\frame_1\DoAction.as
It seems to be fixed, however there is a $$pop instruction which blocks the save, but when
i remove it there is not more new branches.
State: returned→closed