Dynamically Scaling The Stage
I have had a wonderful tool in AS2 where I can take this movieClip, resize it and move it off the stage, and at run time, only what the movieClip is over is seen and at full screen. I would absolutely love it if anyone could help me get it to work in AS3. Here is the AS2 code:
function camControl():Void { parentColor.setTransform(camColor.getTransform()); var scaleX:Number = sX/this._width; var scaleY:Number = sY/this._height; _parent._x = cX-(this._x*scaleX); _parent._y = cY-(this._y*scaleY); _parent._xscale = 100*scaleX; _parent._yscale = 100*scaleY; } function resetStage():Void { var resetTrans:Object = {ra:100, rb:0, ga:100, gb:0, ba:100, bb:0, aa:100, ab:0}; parentColor.setTransform(resetTrans); _parent._xscale = 100; _parent._yscale = 100; _parent._x = 0; _parent._y = 0; } // make frame invisible this._visible = false; // Capture stage parameters var oldMode:String = Stage.scaleMode; Stage.scaleMode = "exactFit"; var cX:Number = Stage.width/2; var cY:Number = Stage.height/2; var sX:Number = Stage.width; var sY:Number = Stage.height; Stage.scaleMode = oldMode; // create color instances for color // transforms (if any). var camColor:Color = new Color(this); var parentColor:Color = new Color(_parent); // Make the stage move so that the // v-cam is centered on the // viewport every frame this.onEnterFrame = camControl; // Make an explicit call to the camControl // function to make sure it also runs on the // first frame. camControl(); // If the v-cam is ever removed (unloaded) // the stage, return the stage to the default // settings. this.onUnload = resetStage;
Here is the code I have so far in AS3, but I've been stuck for a while on this:
function camControl():void { parentColor.setTransform(camColor.getTransform()); var scaledX:Number = sX/this.width; var scaledY:Number = sY/this.height; parent.x = cX-(this.x*scaledX); parent.y = cY-(this.y*scaledY); parent.scaleX = 100*scaledX; parent.scaleY = 100*scaledY; } function resetStage():void { var resetTrans:Object = {ra:100, rb:0, ga:100, gb:0, ba:100, bb:0, aa:100, ab:0}; parentColor.setTransform(resetTrans); parent.scaleX = 100; parent.scaleY = 100; parent.x = 0; parent.y = 0; } // make frame invisible this.visible = false; // Capture stage parameters var oldMode:String = Stage.scaleMode; Stage.scaleMode = "exactFit"; var cX:Number = Stage.width/2; var cY:Number = Stage.height/2; var sX:Number = Stage.width; var sY:Number = Stage.height; Stage.scaleMode = oldMode; // create color instances for color // transforms (if any). var camColor:Color = new Color(this); var parentColor:Color = new Color(parent); // Make the stage move so that the // v-cam is centered on the // viewport every frame this.onEnterFrame = camControl; // Make an explicit call to the camControl // function to make sure it also runs on the // first frame. camControl(); // If the v-cam is ever removed (unloaded) // the stage, return the stage to the default // settings. this.onUnload = resetStage;
I'd appreciate any help.
ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 10-07-2008, 08:18 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Scaling Stage Mask Dynamically
Hi Guys,
Got a slight problem with getting a mask that covers my stage to scale when the browser window is resized.
Basically when the browser window is resized i need the stage to resize with it, and the mask that covers the stage to resize with it to, so it shows more and more of the bg and elements can scale to the width of the entire stage.
Heres where i am on the first frame of the main timeline:
stop();
Stage.align = "TL";
Stage.scaleMode = "noScale";
sizeListener = new Object();
sizeListener.onResize = function() {
_root.mc_menu_all.mc_menu_bg._width = Stage.width;
_root.mc_menu_all._y = Stage.height/1.7;
_root.mc_logo._y = _root.mc_menu_all._y+80;
_root.mc_mask_main._width = Stage.width;
_root.mc_mask_main._height = Stage.height;
};
Stage.addListener(sizeListener);
I don't know if it matters whether i have more than 1 frame on the root timeline, or whether i have to call the script everytime?
If anyone can help with why the above code is not working its much appreciated (got a presentation tomorrow!
Can be seen here http://testsite.imageview.co.uk/djh/site.html
Cheers,
Pat
No Resize/scaling A Movie Clip On The Scaling Stage...
I know this has probably been answered here already, but I've search through all the threads with "scaling" and "resizing" and can't find the solution.
Basically I have a GUI element on a gallery that I don't want to scale, while the rest of the page is free to resize/scale.
I think I need to add a listener of some sort to the stage, but I'm not sure how to do this. If you can point me to a thread where this has already been answered, great! Otherwise I would be grateful for any help you could provide here.
Stage Scaling?
(my code is at bottom)
A button aligned with the bottom of the stage is desired to remain aligned with the bottom of the stage as the user resizes the window.
As the height of stage is increased -- the _y of the button and the stage._height maintain their differential -- but the visible window shows the button moving faster down -- until its completely beyond the bottom of the window.
Conversely, as the window height is decreased -- the differential remains accurate -- but the button ends up in the middle of the window. Resize to the original stage height -- and the alignment goes back to as it started.
I've gotta be missing something. some sort of constraint or percentage/offset? Anybody know what it is? -- or if there's any easier way to maintain a button/object's alignment as the window/stage resizes?
newbie flasher -- and I can't even get unzipped...
Stage.scaleMode = "noScale"
var myListener:Object = new Object();
myListener.onResize = function () {
trace("Stage size is now " + Stage.width + " by " + Stage.height);
trace(btnNext._y)
btnNext._y = Stage.height - btnNext._height
btnPrevious._y = Stage.height - btnPrevious._height
trace(btnNext._y)
}
Stage.addListener(myListener);
Attach Code
Stage.scaleMode = "noScale"
var myListener:Object = new Object();
myListener.onResize = function () {
trace("Stage size is now " + Stage.width + " by " + Stage.height);
trace(btnNext._y)
btnNext._y = Stage.height - btnNext._height
btnPrevious._y = Stage.height - btnPrevious._height
trace(btnNext._y)
}
Stage.addListener(myListener);
Scaling The Stage But Not The Content
how do you make a flash file that is 100% of your browser size
and resizes with the browser but without the objects in the
movie resizing also?
thanks
Stage Scaling Problem
(Using CS3, with AS2.0)
I'm working on a personal site at www.nickelcadmium.net
I'm happy with the progress so far, but I'm having one major problem: The .swf isn't scaled, which I want because I like the background filling the entire screen. However, the main blue box interface scales the same size, reguardless of browser resolution.
In some browsers some of the navigation is getting cut off when the interface "zooms in."
I'd like for the background to stay full, but for the blue box interface to be limited to scale differently depending on different browser resolutions, so that I can guarantee how much of it each user sees.
What would you suggest?
Scaling To Center Of Stage
OK so I am new to the actionscript world and I am struggling to get something to work. I have been searching the web and I don't know if it is because I am new and not sure what I am looking for...or I have over looked something easy...but here is what is going on...
I have a movie clip called "schemLoader_MC" and a user can zoom in and out of it by using a plus or minus button I have created. I am trying to make it so that when you click the plus or minus button it will zoom to the center of the stage.
How do I make the following scale to the center of the stage regardless of the position of the movie it is scaling? The "schemLoader_MC" can be zoomed in or out and can pan in any direction as well...
Here is the current code I have...it functions...just not like I would like it to:
// Zoom in button
zoomIn_btn.onPress = function() {
schemLoader_MC._xscale *= 1.20;
schemLoader_MC._yscale *= 1.20;
};
// Zoom out button
zoomOut_btn.onPress = function(): {
schemLoader_MC._xscale *= .8;
schemLoader_MC._yscale *= .8;
};
Scaling Clip According To Stage
I found this code to scale a MovieClip proportionately to the stage resize. This works great but I’m trying to have a space at the top and bottom each of 60 pixels. I can get this on the top by setting my y value to 60 but I need to get that same space on the bottom. How can I go about this? I tried subtracting 60 from the stage height. I also tried subtracting it from the clips height but it didn't work.
Any solutions would be welcomed
ActionScript Code:
Stage.scaleMode = "noScale";
Stage.align = "TL";
this.createEmptyMovieClip("mcBackground", 1);
mcBackground._y=40;
function stageResize():Void {
//if (Stage.width>640 && Stage.height>480) {
var imageAspectRatio = mcBackground._width/mcBackground._height;
var stageAspectRatio = Stage.width/Stage.height;
if (stageAspectRatio>=imageAspectRatio) {
// long skinny stage - match image width and adjust height to fit
mcBackground._width = Stage.width;
mcBackground._height = Stage.width/imageAspectRatio;
} else {
// tall narrow stage - match image height and adjust width to fit
mcBackground._height = Stage.height;
mcBackground._width = Stage.height*imageAspectRatio;
}
//mcBackground._width = Stage.width;
//mcBackground._height = Stage.height;
mcBackground.updateAfterEvent();
//}
}
var stageListner:Object = new Object();
stageListner.onResize = function():Void {
stageResize();
};
Scaling MC's Within Stage Size
hey guys,
Im having a problem here. I have an MC which loads images from an xml file.
Most of them pictures are quite big (800×600) and i know some people still run that resolution. So the problem is if the browser window is smaller then those dimensions people cant see the full pic. So now my question was, does someone know how to scale them down, without stretching the pic. Thus not:
myMc._width = Stage.width;
myMc._height = Stage.height;
but something like http://www.manipulator.com/
where the _xscale = _yscale;
Does anyone have a clue how to write this?
Stage Object Scaling
Hey.
Anyone have any insight into how one can scale elements of the movie without scaling others.
Like having some elements be full screen (graphics) and other elements stay with a specified pixel size (fonts).
It is possible, I've seen it. Anyone wanna share?
thanks. :]
Scaling A Growing Mc To Always Fit The Stage
Hi!
What I´m trying to do is load images (currently boxes in different colors) into a mc which is supposed to scale down so it always fits the stage. If the "holder" clip is smaller then the stage it should just center itself. The boxes places themselfs in contact with the previous box, thats what the "typeOfBound" function is for basicly.
I´m having trouble with the scaling value, it works fine on the first couple of boxes. You can just copy paste the code to try it for yourself. Hope you understand where I´m going with this.
And sorry about the crappy spelling.
// Rickard
Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
var list:Object = new Object();
Stage.scaleMode = "noScale";
Stage.align = "LT";
Stage.addListener(list);
/* ----------------------------------------------------------*/
// RANDOM POSITIONING
var holder:MovieClip;
var imageRef:Array = new Array();
var probability:Array = new Array();
var prevX:Number = 0;
var prevY:Number = 0;
var prevW:Number = 0;
var prevH:Number = 0;
var bound:Number = 3;
var previousX:Number = 0;
var previousY:Number = 0;
var fakeDown:Number;
var rS:Number = 100;
var nX:Number = 0;
var nY:Number = 0;
//holder = createHolder(this);
holder = this.createEmptyMovieClip("holder", this.getNextHighestDepth());
// Fakes the load process for the images
fakeDown = setInterval(this, "simulateLoad", 2000, holder);
function simulateLoad():Void{
clearInterval(fakeDown);
var mc = createBox(holder);
imageRef.push(mc);
typeOfBound(mc);
}
function typeOfBound(mc:MovieClip):Void{
switch(bound){
case 1 :
bound = position(0, 2);
if(prevY-mc._height*(rS/100) < 0){
// -1 to prevent effecting the current image
var offset:Number = (mc._height*(rS/100)-prevY);
for(var i:Number = 0; i < imageRef.length-1; i++){
imageRef[i]._y += offset;
}
holder._y -= offset;
previousY = holder._y;
prevY += offset;
}
if(mc._width < prevW){
mc._x = prevX + (prevW - mc._width);
}else{
mc._x = prevX;
}
mc._y = prevY - mc._height;
break;
case 2 :
bound = position(0, 3);
if(prevY-mc._height*(rS/100) < 0){
var offset:Number = (mc._height*(rS/100)-prevY);
for(var i:Number = 0; i < imageRef.length-1; i++){
imageRef[i]._y += offset;
}
holder._y -= offset;
previousY = holder._y;
prevY += offset;
}
mc._x = prevX + prevW;
mc._y = prevY - mc._height;
break;
case 3 :
bound = position(0, 4);
mc._x = prevX + prevW;
mc._y = prevY;
break;
case 4 :
bound = position(1, 4);
mc._x = prevX + prevW;
mc._y = prevY + prevH;
break;
case 5 :
bound = position(2, 4);
if(mc._width < prevW){
mc._x = prevX + (prevW - mc._width);
}else{
mc._x = prevX;
}
mc._y = prevY + prevH;
break;
}
prevX = mc._x;
prevY = mc._y;
prevW = mc._width;
prevH = mc._height;
reScale();
}
function position(sValue:Number, eValue:Number):Number{
return Math.ceil((Math.random()*eValue)+sValue);
}
function reScale():Void{
if(holder._width<Stage.width && holder._height<Stage.height){
nX = (Stage.width-holder._width)/2;
nY = (Stage.height-holder._height)/2;
}else if(holder._width/Stage.width > holder._height/Stage.height){
rS = (Stage.width/holder._width)*rS;
nY = (Stage.height - holder._height*(rS/100))/2;
nX = 0;
}else{
rS = (Stage.height/holder._height)*rS;
nX = (Stage.width - holder._width*(rS/100))/2;
nY = 0;
}
new Tween(holder, "_xscale", Strong.easeInOut, holder._xscale, rS, 1.8, true);
new Tween(holder, "_yscale", Strong.easeInOut, holder._yscale, rS, 1.8, true);
new Tween(holder, "_x", Strong.easeInOut, holder._x, nX, 1.8, true);
new Tween(holder, "_y", Strong.easeInOut, holder._y, nY, 1.8, true);
previousX = nX;
previousY = nY;
fakeDown = setInterval(this, "simulateLoad", 2000, holder);
}
function createBox(host:MovieClip):MovieClip{
var w:Number = Math.round((Math.random()*25)+200);
var h:Number = Math.round((Math.random()*25)+200);
var mc:MovieClip = host.createEmptyMovieClip("box_"+host.getNextHighestDepth(), host.getNextHighestDepth());
mc.beginFill(0x000000, 90);
mc.lineTo(w, 0);
mc.lineTo(w, h);
mc.lineTo(0, h);
var col = new Color(mc);
col.setRGB(Math.floor(Math.random()*0xFFFFFF));
return mc;
}
function createHolder(host:MovieClip):MovieClip{
var mc:MovieClip = host.createEmptyMovieClip("holder_"+host.getNextHighestDepth(), host.getNextHighestDepth());
mc.beginFill(0xFF0000, 100);
mc.lineTo(10, 0);
mc.lineTo(10, 10);
mc.lineTo(0, 10);
return mc;
}
Dynamically Scaling A MC
Does anyone know how to scale a movie clip based on how close the mouse pointer is to it (similar to the wat the "Dock" responds in OS X)?
Thanks!
Stage Scaling And Object Align
im lookin for a decent tutorial or something about how to get this scale/resize effect.
http://www.gskinner.com/site2_5/
http://www.ego7.net/
[MX04] Scaling The Main Stage
Hey Gang,
Working on a project that is essentially one large stage (16:9 ratio) that will play 2 movies (4:3 ratio) side by side. These movies are loaded externally by two separate XML files that act as play lists. Everything works great, and I've worked out the kinks except for one.
This flash file is going to be played on large plasma screens and plays at a rather large resolution. The difficulty comes in when an end user is changing the xml files and wants to double check that everything works correctly. Currently, the demo runs at fullscreen with allowscale set to false. Because most of these end users are going to be viewing this on laptops and monitors set to a much lower resolution than the final output, I'm trying to set up a key listener that will upon hit, scale the WHOLE stage of the flash down to say 30% or so, and then back up to 100% when it's hit again, or another key is pressed. Similar to what happens when you toggle allowscale on or off in fullscreen mode, but with a target size that's smaller than the normal stage size. I can't shrink the stage size on the fla because one of the screens requires playback at exactly 100% or I get artifacts all over the place. So during normal playback allowscale is already off, and the movie is playing at 100% size.
Can anyone help me out here or point me in the right direction? I've seen Stage.scale.[string] but that seems to only allow for scale versus no scale and it's dependant upon the window dimensions it's being viewed inside. This is a fullscreen presentation, and I wanted to avoid going into a windowed mode.
So to recap: I'm looking for a key listener function that will change the entire scale of the stage rather than just a particular movieclip.
Any thoughts?
Stage Resize And Scaling Movieclips
how do I code stage resize with scaling movieclips?
I can do stage resize and position/scale movieclips relative to stage size..
but i don't how to have a scalable movieclip retain its scale relative to stage size.
how do I code this?
for example, i have a movieclip originally 50px wide, and the stage 100px wide..
when i click the mc, it scales up to 80px wide. and when I resize the stage to 50px,(50% of stage size) i want the mc to scale to 40px too(50% of mc size).. and when I click it again to restore to it's original size, i want it to scale to 25px(50% of original size). then finally when i scale the stage back to 100px, the mc again is 50px wide.
i hope i made sense.. any help and links would be great.
Stage Alignment Problem Upon Scaling
I am having an issue with alignment within my flash file with a certain part of the flash. I setup a sample version of what I am having the issue with. You can view what I am talking about here: http://www.arteye.com/testme/ (this just emulates the problem I am having)
If you resize the browser when the section with the green box and red bar at the top, you will see they move to the center just like I would like. Next click on the red bar and this will take you to an example of a carousel script I am working with. Now if you resize this section - you will see that it is throwing the content hard to the left and really screwing things up. Why is this happening?
I know you guys are going to want to see code - so here is what I have in the main movie:
Code:
stop();
Stage.scaleMode = "noscale";
Stage.align = "TL";
import mx.transitions.Tween;
import mx.transitions.easing.*;
//Center movieClip reusable function
function centerMC(mc:MovieClip):Void {
mc._x = Math.floor((Stage.width - mc._width) / 2);
}
//Fade in or out reusable function
function fadeMc(mc:MovieClip, newAlpha:Number, duration:Number):Void {
var mcAlpha:Number = mc._alpha;
var fade:Tween = new Tween(mc, "_alpha", Regular.easeOut, mcAlpha, newAlpha, duration, false);
}
//Reposition elements
function reposition():Void {
centerMC(mcholder);
bkgScale();
};
Stage.addListener({onResize:reposition});
//Scale Background
function bkgScale():Void {
// This is the proportion (width/height) of the image
var imageScale:Number = bkgHolder._width/bkgHolder._height;
// This is the proportion (width/height) of the stage
var stageScale:Number = Stage.width/Stage.height;
// If the stage scale is bigger than the image scale the images width resizes to the stage
// width and the image height takes the stage proportion
if (stageScale>=imageScale) {
bkgHolder._width = Stage.width;
bkgHolder._height = Stage.width/imageScale;
// If the stage scale is smaller than the image scale the images height resizes to the stage
// height and the image width takes the stage proportion
} else {
bkgHolder._height = Stage.height;
bkgHolder._width = Stage.height*imageScale;
}
}
/////////////Loader//////////////////////
var loaderListener:Object = new Object();
//When loading starts turn the loaded clip alpha to 0
loaderListener.onLoadStart = function(mc:MovieClip):Void {
mc._alpha = 0;
};
//When the first frame of the loaded clip have been executed
loaderListener.onLoadInit = function(mc:MovieClip):Void {
//if it is the background
//scale background
//and load the external mc with a 1000 miliseconds delay
// so the appearing of the elements seem more smooth
if (mc == bkgHolder) {
bkgScale();
setTimeout(loadMc, 1300);
}
//if it is the external mc
//center it
else if (mc == mcholder) {
centerMC(mc);
}
//Tween the loaded alpha to 100
fadeMc(mc, 100, 28);
};
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(loaderListener);
//Load external MC
function loadMc():Void {
loader.loadClip("sgcore.swf", mcholder);
}
//Load background image
function loadBKG():Void {
loader.loadClip("background.jpg", bkgHolder);
}
//Start Loading
loadBKG();
Stage Alignment Problem Upon Scaling
I am having an issue with alignment within my flash file with a certain part of the flash. I setup a sample version of what I am having the issue with. You can view what I am talking about here: http://www.arteye.com/testme/ (this just emulates the problem I am having)
If you resize the browser when the section with the green box and red bar at the top, you will see they move to the center just like I would like. Next click on the red bar and this will take you to an example of a carousel script I am working with. Now if you resize this section - you will see that it is throwing the content hard to the left and really screwing things up. Why is this happening?
I know you guys are going to want to see code - so here is what I have in the main movie:
Code:
stop();
Stage.scaleMode = "noscale";
Stage.align = "TL";
import mx.transitions.Tween;
import mx.transitions.easing.*;
//Center movieClip reusable function
function centerMC(mc:MovieClip):Void {
mc._x = Math.floor((Stage.width - mc._width) / 2);
}
//Fade in or out reusable function
function fadeMc(mc:MovieClip, newAlpha:Number, duration:Number):Void {
var mcAlpha:Number = mc._alpha;
var fade:Tween = new Tween(mc, "_alpha", Regular.easeOut, mcAlpha, newAlpha, duration, false);
}
//Reposition elements
function reposition():Void {
centerMC(mcholder);
bkgScale();
};
Stage.addListener({onResize:reposition});
//Scale Background
function bkgScale():Void {
// This is the proportion (width/height) of the image
var imageScale:Number = bkgHolder._width/bkgHolder._height;
// This is the proportion (width/height) of the stage
var stageScale:Number = Stage.width/Stage.height;
// If the stage scale is bigger than the image scale the images width resizes to the stage
// width and the image height takes the stage proportion
if (stageScale>=imageScale) {
bkgHolder._width = Stage.width;
bkgHolder._height = Stage.width/imageScale;
// If the stage scale is smaller than the image scale the images height resizes to the stage
// height and the image width takes the stage proportion
} else {
bkgHolder._height = Stage.height;
bkgHolder._width = Stage.height*imageScale;
}
}
/////////////Loader//////////////////////
var loaderListener:Object = new Object();
//When loading starts turn the loaded clip alpha to 0
loaderListener.onLoadStart = function(mc:MovieClip):Void {
mc._alpha = 0;
};
//When the first frame of the loaded clip have been executed
loaderListener.onLoadInit = function(mc:MovieClip):Void {
//if it is the background
//scale background
//and load the external mc with a 1000 miliseconds delay
// so the appearing of the elements seem more smooth
if (mc == bkgHolder) {
bkgScale();
setTimeout(loadMc, 1300);
}
//if it is the external mc
//center it
else if (mc == mcholder) {
centerMC(mc);
}
//Tween the loaded alpha to 100
fadeMc(mc, 100, 28);
};
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(loaderListener);
//Load external MC
function loadMc():Void {
loader.loadClip("sgcore.swf", mcholder);
}
//Load background image
function loadBKG():Void {
loader.loadClip("background.jpg", bkgHolder);
}
//Start Loading
loadBKG();
Scaling Clip To Stage Width
ActionScript Code:
box._x = 0;
box._xscale = Stage.width;
trace(box._width);
when i test the above script, my movie clip doesnt scale to the the stages width. Any thoughts?
Scaling An Mc Relative To Stage Size
No... it's got nothing to do with egotistical newbie dj's...
I have a projector which I would like to go full-screen. In this projector I plan to play a video in the centre of the stage.
Since people using this preso will have differing screen resolutions, the stage will undoubtedly appear at several different sizes.
I don't want the video to scale, so I'll need it to detect the stage size and adjust its size using a specific ratio.
I've tried using Stage.addListener to detect the onResize() event, but Stage.scaleMode must be set to "noScale" for this to work. This screws my plan to have the stage scaleable.
How do I scale my video relative to the stage size?
Any help would be much appreciated!
Scaling Stage With Size Listener
im using the following code to keep my menus in view when the browser is resized. [code]
stage.showmenu = false;
Stage.scaleMode ="noScale";
Stage.align = "TL";
bottomrightmenu._x = Stage.width
bottomrightmenu._y = Stage.height - bottomrightmenu._height
bottomleftmenu._y = Stage.height - bottomleftmenu._height
toprightmenu._x = Stage.width - toprightmenu._width
center._x = (Stage.width + 800)/2
center._y = Stage.height/2
sizeListener = new Object();
sizeListener.onResize = function() {
bottomrightmenu._x = Stage.width
bottomrightmenu._y = Stage.height -bottomrightmenu._height
bottomleftmenu._y = Stage.height - bottomleftmenu._height
toprightmenu._x = Stage.width - toprightmenu._width
center._x = (Stage.width + 800)/2
center._y = Stage.height/2
};
Stage.addListener(sizeListener);
stop();
on my main stage, on a layer beneath the menus, i have an empty movie clip that i'm loading background swf's in and out of.
my question is.......how do i get the background swfs to scale down in size when the browser size is decreased and scale up in size when the browser is enlarged, while still maintaining the "noScale" mode of the stage?
an example of what im trying to do can be seen here:
http://www.whatireallydoatwork.com/
thanks
brandon
Scaling A Path Dynamically
Ok this is an extremely hard question to answer, but hopefully one of you who reads this is a freakin genius.
Ok Normaly to change a scale of a movieclip you would do this.
Movie1._xscale = 200;
Movie1._yscale = 200;
Ok here is what i want to do:
I have a movie clip of a rotating planet. One layer is the planets path, and the other is the planet.
I would like to change the scale of just the path and not the planet. Does anyone know a really good way of doing this? I know two bad ways.
One is to do the rotation in AS rather than a path and you can scale it mathmaticly.
Or Change the Planet to a Movie Clip and Change it's Scale in ratio to the outer MovieClip. Like this
Movie1._xscale = 200;
Movie1._yscale = 200;
Movie1.Planet._xscale = 50;
Movie1.Planet._yscale = 50;
That would double the path size but keep the planets the same size in relation to a scale of 100%
It just seems like a crapy way of doing it.
Any takers on a better answer?
-Breakzero
Scaling Images Dynamically
i'm loading images dynamically. The images that will be uploaded will very rarely be of the exact same dimensions, so scaling percent wise doesn't exactly do what I want. I would like to scale an image up and down to a precise amount of pixels (say,
116(width)*86(height)).
Dynamically Scaling An Object
I managed to scale a movie clip's width with easing.
With this code:
onClipEvent (enterFrame) {
endWidth = 50;
_width += (endWidth-_width)/speed;
}
But it scales both from left and right sides i just want the left to be stable and right to scale.Shortly A box which width is 200 will become 50 but the scale will be from the right.
How am i going to do this?
Dynamically Scaling Text
I have a site that scales, on monitors with 1024 by 768 i think the text is a bit too small, is there a way to have flash detect what size the movie is at then increase the size of the text on stage?
thanks,
-EK
Dynamically Scaling An Object
I managed to scale a movie clip's width with easing.
With this code:
onClipEvent (enterFrame) {
endWidth = 50;
_width += (endWidth-_width)/speed;
}
But it scales both from left and right sides i just want the left to be stable and right to scale.Shortly A box which width is 200 will become 50 but the scale will be from the right.
How am i going to do this?
Dynamically Scaling Border
Hi:
I am wondering how to make a dynamically scaling border from a png. The border would scale depending on what content is loaded into the mc it is relative to. I think i understand how to do that, what i don't understand is how to 'stretch/tile' only the 'mid' points of the border to accomodate the content.
Any help would be appreciated.
Thanks
Dynamically Scaling Fonts?
Hey guys, it's been awhile but I've run into some problems and need some thinkers to help me out :D
I have a movieclip, that will ultimately be a speech balloon. This clip will NOT change in size. Inside the bubble movieclip will be a text box. This box will hold dynamic text, but the text must fill up the entire speech bubble, regardless of length. So in an extreme case, something that's three words long will have to scale up a great deal, while something that's a whole paragraph would scale down.
I thought that by getting the height of the movieclip and textbox, finding their difference, and multiplying the size of the text by that factor would solve it, but I seem to be missing something (maybe I need to take into account the number of lines the original was?)
Anyways, here's the code. If you have any ideas (or maybe a better way to solve this issue), I'm all ears. Thanks!
Code:
var myFormat = new TextFormat();
myFormat.color = 0x336699;
myFormat.size = 18;
var temp_str = "Blah blah blah blah lalala hahah this is a long sentence I think maybe just maybe it will be long enough. Let's repeat it again to make sure: Blah blah blah blah lalala hahah this is a long sentence I think maybe just maybe it will be long enough."
//var temp_str = "Blah blah blah blah lalala hahah this is a long sentence I think maybe just maybe it will be long enough."
//var temp_str = "Blah blah blah short sentence."
//--------------------------------------------------------------------------
container_mc.test_txt.text = temp_str;
container_mc.test_txt.setTextFormat(myFormat);
container_mc.test_txt.autoSize = "left";
//--------------------------------------------------------------------------
function checkSize() {
// If the textbox is not bigger than its containing movieclip, then increase the
// size of the text by a factor of the difference of the text box and container sizes.
if (container_mc.test_txt._height <= container_mc._height - 10) {
trace("It's too short! Increasing font size...");
trace("Textbox Height: " + container_mc.test_txt._height);
trace("Container Height: " + container_mc._height);
var factor = container_mc._height / container_mc.test_txt._height;
trace("Factor: " + factor);
increaseSize(factor);
} else {
trace("It's fine!");
}
}
function increaseSize(factor) {
trace("Font Size: " + myFormat.size);
/******
!!! Dividing by 2 doesn't work for all cases. So there must be another variable !!!
*******/
// Increase the type size based on half of the scale factor
myFormat.size *= factor / 2;
/******
!!! Don't play with this until the above works regardless of text length !!!
*******/
// Subtract 2 from the resulting size to account for leading
//myFormat.size -= 2;
// Re-Apply the text format and autosize it
container_mc.test_txt.setTextFormat(myFormat);
container_mc.test_txt.autoSize = "left";
trace("Font Size: " + myFormat.size);
}
//--------------------------------------------------------------------------
checkSize();
//trace("temp_str length: " + temp_str.length);
//trace("container_mc height: " + container_mc._height);
//trace("test_txt height: " + container_mc.test_txt._height);
Advanced Actionscript? Problem W/stage And Scaling
This is what I want to do:
1) have a "holder" swf that contains the background img and SCALES to fit the browser window.
2) have the "main" swf inside the holder that DOES NOT SCALE with the holder.
An example can be found here:
www.olivier-baldissera.com
so far I've been able to scale the holder to fit the window as I wanted using the "noborder" and 100%x100% html attributes. I've been fooling with the stage.onResize function and listeners, but they don't seem to work right, partly because I don't think they're supposed to be used with "noborder" set to true.
PLEASE HELP!
Positioning And Scaling A Movieclip In Relation To The Stage...
I'm using the "Full Browser Flash" technique and all is working well with one exception, I can't seem to get a movieclip to scale itself to the stage size and then animate.
Example:
I have a movieclip that spans the width of the stage. The code to implement this technique for the FBF stage is working. What I want to do is 1) detect what the size of the stage is, 2) position the movieclip off of the stage using the detected stage size [i.e.: (._x=0-Stage.width)] and 3) animate this movieclip from it's off screen location to it final position.
Let's say the stage size is detected to be 800 pixels wide. This would scale the movieclip to 800 pixels wide. Then the movieclip would be positioned off the stage at an x coordinate of -800. Then the movieclip would animate to the x coordinate of 0.
Make sense?
Please advise. Thanks.
Scaling Ratio In A GradientFill On Stage Resize
When my document class is initialized, I'm drawing a rectangle with a gradient fill equal to the size of the stage to give me a black -> gray gradient background. I'm also rotating the gradient fill to give me a vertical linear gradient.
I have added a RESIZE event listener to the stage that redraws the rectangle on RESIZE. Its working fine, but I noticed that my ratios scale with the size of the browser.
My goal is to keep the point where the gradient starts at the same y position (lets say 200px).
here is my code...
Code:
package{
import flash.display.GradientType;
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.geom.Matrix;
public class site extends MovieClip{
var matrix:Matrix = new Matrix;
public function site(){
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
init();
}
private function init():void{
drawBG();
stage.addEventListener(Event.RESIZE,drawBG);
}
private function drawBG(evt:Event = null):void{
matrix.createGradientBox(stage.stageWidth,stage.stageHeight,Math.PI/2,0,0);
graphics.clear();
graphics.beginGradientFill("linear",[0x000000,0x000000,0xCCCCCC],[1,1,1],[0,50,255],matrix);
graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
graphics.endFill();
}
}
}
Help Proportional Scaling MovieClips Relative To Stage
Hello
I need some assistance on how to proportionally scale multiple movieClips relative to the stage size.
I understand movieclip placement relative to the stage, and I have been using a code to scale MovieClips as a fullscreen background (also proportionally)
But
I can not figure out for the life of me how to scale other movieclips in relation
to the stage size.
for example I have a background_mc that proportionally scales with the stage
to fill without distortion.
HOW do I then place another MC say center aligned (I know how to do that) that will scale with the background without distortion?
Ideally I would like to place several MC's on my stage all scaling in proportion with the stage yet independently.
I have not been able to find any documentation on this.
lots of tutorials on backgrounds and color fills and the like but nothing
on proportional scaling of independent mc's
this is the code I use for my background_mc (can it be modified or should it be thrown out the window to achieve independent scaling?)
Code:
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, resizeHandler);
//function to handle background image resize.
function setBackground() {
var reg2 = stage.stageWidth / 2;
var reg1 = stage.stageHeight / 2;
bg_mc.x = reg2;
bg_mc.y = reg1;
bg_mc.width = stage.stageWidth;
bg_mc.height = stage.stageHeight;
bg_mc.scaleX <= bg_mc.scaleY ? (bg_mc.scaleX = bg_mc.scaleY) : (bg_mc.scaleY = bg_mc.scaleX);
}
setBackground();
function resizeHandler(event:Event):void {
setBackground();
thanks
Change Stage Size In Web Browser Without Scaling
I need to change the stage's size without auto scaling (i.e. cropping is ok) so that the user can scroll up/down the stage either with the browser's scrollbars or custom scroll bars I create. The height of the swf's contents change and so I need to change the stage's size or somehow crop it so that it would match the browser's size.
Help Proportional Scaling MovieClips Relative To Stage
Hello
I need some assistance on how to proportionally scale multiple movieClips relative to the stage size.
I understand movieclip placement relative to the stage, and I have been using a code to scale MovieClips as a fullscreen background (also proportionally)
But
I can not figure out for the life of me how to scale other movieclips in relation
to the stage size.
for example I have a background_mc that proportionally scales with the stage
to fill without distortion.
HOW do I then place another MC say center aligned (I know how to do that) that will scale with the background without distortion?
Ideally I would like to place several MC's on my stage all scaling in proportion with the stage yet independently.
I have not been able to find any documentation on this.
lots of tutorials on backgrounds and color fills and the like but nothing
on proportional scaling of independent mc's
this is the code I use for my background_mc (can it be modified or should it be thrown out the window to achieve independent scaling?)
Code:
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, resizeHandler);
//function to handle background image resize.
function setBackground() {
var reg2 = stage.stageWidth / 2;
var reg1 = stage.stageHeight / 2;
bg_mc.x = reg2;
bg_mc.y = reg1;
bg_mc.width = stage.stageWidth;
bg_mc.height = stage.stageHeight;
bg_mc.scaleX <= bg_mc.scaleY ? (bg_mc.scaleX = bg_mc.scaleY) : (bg_mc.scaleY = bg_mc.scaleX);
}
setBackground();
function resizeHandler(event:Event):void {
setBackground();
thanks
Scaling Dynamically.. Changing Coords
Hey, I'm currently trying to scale an MC using AS but when it zooms in, it doesn't stay focused on what the previous center was, rather, it skirts over about 25px to the left. I don't understand why.
My nesting scheme is as follows.
_root:
attachmovie (picturemc)
picturemc.mountain._scale =150 <-----this one scales
I have it traced and the _x of either picturemc or mountain doesn't seem to change, however I can visually see the change. Bear in mind that I'm scaling both the x and the y. I'm using the new MX2004 functions to do the scaling, my picturemc and my mountainmc are both aligned center of their respective hosts.
Thanks,
DaVuLf
edit: on a sidenote, does anyone know why this preloader works in one .fla (only 2 frame, preloader on frame 1, image on 2) and doesn't work on another (only 2 frames, preloader on frame 1, Dynamic AS on frame 2).
This is code for preloader:
PHP Code:
onClipEvent(enterFrame) {
loaded = _root.getBytesLoaded();
total = _root.getBytesTotal();
percent = ((loaded/total)*100);
trace("Loaded: "+loaded+" Total: "+total+" Percent: "+percent);
_root.percentage = ((int(percent)+1)+"%");
this.bar._width = percent*2;
if (percent == 100) {
_root.gotoAndPlay(2);
}
}
Scaling An Externally Loaded MC Dynamically
Hi everyone
I've been searching for an answer to this, and I'm starting to think that it can't be done.
I'm working on a flash game
I'm scaling all the visual elements of the game based on their _y location on the gameboard. ( this fakes perspective )
as the game is becoming more complex, I would like to start keeping the gamepieces in seperate files ( so I can work on them seperately and load them dynamically )
the problem is that LoadMovie doesn't allow me to change the scale ( _x & _y )
and MovieClipLoader only lets me set the scale when a clip is loaded
is there something I'm missing? or perhaps another way?
my goal is to keep game artwork in seperate files, and load them dynamically and scale them dynamically. is there ANY way to acomplish this?
thanks!
Scaling A Dynamically Loaded Jpeg
I've had a good look through the forums but can't find any specific help on this topic. I hope I'm not duplicating a question if I missed something.
I have created a slide show for a selection of photographs which dynamically loads a jpg into the swf to save on load time at the start. I have an alpha fade between each image which works fine but I have a scaling issue. I have a caption button which slides in a bit of text for the photo and shrinks the photo to make room. The jpg is loaded into a movieclip using actionscript and then scaled again using actionscript. The scaling results in distortion lines and isn't as smooth as I would hope for. Does anyone know of any workarounds for this?
The link to the site is http://www.ethos-uk.com/matt/
Thanks in advance for any help
Matt
p.s. The site is obviously not finished
Loading And Scaling Images Dynamically
Hello..
I'm trying to load to different movie clip instances different pictures, and don't understand why it doesnt work..
Say I have instance 'pic', and in the main timeline I load a picture -
loadMovie("pic.jpg","/pic")
That works. But if I add before this line, or after, the statement :
pic._height=110;
Then I dont see the picture.
------------------------------------------
All this is done to create a modular button with changing images and text.. could anyone refer me to a smart clip button that receives text, and image file parameters, to display as the button's graphics?
Thanks,
Y.
Background Images For Different Aspect Ratios With Stage Scaling
Hi all!
I'm designing a flash website which uses a fluid layout (using listeners to reposition the stage elements when the browser is resized). For this I've used a background image which has a resolution of 1600 x 1200. The bg image looks okay on monitors which have an aspect ratio of 4:3 but looks terrible (squashed and distorted) on wide screen monitors.
I was wondering, is there any workaround to this?
Thanks!
AS3 - Content Centering/stretching/scaling On Stage Resize?
Hi guys,
I'm trying to develop a Flash site that has these characteristics:
1. Populates 100% of browser window real estate.
2. Holds content that is unscalable, but stays centered no matter how large the window is.
3. Also has content that stretches (header and footer) to the width of the window, but doesn't scale vertically.
I have an idea of how to do each of these in AS3, but every time I've attempted them I usually end up failing horribly.
Can anyone tell me a "best practice" method for pulling this off?
Getting 9-slice Scaling When Dynamically Attaching Clips
I'm having trouble with dynamically attached clips scaling incorrectly
They work when I just place them on the stage, but when adding them with the attachMoveClip function, the don't.
Is it possible to use 9-slice with dynamic clips?
Maintain Stroke Thickness In A Dynamically Scaling MC?
Is there any way to dynamically scale a movie clip and keep the stroke thickness of lines and size of the text within it from changing? The problem is that I need the lines to scale but without the stroke thickness' changing. I think I may have a solution to the text which would be to dynamically position it to the coords of graphics which scale with the clip on resize. I'm stumped on the lines thicknesses though. The lines are going from practically invisible to big fat things. Someone help me! I'd love to make this work...
Embedded Video And Scaling To Stage While Maintaing Aspect Ratio
Hi folks, I have a question about the best way to achieve a video scaling deal I'm trying to do. You can see what I have so far here:
http://www.sans-concept.com/AdamBlog/
The SWF I have at the top is currently 1024x240 pixels in size, but when I'm done it'll be 100% wide and 240 pixels tall. What I want to do is have the video running in that SWF scale with the browser window to always fill that SWF horizontally. The actual video is 640x480 pixels, but I'm cropping out the top and bottom with the SWF.
When the window is resized, I'd like for the video to maintain its aspect ratio as its scaled. That is to say, the SWF will always be 240 pixels tall, but the video inside it should scale proportionally to its original 640x480 size.
Can anyone help me with the best way to do this?
Loader Component Scaling Content To Include Off Stage Items
Hi everyone!
I'm trying load an external swf file into a loader component and it works great. However when that external swf file has an asset off-stage (that can't be deleted) the loader component will scale down the external swf and the off-stage assets are viewable in the main swf. Can anyone offer some help?
Thanks,
Rolando
Dynamically Scaling Dashed Lines Without Them Increasing In Size?
I'm trying to create a rectangular menu that is dragable, and has dashed lines connected from various areas of the screen, and then to each of it's four corners.
However, as far as I know, you can't "draw" lines in flash. Everyone uses the scale technique. However, Hairlines are the only lines that don't scale... and you can't make a dashed hairline. So...
Any way to "scale" a dashed line as if it were a hairline?
Also, these are "wavy" dashed lines, so I'm thinking that using the scale technique will give the appearance the lines keeping their anchor points. If the lines were redrawn somehow, how would we keep the same anchor points..
Anybody have any ideas?!!
Can A Stage Be Resized Dynamically
I am asking this question as you folks here seem to know your
****. I have learnt a lot from the people at flash kit so here i am again to ask a question.
I want to know if this is possible at all in actionscript.
I want to know that once a swf is playing whether a user can
resize their stage size for example if i had made a
thing where you could draw things and print it and i wanted the user to be allowed to change the stage size
can it be done please help
cheers pixelmagik
Set The Stage Size Dynamically?
Can the stage dimensions be set dynamically from inside or outside flash? And I don't mean within the embed tag. Sounds impossible but I thought I would ask.
~Dev
Resize The Stage Dynamically
Hi,
I have a Flash button that resizes dynamically depending on the length of text in a .txt file (thx wdhall) and was wondering if the Stage can be resized to fit around the button, dependant on how big the button is?
Basically, the button's size is determined by the length of text after it becomes a .swf. So scaling the .swf will not work as the button will also scale in proportion to the Stage.
Or can I just make the Stage transparent? (I know, a stupid question)
Many thanks again.
Dynamically Set The Stage Size
Is there a way to set the stage size based on parameters I feed a swf through the url line?
In essense I want to work around the fact that Stage.width and Stage.height are read only. Any ideas?
Is It Possible To Resize The Stage Dynamically?
Does anyone know if it's possible to resize the stage dynamically? Basically starting out with a small stage and then when going to a section of a site with a large amount of content you would change the size of the stage to a larger height value and allow the browser to scroll it.
I saw something along those lines here: http://www.bigspaceship.com/
Go to the Portfolio section and then click on All Projects.
Are they resizing the stage, or doing something else to get the browser scroll bars when it loads all the new content?
|