Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AS2] loader doesn’t work #1561

Closed
ousia opened this issue Nov 15, 2020 · 10 comments · Fixed by #12063
Closed

[AS2] loader doesn’t work #1561

ousia opened this issue Nov 15, 2020 · 10 comments · Fixed by #12063
Assignees
Labels
A-avm1 Area: AVM1 (ActionScript 1 & 2)

Comments

@ousia
Copy link
Contributor

ousia commented Nov 15, 2020

http://www.mejorar-presentaciones.tk/mejorar-presentaciones-loader.swf loads http://www.mejorar-presentaciones.tk/mejorar-presentaciones-presentation.swf.

I assume the relevant AS2 code in the loader reads:

the_presentation = "./{filename:output}";
first_loading = new Object();
first_loading.onMouseDown = function () {
        load_swf = new MovieClipLoader();
        load_swf.loadClip(the_presentation, placeholder);
        listen_loading = new Object();
listen_loading.onLoadStart = function(target) {
    _root.dlprogress_mvclip.bar._xscale = 0;
    _starttime = gettimer();
};
listen_loading.onLoadError = function(){
    _root.load_text = "Presentation cannot be loaded!";
};
listen_loading.onLoadProgress = function(target, bytesLoaded, bytesTotal) {
   downldtime = (gettimer() - _starttime) / 1000;
   _root.load_text = (String (Math.round ((bytesLoaded * 100) / bytesTotal)) + "% (" + Math.round((bytesLoaded / 1024) / downldtime) + " KB/s)");
   _root.dlprogress_mvclip.bar._xscale = Math.round(bytesLoaded/bytesTotal*100);
   keeping_awake = setInterval(function(){}, 1000);
};
listen_loading.onLoadComplete = function(target) {
   clearInterval(keeping_awake);
   _root.load_text = "";
   _root.dlprogress_mvclip._visible = 0;
   _root.dlprogress_mvclip.bar._visible = 0;
   _root.first_slide._visible = 0;
};
            load_swf.addListener(listen_loading);
    };
    Mouse.addListener(first_loading);

I get two errors and no loading:

Unknown tag code: 40
Stop: Target is not a MovieClip

I wonder why target isn’t a movieclip for Ruffle.

Many thanks for your help.

@Toad06
Copy link
Member

Toad06 commented Nov 23, 2020

load_swf = new MovieClipLoader();
load_swf.loadClip(the_presentation,placeholder);

In Flash, "placeholder" is _level0.presentation_sprite but in Ruffle the value is undefined. The variable doesn't seem to be set anywhere but I've found out "placeholder" was the name of a shape element.

@Toad06 Toad06 added the A-avm1 Area: AVM1 (ActionScript 1 & 2) label Nov 23, 2020
@ousia
Copy link
Contributor Author

ousia commented Nov 23, 2020

Many thanks for your comment, @Toad06.

placeholder in swfc (from SWFTools) code is:

.box placeholder width={presentation:width} height={presentation:height}
...
.sprite images
.put placeholder alpha=0%

images is only used later in AS2 code related to the same sprite:

this.attachMovie("images","presentation_sprite",1);

presentation_sprite isn’t defined or used anywhere else.

@CUB3D
Copy link
Contributor

CUB3D commented Dec 20, 2020

The "placeholder" variable seems to be set based on the value used for the name in the PlaceObject2 tag inside of the sprite, in ruffle this seems to work fine when the tag is at the root but fail when it's part of a sprites actions.

Minimal example:
1561_example.zip

Output in Flash Player:

placeholder = _level0.other_mc_instance
other_mc_instance = _level0.other_mc_instance

Output in Ruffle:

placeholder = undefined
other_mc_instance = _level0.other_mc_instance

@ousia
Copy link
Contributor Author

ousia commented Apr 25, 2021

@CUB3D,

many thanks for your reply and sorry for not having answered before.

I’m afraid I don’t know how to attach a movie outside the sprite (I’m on Linux, using swfc [the SWF compiler from SWFTools]).

It would be great that Ruffle could solve placeholder inside the sprite.

Many thanks for your help.

@kmeisthax
Copy link
Member

@CUB3D Am I to interpret this to mean that if a PlaceObject happens with a given name, but the object that was placed isn't representable in AVM1 (e.g. it's a shape), then it's supposed to return itself?

I can implement that behavior, but I'm confused. Why would this be working in root if that were the case?

@Herschel
Copy link
Member

Herschel commented Oct 20, 2021

This is a variant of #1029. The shape does get assigned a name (even though this isn't allowed by the Flash IDE...!). Because shapes don't have an object representation in AVM1, accessing it falls back to the parent, similar to how buttons have the same behavior in v5 SWFs.

So using _level0.presentation_sprite.placeholder actually resolve to the parent _level0.presentation_sprite, and the movie then gets loaded into presentation_sprite. This should be taken care of as part of #5492 (although it needs a bit of work to consider graphics as well).

@ousia
Copy link
Contributor Author

ousia commented Oct 21, 2021

Many thanks for your explanation, @Herschel.

Looking forward having this issue fixed... it would be great that it could be done before it turns 12 months old.

Many thanks for your excellent work.

@ousia
Copy link
Contributor Author

ousia commented Jan 12, 2022

@relrelb,

considering #1561 (comment), could #6004 solve also this issue?

Many thanks for your help.

@ousia
Copy link
Contributor Author

ousia commented Mar 8, 2023

@CUB3D, many thanks for your excellent work with #9447.

If you feel in the mood, it would be a great contribution to deal with other issues that were pending from that PR (at least this one and these other ones).

Many thanks for your excellent work and your help.

@ousia
Copy link
Contributor Author

ousia commented Jul 23, 2023

Many thanks for the fix, @CUB3D.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-avm1 Area: AVM1 (ActionScript 1 & 2)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants