Skip to main content
Participant
December 4, 2018
Answered

How to gotoandplay frame label when stage resizes?

  • December 4, 2018
  • 1 reply
  • 185 views

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);

    This topic has been closed for replies.
    Correct answer ClayUUID

    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.

    1 reply

    ClayUUIDCorrect answer
    Legend
    December 4, 2018

    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.