Resizing Stage
Hi--
I was wondering if there is a way to resize the stage when dynamically loading a .swf -- for example:
main.swf is 390px home.swf is 390px page01.swf is 1000px.
When I load home (into main) the stage stays the same, when I load page01 the stage would resize to 1000px and resize back with home, etc.
Is this possible? If so, what would be the code reference? stage.resizeorsomething??
Any help would be appreciated.
Thanks,
ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)
Posted on: 02-11-2006, 06:18 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Stage > Origin Issue When Resizing Stage
Hey. Its 7:00am and Im dead tired looking for an answer to my noob question.
Basically I was wondering if someone could explain to me why the origin of the stage changes when performing a browser resize?? The thing is that when it is resized to a size larger than the original stage size the origin has negative values. On the other hand when I resize the stage to a size smaller than the original I get positive values for the origin. (Upper Left hand corner).
Ive tried setting the stage.align property to top left but i still get these crazy values and i was just hoping that someone could explain this behavior to me.
Too make matters even worse is that the results I get when previewing the movie in the IDE Flash Player is not even close to the results I get in the browser Flash Player. Could it have something to do with the fact that I recently installed Flash Player 10?
Id also like to take advantage of this thread to ask if it is possible to set the stage w/h to 100% via the swf metatag. Ive tried to do this but have been unsucesful.
Here is the link... which is not even close to what Im seeing when previewing in the Flash IDE. '
http://www.pixelbrigade.com
Moving The Stage After Resizing - Or Moving All Objects On The Stage? Heeeelp
Hello! I'm in dire need of help!
I've been forced to resize the stage of my movie but as the stage is expanded to the right and down everything ends up in the wrong place. So I wonder:
Is there any way to move the stage rather than the contents thereon?
or
is there a way to move all the content on all layers and even all scenes simultaneously?
or
is there a way to expand the stage equeally on all sides rather than just right and down?
THANKS ALOT TO WHOEVER COULD HELP ME!
Freddy D, Stockholm, Sweden
When Resizing The Stage..
I want to resize the stage of a Flash movie, but I have already created the movie. Is there a way of doing this, without having to readjust all elements manually? The problem is I have to remove the upper part of the stage, and when I change the stage's size by clicking the Size button in the Properties window, some elements end up out of the stage, whereas the part I want to remove is still there (I included an image to show what I am having problems with doing, below).
In advance, I thank you for your help.
Regards,
RCarlton
Resizing The Stage ?
Ok so this may be a real simple one for somebody who spends a lot of time in Flash.
I have created a real basic flash animation, and it only uses a tiny bit of my stage/background. Now it would be silly to put the whole BIG flash move into a web page so I want to crop the stage to fit the gorgeous bits. Trouble is that when I do, it resizes to top left and half of my lovelies disappear.
Can anybody help??
Stage Resizing.
how can i center a movieclip in the middle of the page, but keep the stage the length and width of the page?
this is an example of what i mean: http://www.monokai.nl/
i don't want a scrollbar to appear either (i guess the auto stage-resizing would take care of that though)
thanks in advance,
stwelin
Resizing The Stage (?)
I'd think this should be easy, but I can't seem to learn how to do it.
I've a simple logo "crawler" with 11 logos scrolling left to right. I've 22 logos in all, two sets, to make the animation look continuous.
My actual document size is 340x 50. The stage appears to be approximately 2300 pixels wide. My problem is that I've run out of room on the first scene in the movie due to all my logos...they are disappearing off the right hand side of the screen.
Any way one can resize the screen in MX? Thanks in advance and I apologize if this is a frequently asked question I simply couldn't find in my web searches.
Resizing Stage
Is this possible ? I'm pretty sure it isn't, but I'll ask either way. I have a layout in Flash, but would like to resize the stage area and preferably keep the content centered as is, possibilities ?
Thanks.
Resizing Stage From Xml
i'm wanting to make a completely xml driven slideshow, and it is done except for being able to define width and height in xml. the slideshow can read them in fine, but i need a way to set the size of the stage according to xml values. because even if I have all of the content inside rescale with as, the html embed tag says width="400" height="300", and it's defined in xml to rescale to that height, if the stage is set to be 800x600, then everything in flash will still be scaled downto half size. is there a way to get around this? basically i just want to avoid having to republish the movie every time you want a new size so only the compiled swf can be given out
thanks,
chris
Resizing Stage
can u dynamically resize the stage to display all the content in the movie using actionscript? I want to show buttons and pictures that are added by actionscript from xml files or databases. since i will not know how many items i will have in the movie and i dont want a very big movie for little content i want to resize the stage or movie. can u do this?
Stage Resizing By Itself?
Hi,
I was trying out some stuff then i traced this in the oneneterframe section of a movie clip:
trace (stage.width);
I get the folowwing:
546
728
1020
1020
1020
. . .
There's NOTHING coded anywhere else, the flash is all default values, brand spanking new. (stage dim = 500x400 pixels)
Now I need to do some checks on that stage width value, but by the time i get there, it's already at 1020, which is not visually accurate.
Anyone got an idea?
Resizing Stage
I need to control the sizing of my swf... when viewing its html.
I have 1 background image, some static textfield and 1 other image that has a mask applied to it. That's it.
I'd like to be able to not have scrollbars on my html, and just be able to resize that window, and when doing so, my swf scales proportionally.
I've seen a swf once that did this, and on this, their smaller "masked" image, when page resized, it's mask also change to always match whatever the browser window was at.
So, if possible, I'd like to figure out how to do that, too.
Tnx!
Resizing The Stage...
I have a small problem (but after trying to fix it – seems to be a pain in the arse). I am finishing up my design on my portfolio and I have the document sized for 1024x768… Which is exactly what I wanted for my CD version that I can send out, but what I forgot to account for is that I also wanted to put this on the web.
Well on a screen that has a res of 1024x768 it cuts off the bottom part of my site that I would much rather have the page display it all… My saving grace is that the document has a free area of about 72 px around the outer edges so that if I made the stage size smaller – I theoretically could move my movie back to the center of the stage. But it seems that when I resize the stage, the “registration point” of the stage is in the upper left hander corner and it pulls up the stage to that direction making my stage member offset towards the lower right side… I guess what I am trying to ask is there an easy way to resize my document… I don’t need to make my instances smaller or anything else - I just need to decrease the size of the stage for my document to properly fit on a webpage. Any ideas or help would be awesome.
Yes I know I made a design error – I am beating myself for it now! Thanks again.
Resizing Stage?
I am building a flash .flv player that loads the .flv file dynamically then allows the user to enter some html into their site that allows them to add the player in and make it a certain size. How would I resize the stage to be the size of the movie? Can it be done either through the html or actionscript? I read somewhere that as doesent allow for the actual stage to be resized. Thank you for your help in advance..
Resizing The Stage.
Alright so I want to resize my stage to fit however large the browser window is. I found a couple threads that lead me to the Stage class, and the actionscipt dictionary gives this example:
ActionScript Code:
myListener = new Object();myListener.onResize = function () { ... }Stage.scaleMode = "noScale"Stage.addListener(myListener);
I don't know where to go from here, I dont know what function to write to accomplish what I want... any ideas?
Stage Resizing
hai can anyone tell me how the stage can be resized dynamically?....if i load a jpg into a movieclip the stage should resize itself to the size of the image file.
thanks in advance
Help With Stage Resizing Please
Hi I was wondering how I could resize my swf stage with buttons and change the look of things, without affecting what's in the webcam / chat area of something similar to this:
http://www.softservice.org/products_flashcam_demo.html
Thanks very much.
Stage Resizing
i have picture(s) for my background which are 1024x768 in size;
and i am loading the picture into a movieClip with new Loader();
the movieClip is initially located at 0,0 because the stage size is equal to the picture size.
-------
now i am trying to set a stage resize function to work like this:
if the stage is scaled for example to 1680x1050 i want that the picture scales to: stage.stageWidth, but i also want for it to always remain proportional.
so the size of the movieClip which holds my Loader would in this case have to be: 1680x1260 for a picture to remain proportional;
so, i would always say: (fullContainer_mc is the name of the movieClip)
fullContainer_mc.width = stage.stageWidth;
fullContainer_mc.height = ?;
so the first question is how to calculate this second number?
and what i also want, is if the picture is wider or higher than the screen (after resizing), to center it like its shown on the picture:
i think i can do it this way:
fullContainer_mc.y = (stage.stageHeight / 2) - (fullContainer_mc.height / 2);
fullContainer_mc.x = (stage.stageWidth / 2) - (fullContainer_mc.width / 2);
---------
i have found some code which looks like it does something similar, but i still havent figured out how to calculate fullContainer_mc.height = ? to begin with
var targetRatio:Number = stage.stageWidth / stage.stageHeight; // stage ratio
var destinationRatio:Number = fullContainer_mc.width / fullContainer_mc.height; // movieClip ratio
if (targetRatio > destinationRatio) {
fullContainer_mc.height = stage.stageHeight;
fullContainer_mc.scaleX = fullContainer_mc.scaleY;
} else {
fullContainer_mc.width = stage.stageWidth;
fullContainer_mc.scaleY = fullContainer_mc.scaleX;
}
fullContainer_mc.x = (stage.stageWidth / 2) - (fullContainer_mc.width / 2);
fullContainer_mc.y = (stage.stageHeight / 2) - (fullContainer_mc.height / 2);
Resizing The Stage...
I have a small problem (but after trying to fix it – seems to be a pain in the arse). I am finishing up my design on my portfolio and I have the document sized for 1024x768… Which is exactly what I wanted for my CD version that I can send out, but what I forgot to account for is that I also wanted to put this on the web.
Well on a screen that has a res of 1024x768 it cuts off the bottom part of my site that I would much rather have the page display it all… My saving grace is that the document has a free area of about 72 px around the outer edges so that if I made the stage size smaller – I theoretically could move my movie back to the center of the stage. But it seems that when I resize the stage, the “registration point” of the stage is in the upper left hander corner and it pulls up the stage to that direction making my stage member offset towards the lower right side… I guess what I am trying to ask is there an easy way to resize my document… I don’t need to make my instances smaller or anything else - I just need to decrease the size of the stage for my document to properly fit on a webpage. Any ideas or help would be awesome.
Yes I know I made a design error – I am beating myself for it now! Thanks again.
Resizing Stage?
I am building a flash .flv player that loads the .flv file dynamically then allows the user to enter some html into their site that allows them to add the player in and make it a certain size. How would I resize the stage to be the size of the movie? Can it be done either through the html or actionscript? I read somewhere that as doesent allow for the actual stage to be resized. Thank you for your help in advance..
Resizing The Stage
Hi all,
In Flash MX, is there a way to resize the stage so that the new area that is added is distributed evenly around the contents that are already on the stage?
I have a movie and decided that I want to increase the depth of it to 600px but want to distribute the added space equally above and below the contents. Can you do this just like you do in Photoshop?
Thanks in advance.
Rhiannon
Stage Resizing
Last edited by moedit : 2003-03-05 at 20:26.
Is there anyway to resize the stage and let the browser know it?
In the developping environment, it works with this simple code:
Code:
Stage.height = 1000;
But when testing it in the browser, prrrt! No resize
Does anybody know of a way?
Your humble servant for years to come,
Moedit the peon
(I'm trying to stay in the new monarchy spririt of US )
Stage Resizing On The Fly?
Hi guys, Im building a blog site in flash pulling content from WP and its going to be vertically formatted like an html blog.
Is there any way at all I can vertically resize the Stage with AS3 on the fly?
The reason for this is that I want to use the browser scrollbar rather than do the scrolling within flash.
thanks in advance
coldy
Help Needed On Resizing The Stage
I imported a swf and it came up with the actual presentation with a huge workarea aswell (stage). I was just wondering how you get just the picture and not the left-over stage around it when exporting to a .gif???
Dynamic Resizing Of Stage
I have a template swf that I plan on using to load stuff into (items of a catalog) dynamically. I need to be able to resize the movie so if there are say 20 items, then the height of the movie would expand so all of the items could fit within the height of the movie. I was thinking if I could dynamically change the height of the movie, then I could use the html frame that it is in to scroll up and down the flash movie. I've played around with Stage.height and Stage.width, but I can't seem to accomplish what I'm trying to do.
Hopefully you understand what the heck I'm talking about. If anyone can help me out it would be greatly appreciated!
Stage Resizing In HTML
Hello,
I am working on a personal project here:
NinjaCamp
And if you push the big red button there, you see that my footer goes down as it is supposed to. the problem is that the HTML for the page does not adjust the height value and so my footer slowly gets cut off as opposed to showing more of the swf.
So, my question is, is it possible to have the flash stage extend and the html properly display it, and how? In an ideal world it would be something in the embed tag that can accept dynamically changing stage sizes. Otherwise, some kind of scripting where when I change the size of the stage the html is rewritten or something would work too, if that's possible. Thanks for all of your help!
Jeremy
Is This Still The Case? (Resizing The Stage)
What I would like:
OnRelease (Stage.height = 768);
Browser then resizes scrollbar to accomodate the new size.
What I suspect:
You can detect when the stage is resized, but you can't actually resize it yourself dynamically.
Am I right?
Resizing Stage At Runtime
Hi,
What i am trying to do is create a small flash movie that i will use as my home page. What i want is two horizontal lines that extend the entire length of the browser window no matter what resolution you are viewing it at. I plan to have some content in between these lines. An i want them in the center of the viewable browser area. I do not want the content to be resized at all. Such that when the browser is resized the content remains the same size but just shifts location to be in the middle of the viewable region
eg.
----------------------------------------------------------------
logo a few nav buttons an image
----------------------------------------------------------------
How do i think about starting this? Do i start with a stage of size 1024x768 and use action script to detect the screen resolution and draw lines to fill this? Do i use javascript to do any of this? I've been messing around with this for a few days now and have become somewhat frustrated. Any help would be appreciated.
thanks
Andy
TransitionManager & Stage Resizing
Hey all,
So I'm building a page in AS3 that resizes to fill the entire browser window. I'm also using the TransitionManager to pull in my content. It flys in from the right side of the stage to the center and exits on the left. The problem is that when I resize the browser window, the transition manager doesn't put each content movieclip in the center of the stage. Instead, it appears to putting them back at the same coordinates before the resize.
Anyone else run into this problem?
Thanks!
Bill
Dynamic Stage Resizing........................
Hiya guys....
I am loading in an XML file to populate a menu I have. BUT I want to be able to dynamically size the stage based on the number of nodes (menu items) in the XML.
So if 8 nodes exist I want to be able take my button height (21)and multiply that by the # of nodes (8). Giving me a total height of 168 for my menu. Otherwise I am going to have to render out a menu that has empty space at the bottom of it.
My menu will change very frequently and there has GOT to be a way to do this. I saw on ericd.net that he has done something similar HERE http://www.ericd.net/scales2.html .
I only need to movie to scale on the Y axis.
Thanks gang!
Resizing The Stage Around Its Center
I have done some animation work on a stage 320px X 320px. I find that I must present the same work on a stage 240px X 320 px. If I use the Property Inspector window, I can enter the new stage size. Unfortunately, the window is resized with the left hand side of the screen as its reference point, effectively cutting off a large part of the right side of my work. I would expect to loose a piece of my animation at the right and the left evenly. How can I resize the stage around its center?
Thanks
Stuff Outside The Stage When Resizing
Hey guys,
When setting the HTML publish settings to percent, why does the published page show stuff that is outside the stage (but in the work area)???
Is there any way to publish the animation showing only the stuff on the stage and not anything outside it??
Resizing Flash Stage.
I have realized now that I need my stage to be bigger then the area I started with. The problem is that I need the current movie to be in the center (but it's auto at 0,0). Not all of the frames are moving with the others. Does anyone know how to make it all move to the center?
Thank's
Align To Stage When Resizing
Hello fellow humans,
I need to know how to align a _mc to the bottom of the stage no matter how large or small the browser is stretched.
right now I'm using this script to change the purpotions of a mc.
topstretch._width = Stage.width;
I know it must be close to the script used above I just cant find anything on the world wide web to tell me more.
Any help would be rad!
~Snake
Stuff Outside The Stage When Resizing
Hey guys,
When setting the HTML publish settings to percent, why does the published page show stuff that is outside the stage (but in the work area)???
Is there any way to publish the animation showing only the stuff on the stage and not anything outside it??
A Follow Up On Resizing Stage
Hey again;
Thanks for your response. I may end up using just one standard long stage length but before I give up let me ask another quest, if i may. A text field won't work for me because in a sense the text is the stage, laid out in photoshop, carved in stone, then I use flash to bring it to life. Any other ideas - is it possible to make say 20 short one page movies (that way each page's W&H demands can be met)and then string them, publish them, together as one movie? Or is that just more work than it's worth and I should just use a standard length page?
I should mention that on longer length pages I will be using a scrollpane as soon as I figure out how to do that.
Again, any help is much appreciated.
Hoss
Resizing Stage Outside Of Flash
OK pardon the flame protection but I know you can resize movies in flash or make them static outside of it but here's my situation:
I have a movie that is aligned to the bottom of the browser, and has 100% width but a fixed height. However, after the animation plays thats in the bottom left of the browser, I want content to pop up over it and the stage size to change in html, forcing the movie to be longer and thereby letting the user scroll up the page with the normal chrome scrollbar to see the content.
I suppose I could bring some javascript in to focus on the bottom of the page at the beginning, but I thought I'd make sure that its impossible to use javascript or something from flash to the browser to resize the static stage height.
Dynamic Stage Resizing............................
Hiya guys....
I am loading in an XML file to populate a menu I have. BUT I want to be able to dynamically size the stage based on the number of nodes (menu items) in the XML.
So if 8 nodes exist I want to be able take my button height (21)and multiply that by the # of nodes (8). Giving me a total height of 168 for my menu. Otherwise I am going to have to render out a menu that has empty space at the bottom of it.
My menu will change very frequently and there has GOT to be a way to do this. I saw on ericd.net that he has done something similar HERE http://www.ericd.net/scales2.html .
I only need to movie to scale on the Y axis.
Thanks gang!
Resizing Stage And Listener Problem
Any help on this would be greatly appreciated.
I am trying to make an expandable movie that that keeps interal elements a constant size. I want the background stay aligned with the upper left corner and have the content stay flush left.
This all works fine if the background is embedded within a mc (bg_mc)on the main timeline. What I want to do however is load "bg.swf" into an empty an empty mc. As soon as I load anything into "bg_mc" the dynamic positioning functions fail to run for some reason. When I try to list variables none of the variables have been created after resizing the stage. Everything is broken. This doesn't make any sense to me. Can someone explain what my problem is - I'm at a loss?
Thanks a lot. Code is below.
fscommand("allowscale", "false");
// switch to showAll mode
Stage.scaleMode = "showAll";
Stage.originalWidth = Stage.Width;
Stage.originalHeight = Stage.Height;
// switch back to noScale
Stage.scaleMode = "noScale";
Stage.onResize = function() {
this.left = this.getLeft();
this.top = this.getTop();
this.right = this.getRight();
this.bottom = this.getBottom();
};
// retrieve boundaries
Stage.getLeft = function() {
return -1 * (this.width - this.originalWidth) / 2;
};
Stage.getTop = function() {
return -1 * (this.height - this.originalHeight) / 2;
};
Stage.getRight = function() {
return this.left + this.width;
};
Stage.getBottom = function() {
return this.top + this.height;
};
//problematic code - remove this and make the background embedded
//in a static mc and everything works fine
_root.createEmptyMovieClip("bg_mc",1);
loadMovie("bg.swf",bg_mc);
Stage.addListener(Stage);
// register bg to receive notification of onResize
Stage.addListener(bg_mc);
bg_mc.onResize = function() {
this._x = Stage.left;
this._y = Stage.top;
};
Dynamic Stage Resizing And Netscape
Allright, after forever and a day I was able to make a html page that only loads the swf once, and have the swf resize as needed (content for tabs is loaded via a .txt file)
In the flash I have:
Stage.scaleMode = "noScale";
Stage.align = "tl";
in frame1. Then in the html I have
< table border=1 height="100%" >
< tr >< td id="tar" valign="top">
< OBJECT classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
WIDTH="475" HEIGHT="100%" id="asd" ALIGN="">
< PARAM NAME=movie VALUE="test2.swf" >
< PARAM NAME=quality VALUE=high >
< PARAM NAME=bgcolor VALUE=#FFFFFF >
< EMBED src="test2.swf" swLiveConnect=true quality=high scale=exactfit bgcolor=#FFFFFF WIDTH="475" HEIGHT="100%" NAME="asd" ALIGN=""
TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" >< /EMBED >
< /OBJECT >
</td>
</tr>
</table>
OK. This works in IE but netscape won't resize beyond the original height.
Any ideas on this would help the insanity.
Oh yah, I can't have scroll bars, so that's not an option.
Gracias
Resizing The Stage, Can't Remember The Site...
Okay, it's probably been a year since I saw this website, but it was really cool and I need to find it. The site was kinda pink and it had a big white star in the middle. The cool thing about the site was that when you resized the browser window, it resized the flash movie, but did not scale any of the elements. The site listed a bunch of flash components, similar to what flashcomponents.net does. Does anyone remember the site or where to find the technique for doing that?
Thanks guys, my old age is getting to me...
Resizing Main Stage Dynamically
I've seen this before and haven't found it by searching. The main stage or movie clip changes it's x/y coordinates when a navigation button is clicked. For example, when the "News" section is clicked, the main stage changes to 300x100.
There are a few sites that i've seen do this. Any places I can look or any code out there?
Resizing Clip To Use Entire Stage
I'm attempting to create a graph that will resize when the browser resizes, but I'm kind of confused on resizing and scaling. The code below demonstrates my problem by attempting to draw a diagonal line from the top left to the bottom right corner. Works ok on initial load but not on resize. Can someone explain what I'm missing? Thanks!
stop();
Stage.alignMode = "LT";
Stage.scaleMode = "noScale";
Stage.addListener(this);
// Non-CPU intensive resizing
function onResize() {
if(this.intervalId) return;
this.intervalId = setInterval(this,"_onResize", 200);
};
this._onResize = function() {
this._resize();
clearInterval(this.intervalId);
delete(this.intervalID);
};
this._resize = function() {
this.canvas_mc.draw(Stage.width, Stage.height)
}
this.createEmptyMovieClip("canvas_mc", 1);
this.canvas_mc.draw = function(width, height) {
this.clear();
// Various experiments with _x,_y,_width,_scale, etc tried here
this.lineStyle(1, 0, 100);
this.moveTo(0, 0);
this.lineTo(width, height);
}
this._resize();
Stop Automatic Stage Resizing
Hi guys?
Can anyone tell me how i can stop flash from resizing my stage whenever a moviclip exceeds the pre-set screen boundaries?
its driving me nuts: i've got a scrolling game and i'm happy for the map to be big, but placement of other game content depends on keeping the stage the same size throughout.
I greatly appreciate any help!
best wishes
PNGs Resizing Themselves When Dragged To Stage.
I'm having a heck of a time trying to figure out why my PNG files which are 791px x 567px in my library resize themselves to 593px x 435px when I drag them to the stage! Dragging GIF or JPG files to the stage does not resize them. What am I doing wrong... this is driving me nuts?! I'm using Flash CS3. I didn't have this issue with Flash 8.
Resizing Stage To Fit Multiple Screens
Hi, I'm designing a Flash website and I want the stage to fill the viewer's screen, similar to www.s-w-h.com. I've always designed flash sites with one particular size in mind, never for multiple screen sizes. I know there's a Stage.onResize property I can use, but I'm sure there must be a limit to the actual size of the viewers screen, otherwise it would kill my layout and design. I'm wondering whethere there's a technique flash designer's use to effectively and optimally resize, i.e. choose only 3 stage settings and work around them, or 3 browser types (IE, Safari, Firefox) and work from there. I ask this because I have also noticed that my Firefox browser fits my whole screen while my Safari browser does not. So there are many variables to consider. What would be the best way to apprach this?
Content Not Resizing To Center Stage
Hi
I am having some problem with resizing my content to my stage.
I am loading in a baggrund image and setting a tile. The background and tile are resize according to the stage. When the preloader is done and removed i load the content. Right now i'm just loading a image, but i want the image to be at the center stage. When i load its like it is the sprites registration point thats being centered. When i resize the browser it jumps to the center. Can anyone tell me why?
Here is my code for.
Code:
package classes {
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.*;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.geom.Matrix;
import flash.display.Bitmap;
import gs.*;
import gs.easing.*;
public class mainCore extends Sprite {
private var tile :Sprite = new Sprite();
private var bg_ldr :Loader = new Loader();
private var bgHolder :Sprite = new Sprite();
private var preloader :Sprite = new Sprite();
private var showPercent :Number;
private var _shellHolder :Sprite = new Sprite();
private var _shell :shell
private var _menu :menu;
public function mainCore() {
bg_ldr.load(new URLRequest("graphics/bgtest.jpg"));
bg_ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onBgComplete);
bg_ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, checkProgress);
bgHolder.addChild(bg_ldr);
addChild(bgHolder);
bgHolder.alpha = 0;
tile.alpha = 0;
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.align=StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, resizeHandler);
trace("constructor");
_shellHolder = new Sprite();
}
private function resizeHandler(e:Event):void {
makeBackground();
}
private function onBgComplete(e:Event) {
TweenLite.delayedCall(0.5, removePreloader);
}
public function removePreloader() {
makeBackground();
removeChild(preloader);
addChild(tile);
TweenLite.to(bgHolder, 1, {alpha:1,onComplete:loadShell});
TweenLite.to(tile, 1, {alpha:1});
}
private function checkProgress(p:Event) {
var percent:int = (p.currentTarget.bytesLoaded / p.currentTarget.bytesTotal) * 100;
drawPreloader(percent);
}
public function drawPreloader(percent:Number) {
showPercent = (stage.stageWidth/100) * percent;
preloader.graphics.lineStyle();
preloader.graphics.beginFill(0xFFFFFF);
preloader.graphics.drawRect(0,0,showPercent,10);
preloader.graphics.endFill();
addChild(preloader);
}
private function makeBackground() {
var sW = stage.stageWidth;
var sH = stage.stageHeight;
bgHolder.width = sW;
bgHolder.height = sH;
bgHolder.scaleX <= bgHolder.scaleY ? (bgHolder.scaleX = bgHolder.scaleY) : (bgHolder.scaleY = bgHolder.scaleX);
tile.graphics.clear();
tile.graphics.beginBitmapFill(new patternTile(1,1));
tile.graphics.moveTo(0, 0);
tile.graphics.lineTo(sW,0);
tile.graphics.lineTo(sW, sH);
tile.graphics.lineTo(0, sH);
tile.graphics.lineTo(0, 0);
tile.graphics.endFill();
_shellHolder.x = Math.round((sW/2)-(_shellHolder.width/2));
_shellHolder.y = Math.round((sH/2)-(_shellHolder.height/2));
}
public function loadShell() {
var _shell:shell = new shell()
_shellHolder.addChild(_shell)
addChild(_shellHolder);
}
}
}
Here is the code for shell. It is here i load the content.
Code:
package classes {
import flash.display.Sprite;
import flash.events.*;
import flash.net.URLRequest;
import flash.display.Loader;
import gs.*;
import gs.easing.*;
public class shell extends Sprite {
private var _logo_ldr :Loader = new Loader();
private var _logoHolder :Sprite = new Sprite();
public function shell() {
animateBottom();
trace("SHLL COUNSTRUCTOR");
}
public function animateBottom() {
_logo_ldr.load(new URLRequest("graphics/test.png"));
_logoHolder.addChild(_logo_ldr);
addChild(_logoHolder);
}
}
}
Stage.width, Resizing, And Positioning? Going Crazy
Hi,
I'm trying to create a swf, that when resized will place a close button in the top right hand corner:
Code:
_____________________________________________
// _________________________________DETECTION
// Capture Flash stage dimensions...
stageW = Stage.width;
stageH = Stage.height;
// Move close button to top right hand corner
_root.closeButton._x = stageW;
_root.closeButton._y = stageH-StageH;
//
// Set noResize because we will handle
// resizing from now on...
Stage.scaleMode = "noScale";
//
// function to run when resized...
function stageResize() {
newWindowX = Stage.width;
newWindowY = Stage.height;
_root.closeButton._x = newWindowX;
_root.closeButton._y = newWindowY-NewWindowY;
}
// Add listener for the Stage.onResize event...
myListener = new Object();
myListener.onResize = function() {
stageResize();
};
Stage.addListener(myListener);
stageResize();
Code:
____________________________________________
What am I doing wrong? I've been racking my brain for hours on this!!!
TIA,
oldspirit
|