diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionScriptObject.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionScriptObject.java index a11e19291..6206c38b6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionScriptObject.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionScriptObject.java @@ -18,6 +18,24 @@ public class ActionScriptObject implements Cloneable { protected Object extendsObj; protected List implementsObjs = new ArrayList<>(); + public void clearMembers() { + for (Object o : members.values()) { + if (o instanceof ActionScriptObject) { + ((ActionScriptObject) o).clear(); + } + } + members.clear(); + } + + public void clearProperties() { + properties.clear(); + } + + public void clear() { + clearMembers(); + clearProperties(); + } + public List getImplementsObjs() { return implementsObjs; } @@ -121,6 +139,10 @@ public class ActionScriptObject implements Cloneable { return null; } + protected Object getThisMember(String name) { + return members.get(name); + } + public Object getMember(String path) { String pathParts[]; if (path.startsWith("/")) { @@ -131,13 +153,15 @@ public class ActionScriptObject implements Cloneable { ActionScriptObject obj = this; for (int i = 0; i < pathParts.length; i++) { String part = pathParts[i]; - Object member = obj.getMember(part); if (i == pathParts.length - 1) { - return member; - } else if (member instanceof ActionScriptObject) { - obj = (ActionScriptObject) member; + return obj.getThisMember(part); } else { - break; + Object member = obj.getMember(part); + if (member instanceof ActionScriptObject) { + obj = (ActionScriptObject) member; + } else { + break; + } } } return null; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/DepthStateObjectAdapter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/DepthStateObjectAdapter.java new file mode 100644 index 000000000..f3d02c45b --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/DepthStateObjectAdapter.java @@ -0,0 +1,18 @@ +package com.jpexs.decompiler.flash.action; + +import com.jpexs.decompiler.flash.timeline.DepthState; + +/** + * + * @author JPEXS + */ +public class DepthStateObjectAdapter extends ActionScriptObject { + + protected DepthState ds; + + public DepthStateObjectAdapter(DepthState ds) { + this.ds = ds; + } + + //TODO +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/DisplayObject.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/DisplayObject.java index b44d71777..a9cf49c27 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/DisplayObject.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/DisplayObject.java @@ -13,8 +13,8 @@ public class DisplayObject extends ActionScriptObject { protected Map displayList = new HashMap<>(); - protected int totalFrames; - protected int currentFrame; + protected int totalFrames = 1; + protected int currentFrame = 1; protected boolean paused = false; protected boolean dragging = false; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/LocalDataArea.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/LocalDataArea.java index ed4f503ae..4668171d2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/LocalDataArea.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/LocalDataArea.java @@ -73,6 +73,7 @@ public class LocalDataArea { localRegisters.clear(); withs.clear(); functions.clear(); + stage.clear(); jump = null; returnValue = null; executionException = null; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Stage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Stage.java index f7c6bbd11..d0a0c2d66 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Stage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Stage.java @@ -1,5 +1,17 @@ package com.jpexs.decompiler.flash.action; +import com.jpexs.decompiler.flash.ReadOnlyTagList; +import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.flash.tags.base.BoundedTag; +import com.jpexs.decompiler.flash.timeline.DepthState; +import com.jpexs.decompiler.flash.timeline.Frame; +import com.jpexs.decompiler.flash.timeline.Timeline; +import com.jpexs.decompiler.flash.timeline.Timelined; +import com.jpexs.decompiler.flash.types.RECT; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + /** * * @author JPEXS @@ -7,15 +19,73 @@ package com.jpexs.decompiler.flash.action; public class Stage extends DisplayObject { protected long startTime; + protected Timelined timelined; + protected Timeline timeline; + protected Frame frame; - public Stage() { + public Stage(Timelined timelined) { startTime = System.currentTimeMillis(); + this.timelined = timelined; + this.timeline = timelined != null ? timelined.getTimeline() : null; + this.frame = timelined != null ? this.timeline.getFrame(0) : null; + } + + @Override + public List enumerate() { + List ret = new ArrayList<>(); + if (frame != null) { + for (DepthState ds : frame.layers.values()) { + if (ds.instanceName != null) { + ret.add(ds.instanceName); + } + } + } + return ret; + } + + @Override + protected Object getThisMember(String name) { + if (frame != null) { + for (DepthState ds : frame.layers.values()) { + if (name.equals(ds.instanceName)) { + return new DepthStateObjectAdapter(ds); + } + } + } + return null; } public long getTime() { return System.currentTimeMillis() - startTime; } + @Override + public int getTotalFrames() { + if (timeline == null) { + return 1; + } + return timeline.getFrameCount(); + } + + @Override + public void gotoFrame(int frameNum) { + super.gotoFrame(frameNum); + if (timeline != null) { + this.frame = timeline.getFrame(getCurrentFrame() - 1); + } + } + + @Override + public void gotoLabel(String label) { + if (timeline == null) { + return; + } + int f = timeline.getFrameWithLabel(label); + if (f != -1) { + gotoFrame(f + 1); + } + } + public void stopSounds() { }