• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ScaleMode SHOW_ALL + responsive objects?

Explorer ,
Nov 03, 2017 Nov 03, 2017

Copy link to clipboard

Copied

Hello!

I'm wondering if it's possible to have certain objects on the stage responsive while the scaleMode is set to SHOW_ALL?

For example, I want some buttons to stay to the right of the stage (button1.x = 5;) and some to the left (button2.x = stage.stageWidth -5;) to make use of the screen of wider devices, but I've found that I can only get that to work on scaleMode NO_SCALE. But if I put the game on NO_SCALE, vital parts of the game gets cut out by the window (and I assume that parts of the game will also get cut out on some devices if the screen resolution is smaller than the game resolution?).

Thanks!

TOPICS
ActionScript

Views

529

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Nov 03, 2017 Nov 03, 2017

I figured out a difference. You don't get resize events with showAll. In my code I have:

  if (Capabilities.version.indexOf('MAC') < 0) {

so that I can test inside Animate and on mobile. I only reposition the buttons on mobile.

For showAll in a browser window you would need the web page JavaScript to send the resize information into the SWF. Here's a related post:

..::: ??? Sending data to Flash via JavaScript ??? :::..

Votes

Translate

Translate
LEGEND ,
Nov 03, 2017 Nov 03, 2017

Copy link to clipboard

Copied

Yes, you can. See my replies to this post, which didn't solve that particular problem, but do describe the approach you would take:

Re: Getting Accurate iPhone Screen Resolutions

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 03, 2017 Nov 03, 2017

Copy link to clipboard

Copied

I had a good look at it and attempted to use it for one of the buttons to the left, but it still won't work. The button stays on the same position as I resize the window. What I have is

stage.scaleMode = StageScaleMode.SHOW_ALL;

stage.align = StageAlign.TOP_LEFT;

var realheight = Math.min(Capabilities.screenResolutionX, Capabilities.screenResolutionY)

var realwidth = Math.max(Capabilities.screenResolutionX, Capabilities.screenResolutionY)

var vr = realwidth / realheight;

var ew = 480 * vr;

var gap = Math.floor((ew - 800) / 2);

button1.x = 1 - gap;

If I change the stage alignment to right, the button will be placed in the middle and follow the right side as resizing the screen.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 03, 2017 Nov 03, 2017

Copy link to clipboard

Copied

The default scale mode is showAll, and StageAlign isn't needed, so remove those two first lines, in case it's confusing things.

If you want to continually move at object you have to include a resize listener:

Adobe ActionScript 3.0 * Controlling Stage scaling

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 03, 2017 Nov 03, 2017

Copy link to clipboard

Copied

I attempted removing the first two lines and adding it into a resize listener, but sadly I get the same result. This is what I have now:

stage.addEventListener(Event.RESIZE, resizeListener);

function resizeListener(e: Event): void {

trace("stageWidth: " + stage.stageWidth + " stageHeight: " + stage.stageHeight);

var realheight = Math.min(Capabilities.screenResolutionX, Capabilities.screenResolutionY)

var realwidth = Math.max(Capabilities.screenResolutionX, Capabilities.screenResolutionY)

var vr = realwidth / realheight;

var ew = 480 * vr;

var gap = Math.floor((ew - 800) / 2);

button1.x = 1 - gap;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 03, 2017 Nov 03, 2017

Copy link to clipboard

Copied

There is a chance the the registration point in my button is different. Are you able to post a test FLA somewhere that I can look at it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 03, 2017 Nov 03, 2017

Copy link to clipboard

Copied

Although if the registration point was off, the item would just be placed off but still move with the edge of the window. I posted the game to dropbox over here: Dropbox - testgame.fla

A simple example game just to get the buttons to work properly before implementing it in the actual game

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 03, 2017 Nov 03, 2017

Copy link to clipboard

Copied

I figured out a difference. You don't get resize events with showAll. In my code I have:

  if (Capabilities.version.indexOf('MAC') < 0) {

so that I can test inside Animate and on mobile. I only reposition the buttons on mobile.

For showAll in a browser window you would need the web page JavaScript to send the resize information into the SWF. Here's a related post:

..::: ??? Sending data to Flash via JavaScript ??? :::..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 03, 2017 Nov 03, 2017

Copy link to clipboard

Copied

LATEST

Alright, I see. Well thanks for your help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines