Solved

full width centered flash, fixed height

Posted on 2009-07-12
3
1,590 Views
Last Modified: 2013-11-11
i currently have Flash CS3 Pro. What I'm trying to do is create a flash movie that will scale 100% in width, but always remain at a fixed height, no matter what size the browser is set to, and without stretching or distorting my swf. Also, I'd like the center portion of the movie to show, not the left. I'm creating a flash movie with a width of 1600px. the larger the browser width, the more of the movie is viewable on either side (rather than showing more on just the right side.

if you're familiar with CSS then what I'm talking about is the equivalent of using a background image with the position set to "top center" (ex: {background-position:top center;})

I've looked everyone for an example or tutorial on this, but with no luck. I'm not great with AS, so this is my last resort before I hire a freelancer to set it up for me. Any help is appreciated greatly :)
0
Comment
Question by:xill2678
3 Comments
 
LVL 7

Accepted Solution

by:
kishoregp earned 250 total points
ID: 24837610
if u edit ur html.. u shud see width and height parameters
and if u r publishing html from cs3, u shud find it in three places.. find and change it as below

width to "100%"
height to "300px" //change height to as you want

if you dont want the content to resize.. use the fscommand in the first frame of ur flash
fscommand("allowscale",false)
0
 
LVL 1

Author Comment

by:xill2678
ID: 24837670
but how do i show only the center of the movie at all times? i'm assuming i'll need to use an empty container which calls in an external swf, but only shows the center portion of the external file. how much it shows would depend on the width of the browser. not sure how to set this up
0
 
LVL 2

Assisted Solution

by:jockejocke
jockejocke earned 250 total points
ID: 24839111
I see your problem. There are mainly two ways of dealing with this:
1. Use HTML to set flash width and height and then use CSS to position the Flash DIV box.
2. Set the Flash container on the HTML page to 100% width and height, and then keep positions within flash (with AS)

Alternative 1:
Use SWFObject to place your Flash content inside a div on your HTML page, and then set width/height to what you want. Then CSS-position the div with absolute value to 'left: 50%'.

Alternative 2:
Use SWFObject to place your Flash content inside a div on your HTML page. Then set width/height to 100%. In Flash, set scaleMode to noScale and position document top-left. Add a listener function to when window is resized and position the movieclip where you want it to be. See as2/as3 example code below.

If you have for example a background image you want stretched instead of not visible, you can set width/height to the current stage width/height.

For more info on how to use SWFObejct, go to http://code.google.com/p/swfobject/ or search here at EE ;)

Hope this helps ;)
Cheers
----------

AS2:
 

Stage.scaleMode = "noScale";

Stage.align = "TL";

var resizer:Object = new Object();

resizer.onResize = function()

{

	myMc._x = Stage.width/2;

	myMc._y = 0;

}

Stage.addListener(resizer);
 
 
 

----------

AS3:
 

import flash.display.Stage;

import flash.events.Event;

stage.align = StageAlign.TOP_LEFT;

stage.scaleMode = StageScaleMode.NO_SCALE;			

this.stage.addEventListener(Event.RESIZE, resizeHandler);

function resizeHandler(e:Event)

{

	myMc.x = stage.stageWidth/2;

	myMc.y = 0;

}

Open in new window

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Action Script commands 3 206
Flash player plugin 13 7 312
bandwidth 5 64
Can't play streaming video on event.on24.com 7 135
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now