-
-
Notifications
You must be signed in to change notification settings - Fork 993
Closed
Labels
A-avm1Area: AVM1 (ActionScript 1 & 2)Area: AVM1 (ActionScript 1 & 2)bugSomething isn't workingSomething isn't working
Description
Describe the bug
AS2: When splicing unloaded/removed movie clips from an array referencing them, Ruffle's behavior does not match Flash player.
.swf attached.
When attached .swf is run in Flash Player, the yellow MovieClips are unloaded fairly quickly, and the logs/trace statements show the length of the array steadily decreasing.
When attached .swf is run in Ruffle, the MovieClips take much longer to unload and the array's length logs as 100 always. Here is the attached .swf running via Ruffle: https://typehelp.org/ruffletest/splicetest.html
Minimally reproduced as2 code:
var allItems = new Array();
populateItems();
function populateItems() {
for (var i=0; i<100; i++) {
var g = this.attachMovie("guy", "g" + i, i);
g._y = Math.floor(Math.random()*350);
allItems.push(g);
}
}
function randomRemove() {
var doIt = Math.random() * 100;
if (doIt < 30) {
var randGuy = allItems[Math.floor(Math.random()*allItems.length)];
randGuy.removeMovieClip();
randGuy.unloadMovie();
}
}
function sortClips() {
trace("allItems length: " + allItems.length);
for (var i=0; i<allItems.length; i++) {
var s = allItems[i];
if (s == undefined || s._y == undefined) {
allItems.splice(i,1);
i--;
continue;
}
}
}
this.onEnterFrame = function() {
sortClips();
randomRemove();
}
Expected behavior
In Ruffle, the allItems array length would decrease from 100 to 0 as the file runs.
Affected platform
Self-hosted version
Operating system
Win 10
Browser
Chrome
splicetest.zip
Additional information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-avm1Area: AVM1 (ActionScript 1 & 2)Area: AVM1 (ActionScript 1 & 2)bugSomething isn't workingSomething isn't working