ActionScript 3.0 :: Control The Stagewidth And Stageheight Using Script?
Sep 10, 2009How do control the stagewidh and stageheight Using script in AS3?
View 1 RepliesHow do control the stagewidh and stageheight Using script in AS3?
View 1 RepliesI'm having issue regarding the display when using Firefox 3.5 on MAC, I can see my menu and the display is correct. The menu just position above what it supposed to be positioned. It works fine with Safari on MACOSX.My flash size is: 1440x750It looks like Firefox can't recognize stage.StageWidth and stage.StageHeight. It returns 0.Some suggest implementing was to pass in the actual width and height of movie via FlashVars. The movie uses these instead of stage.stageWidth and stage.stageHeightDoes anyone have an example of code of how to fix that issue??
public function Main()
{
addEventListener(Event.ADDED_TO_STAGE, handleOnStage, false, 0, true);
[code]....
Working on personal full flash site and I can't really figure out how to make MC's position on Stage aligned on Firefox browser. Everything goes fine using Safari.
I have tried a method of set a timer every time it goes off (every 200 ms or so) it checks to see if stage.stageWidth > 0. If that is the case, do stop the timer and start resize on stage. However it's still not working on Firefox of MAC. :(
In my HTML code:
<link href="css/site.css" rel="stylesheet" type="text/css" />
Test Site
<script type="text/javascript">
var swf = new SWFObject("main.swf", "mymovie", "100%", "100%", "10", "#000000");
swf.addParam("allowScriptAccess", "always");
[Code]....
I am using SWFOBJECT to embed my flash content. I have been worried about stage.stageWidth and stage.stageHeight returning 0 in Firefox/Internet Explorer; this problem is referred to in question #21 on the SWFOBJECT FAQ [URL]..I have been told that this problem is particularly prevelant on Macs. The SWFOBJECT FAQ (question 21) indirectly suggests that this problem does not occur with static publishing. Is this correct? Is it still advisable to implement a solution to this stageWidth/stageHeight problem, even if you are using static publishing?
View 1 RepliesI've been working on a project that requires lots of scaling around a center point.
I always thought that stage.stageWidth and stage.stageHeight give you the dimensions of the stage you set in the properties panel no matter what. But when I went into fullscreen mode (with scaling), both the width and the height changed to the dimensions of the screen rather than staying the dimensions I specified.
In my AS3 code all the elements on the page are dynamically positioned depending on the current width and height of the SWF - providing it's not under a certain value, then the items are back in their original position.
When debugging in the Flash player the size all reports correctly however when run from a web browser it does not - initially.
This is my HTML & PHP code for the entire page:
HTML Code:
<?php
function hashId($fn) {
$hash=md5_file($fn);
[Code].....
But I cannot get the size to report correctly without, say, clicking a button.
It seems to me like I need to force flash to re-draw the screen, but I had no luck trying to do that.
can you tell me a simple and clean way to pass the dimension of the stage to another class, imported in my documentclass?
View 2 RepliesI have two problems. 1) the page still will not resize properly until the window is resized. I assume I have the code wrong somehow.
2) I changed the height of my menu object to stage.stageHeight, but its now coming up squished and only about 30% of the actual height of the stage. I am not sure what I did as it seemed to be working before, but I cant seem to fix it.
Code:
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, stageresizeListener);
[Code]...
I just noticed a workaround something that's been annoying me for a long time. Occasionally my projects vertically line up funny if clip y-coords or heights are based on frame 1 stageHeight. I always thought it was a load-time duration or something like that, but it turns out to be bandwidth profiler (CS4 authoring). Try this on frame 1 of a new, empty project:
this.addEventListener(Event.ENTER_FRAME, this.entf); function entf(evt:Event):void{ trace(this.stage.stageHeight); }
When bandwidth profiler is on, the first frame reports -100 the real stageHeight. Now to avoid the problem I just turn off bandwidth profiler. Is it just a bug?
I have a class with the following code in it's constructor (eventSprite is just a circle added to the stage):
Code:
eventSprite = new Sprite();
addChild(eventSprite);[code].........
I've seen this in several of my projects, when testing the stage.stageHeight is 100 less than what I've set the property to. I looked around and found at thread from 2004 (AS2) that talks about it, and found one in 2009 (AS3)With this in mind, I almost always have this:
ActionScript Code:
var SW:int = stage.stageWidth;
var SH:int = stage.stageHeight;
[code].....
how to make my package use stage.stageHeight so I can tell a ball to bounce when it reaches the bottom of the stage. I'm calling my ball to the stage from the library in a way I'm not used to and have never done so I'm assuming it has got to do with that. if you take a moment to look at it (pretty simple i've stripped out everything except for the physics that makes a ball drop and bounce) and let me know why I cant detect the stage.
particle.as file:
[Code]......
Anyone else has experienced weird behaviors and unexpected values when checking for stage.stageHeight while you have Bandwith Profiler open in Flash IDE?
I have been using this for testing Perlin Noise stuff:
[Code]...
As you see here, the swf is set to a height of 400 When executed with test movie, control-enter, the trace returns 400 .. now, if you try this with the Bandwidth Profiler open, it would return 300, and the Sprite would only extend to 300 height.
I am trying to get the stage width of the FLA in as3. Obviously, stage.stageWidth works well, the only issue is that when viewing the the SWF in an HTML page when you are zoomed in or out it gives you the relative width of your current view. For example, my stage width is 800x600 and when I trace out the stage.stageWidth it is showing up as 800 as long as I am viewing in my browser at 100 percecent, but once I zoom out in my browser the stageWidth gets traced out as a smaller number. Does anyone know how I can dynamically get the stageWidth of the FLA and have it not change regardless of how you are viewing the HTML page
View 1 RepliesI use mxmlc to compile as file,I use default stage.stageWidth to draw some grahpics,such as:
[Code]...
I have a 2 swfs, home.swf loads into main.swf. However the stageWidth/Height that I defined they are now pointed to main.How can I get stageWidth and stageHeight pointed to home.swf instead?
View 1 RepliesI use mxmlc to compile as file,I use default stage.stageWidth to draw some grahpics,such [code]...
View 2 Replies When I test the swf straight from Flash, the stageWidth is 800 pixels. This is correct. When I load the swf using an HTML page in Firefox, it tells me the stageWidth is 0. I've stripped the whole thing down to just the following script and slapped a bright green frame into the first layer of FLA so I can see the edges of the stage. The SWF is displaying at 800 X 800 but the number displaying in the text field is "0" in a browser, and "800" when the swf is playing stand-alone.
package com.maijag.threedee{ import flash.display.*; import flash.text.TextField;
public class SwarmTest extends Sprite { private var myParent:Object;
public function SwarmTest() { myParent = this; // this textField is just to see what the stageWidth is in
[code]....
I'm trying to get the width and height of the stage to position my objects when the user resizes the window, but I can't figure out how.
I've Googled a lot and found some examples and my last try looks like this [code]...
So I'm trying to do a simple graph with rollover definitions. I have the graph on one layer in the root along with the definitions. On a hit testing MC I have the following:
var defbox:info = new info();
var mcName = this.name;
var xPos = (MovieClip(parent).stage.stageWidth)/2;
[code]....
Experimenting with Flash as usual.Preloader's are always something that have caused me trouble.Here's what I typically use for a timeline based preloader in AS3:
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(e:Event):void {
var total:Number = this.stage.loaderInfo.bytesTotal;[code].......
I'm really interested in a preloader that loads right across the stage however - regardless of if the stage is resized.I should imagine it'll involve implementing = Math.round(stage.stageWidth); at some point?
I am trying to set masks and other component positions in relation to Stage size.AS3 CS5I trace stage.stageWidth on a 800x600 pixel stage and I get - 100My stage will scale within a Director piece.Is this a bug? Modal condition? Releated to scaling??
View 7 RepliesI have a full-windowed SWF running in Firefox3.6.Reading stage.stageWidth should follow the size of the browser's window, but that's not the case with Firefox! The minimum stage.stageWidth I get is 925, even if I make the Firefox window much smaller than that.stage. stageHeight seems to work fine though.This is because the (my?) Menu Bar won't go below 925 pixels wide. The problem is solved if I hide the Menu Bar!
This problem only appears on Firefox. Anyone knows if there is a work around? I can't ask users visiting my site to turn their menu bar off in order to see it correctly.
I created a custom class in a .as file. I then linked this custom class with a symbol from the library in my .fla file. However, I can't reference stage.stageWidth in my custom class file. I get a null object error.
I think this happens because the custom class file is associated with a symbol on the stage and not the stage itself. For example, if I set the fla file's Document Class to the name of my custom class I can reference stage.stageWidth in the custom class. But I don't do this because I am creating multiple instances of the symbol on the stage. In order to do that properly i found I have to set the class in the properties panel of the symbol to the underlying class which then defines how each symbol behaves.
Under this type of linkage, is there a way to reference the stage width from the class? I've tried root.stage.stageWidth and parent.stage.stageWidth to no avail. I also made sure to import flash.display.* in my custom class. Below is the code for my .fla file and my .as file. In the .as file you'll see the line "x = Math.random() * stage.stageWidth;". This is the line giving me problems. I could hard code it, as I do for the y variable on the next line, but I'd prefer not to in order to keep the code flexible.
[Code]....
The old loaded swf issue. How can I keep the dimensions of the loaded SWF to that of its FLA, and not to the new stage where it is loading? I know there is only one stage, so i just have to hard-code this into the loaded SWF right?
View 9 RepliesI made a class to create and handle a google map in my swf and everything works very well. But I want to make my layout completely liquid. To acomplish this, I need to call the stage from the class... But it doesnt seem to be so easy.
the code is bellow:
[Code]....
Well everything was going well until I tested my project in a browser (embeded using SWFObject if that matters). After all the troubleshooting, it turns out that the stageWidth/Height values were just 0 which threw off the whole thing. The stage is set up by the DocClass (some unrelated stuff taken out to make it shorter):
[Code]....
I've got a MovieClip that gets positioned in respect of the stage.stageWidth/stage.stageHeight which works completely fine in the stand-alone Flash Player, however when embedded into a webpage with the "showAll" param it gets cropped. Is anyone aware of some sort of issue with stageWidth not being updated when using the scale param in the embed code?
View 1 RepliesI've decided to start re-writing my project, but this time making the use of class files rather than nesting code inside my MovieClips.
Now it's come to the "message box" that I previously wrote, and I'm having some troubles. (note: I don't really want to download a pre-built one as my message box class end up being the backbone for several custom interfaces).The problem is that I cannot, for the life of me, figure out why my message box class cannot access "stage.stageWidth", "stage.stageHeight", "MovieClip(root).currentWidth", etc.
This is the code for the working "messageBox.as":
ActionScript Code:
package com.components{
import flash.display.Shape;
import flash.display.MovieClip;
[code]....
I've tried several variations of creating the movie clip, but to no avail. I've tried like creating a global movie clip variable and that attatching the movieclip to it in this function, the same with a display object, creating a function variable and doing both of the above, etc.I just cannot figure it out! All of my other classes are working just fine!
I want to make horizontal easing that depends on stagewidth. I have made all coding and it works fine, but text in easing MC becomes sometimes slightly blured. I use pixel fonts and the start position is a round number: x.0 y.0Is there any way to put some variable that makes corrections, like in some scrollers? Maybe it's impossible because when someone resizes browser window it isn't on round number, or it is?
View 9 Replies