Copy link to clipboard
Copied
Is there a piece of code that I can add into my Animate project that will gotoandplay a frame or movie clip when the stage resizes? I've got 2 movies - one for desktop and one for mobile. I want to go to the mobile version when the stage resizes. The code that I am putting together is not working and I don't know why as I'm just a beginner Any help or advice is much appreciated ...
var stageListener:Object = new Object ();
stageListener.onResize = function ()
{
if (Stage.width >= 600)
{
stageListener.gotoAndPlay("mobileArtwork");
}
}
Stage.addListener(stageListener);
First thing, for a desktop/mobile project you should be working in a Canvas document, not AS3. AS3 documents don't work in any common mobile browsers.
Second, the Canvas canvas normally has fixed dimensions. It doesn't resize unless some code resizes it. And when it does, there's no event for it. At best you could run a ticker event that continuously monitors the stage's scale.
Third, resolution sniffing is a really bad way to tell whether you're on mobile. Many smartphones these days have a scree
...Copy link to clipboard
Copied
First thing, for a desktop/mobile project you should be working in a Canvas document, not AS3. AS3 documents don't work in any common mobile browsers.
Second, the Canvas canvas normally has fixed dimensions. It doesn't resize unless some code resizes it. And when it does, there's no event for it. At best you could run a ticker event that continuously monitors the stage's scale.
Third, resolution sniffing is a really bad way to tell whether you're on mobile. Many smartphones these days have a screen resolution equal to or greater than common desktop resolutions.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now