Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Property For Finding A Loaded Movies Stage Width?



The title says it all.
Is there any way I can get the stage width of a movie that I load into my swf?



FlashKit > Flash Help > Flash MX
Posted on: 09-27-2006, 06:00 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Finding The Stage's Width
I don't know what to do. I want to figure out the stages width. I know of two ways: Stage.width or _root._width. What exactly do these do? Why do they change? Shouldn't the movies width stay static? I'm confused...

Finding Stage Width From A Class
I know this should be straightforward, but for some reason it's not working ...

I want to create a 'Square' class that will automatically bounce off the "walls" (edge of the stage) so it needs to know the dimensions of the stage to do this. But using Stage.stageWidth or any of a dozen other things I've tried just doesn't work.

The error I get is:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Square()
at SquareTest()
My code is below - if someone can help, that would be very much appreciated!







Attach Code

package {
import flash.display.MovieClip;
import flash.display.Graphics;
import flash.display.Shape;
import flash.display.Sprite;

public class Square extends Sprite {

private var side:uint;
private var colour:uint;
private var hspeed:Number;
private var vspeed:Number;
private var moving:Boolean;
private var bounceable:Boolean;

public function Square (sideLength:uint, col:uint=0x00000,
myX:Number=0.0, myY:Number=0.0):void {

if (sideLength < 1) {
trace("side length must be at least 1 pixel");
return;
} else {
side = sideLength;
}
if (col < 0) {
trace("not a valid colour!");
return;
} else {
colour = col;
}
this.x = myX;
this.y = myY;
// decisions about other properties' initial values
hspeed = 0.0;
vspeed = 0.0;
moving = false;
bounceable = false;

// actual code to draw the Square
var square:Shape = new Shape();
square.graphics.beginFill(colour);
square.graphics.lineStyle(0,colour); // no border
square.graphics.drawRect(0,0,side,side);
square.graphics.endFill();
addChild(square);
}

public function showWidthOfStage() {
trace("stagewidth is " + Stage.stageWidth);
// have tried MovieClip(parent).stage.stageWidth and other options as well
}

// other functions
}
}

Finding Out The Width Of A Loaded Swf
hello. i need some help. i am loading in these swfs into this movieclip with a width of 100. but these swfs are all different widths and I want to put them in different places on the screen depending on how wide they are.

the problem is that flash doesn't change the movieclip width property once it loads an swf inside of it. it is still the same.. i did this as a test:

movieName = "testmovie.swf";
duplicateMovieClip(_root.stupid, "dummy", 1);
setProperty("dummy", _x, 100);
trace(dummy._width); // before loading swf into movieclip
loadMovie(movieName, "dummy");
trace(dummy._width); // after loading swf

it prints out 100 both times even though the swf i loaded into that movieclip was larger than 100 pixels wide. is there an easy way to find out the width of a loaded swf?

thanks,

~jimmy.

Finding Width Of Loaded Img
What I want to happen is a movieclip of text aligns 20px to the right of the loaded img, similar to what padding does in css, the code I am using is:
textFields._x = (picture._width+20);
textFields is the movieclip of text and the image is loading into picture

What actually happens is the the text aligns to picture._width but before the image the image has loaded or I am not telling it the right place to look for ._width

I'll include the .fla in for convenience

As always much thanks to anyone with a suggestion

How To 'read' Stage.width Property In An External Swf?
hi guys,

I load an external swf in a component I wrote. Is it possible to get actual stage size (not _width / _height) and background color for the swf?
I noticed Dreamweaver does it, but I don't know how...

ciao ciao
stv

Finding The Width Of Dynamically Loaded Images
ok im working on loading images dynamically and getting there width and height i have heard that you need to have the images loaded before you can have accesses to there width and height values. i have an attached an swf of what i have been trying to do, all the code is on the first frame, i have comment up the code.

Help Finding Loaded Content Width/height AS3
I am loading an image in to this pre-made button class.
I would like to be able to retrieve width/height of the image from outside of this class. So when I add it to the stage, I can put another next to it programatically not hard coded.

ie: Code:

button2.x = button1.width + 5;

currently if I Code:

trace(button1.width) // 0

the reason I want to do this is so I can load on image for a left and right button and just rotate one of them. Right now when I rotate the button it's x/y coordinate up and to the left.

implementation Code:

var buttonRT:Button = new Button("arrow.jpg", false);

Code:

package
{
   import flash.display.SimpleButton;
   import flash.display.DisplayObject
   import flash.display.BitmapData;
   import flash.display.Bitmap;
   import flash.display.Loader;
   import flash.net.URLRequest;
   import flash.events.Event;
   import flash.filters.BevelFilter;
   import flash.geom.ColorTransform;
   import flash.geom.Matrix;
   
   public class Button extends SimpleButton
   {
      private var _content:DisplayObject;
      private var _isBeveled:Boolean;
      private var _bitmapData:BitmapData;
      private var _angle:int;
      
      
      public function Button(content:*, isBeveled:Boolean = true, angle:int = 0 )
      {
         _isBeveled = isBeveled;
         _angle = angle;
         if(content is String)
         {
            var loader:Loader = new Loader();
            
            
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, draw);
            
            
            var request:URLRequest = new URLRequest(String(content));
            loader.load(request);
            _content = loader;
         }else if(content is DisplayObject)
         {
            _content = DisplayObject(content);
            
            
               draw(null);
            
            
         };
      };
      
      private function draw(event:Event):void
      {
         
         var changed:Event = new Event(Event.CHANGE);
         
         var bitmapData:BitmapData = new BitmapData(_content.width, _content.height,
                              true, 0xFFFFFF);
         
         var matrix:Matrix = transform.matrix;
         var rotation:Number = 2 * Math.PI * (_angle / 360); // 60˚
         
         matrix.rotate(rotation);
         
         transform.matrix = matrix;
         
         bitmapData.draw(_content);
         var up:Bitmap = new Bitmap(bitmapData);
         var over:Bitmap = new Bitmap(bitmapData);
         var down:Bitmap = new Bitmap(bitmapData);
         if(_isBeveled)
         {
         var bevel1:BevelFilter = new BevelFilter(2);
         var bevel2:BevelFilter = new BevelFilter(2, 235, .6, 1, .2, .6);
         
         up.filters = [bevel1];
         over.filters = [bevel2];
         down.filters = [bevel2];
         }
         var colorTransform:ColorTransform = new ColorTransform(.9, .9, .9);
         over.transform.colorTransform = colorTransform;
         
         colorTransform = new ColorTransform(.7, .7, .7);
         down.transform.colorTransform = colorTransform;
         
         upState = up;
         overState = over;
         downState = down;
         hitTestState = up;
      };
      
      
   };
}

Loaded Image.width Be Stage.width On Resize
Hello... I am trying to make a loaded image.width be the stage.width on resize... the same for the height... I'm tweening them also... and that seems to be working... well on the yx... not so much on the width.... If I use Stage.width directly in the tween it seems to not load the image... little lost here... thank you for any help...

jeremyBass

here is what I have which is the whole file

ActionScript Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;


// ***Stage aligned top left
Stage.align = "TL";
// *** Stop the stage from scaling with the browser window.
Stage.scaleMode = "noScale";
Stage.showMenu = false;
stop ();


image_mc1.loadMovie("http://hellscanyonsportfishing.com/images/testhead.png");
image_mc2.loadMovie("http://hellscanyonsportfishing.com/Scripts/flash/bk.jpg");
image_mc1._quality = "BEST";
image_mc2._quality = "BEST";
// initiate postitions and scaling values for objects

v = Math.random() * 6 - 3;
v = Math.random() * 6 - 3;
var curStageheight = Stage.height;
var curStagewidth = Stage.width;
imageHolder._height = curStageheight;
imageHolder._width = curStagewidth;
//var xScaleT:Tween = new Tween(image_mc1, "_rotation", Elastic.easeOut, 0, 10, 4, true);

var xScaleT0:Tween = new Tween(image_mc1, "_x", Bounce.easeOut, 0, -2*v, 3, true);
var xScaleT1:Tween = new Tween(image_mc1, "_y", Bounce.easeOut, 0, -6*v, 4, true);
var xScaleT4:Tween = new Tween(image_mc2, "_width", Bounce.easeOut, imageHolder._width*1.1, imageHolder._width*1.15, 3, true);
var xScaleT5:Tween = new Tween(image_mc2, "_height", Bounce.easeOut, imageHolder._height*1.1, imageHolder._height*1.15, 3, true);
var xScaleT2:Tween = new Tween(image_mc2, "_x", Bounce.easeOut, 0, 0-2*v, 2, true);
var xScaleT3:Tween = new Tween(image_mc2, "_y", Bounce.easeOut, 0, 0-8*v, 2, true);
xScaleT0.onMotionFinished = function() {
    this.yoyo();
};
xScaleT1.onMotionFinished = function() {
    this.yoyo();
};
xScaleT2.onMotionFinished = function() {
    this.yoyo();
};
xScaleT3.onMotionFinished = function() {
    this.yoyo();
};
xScaleT4.onMotionFinished = function() {
    this.yoyo();
};
xScaleT5.onMotionFinished = function() {
    this.yoyo();
};


image_mc1._y = 0;
image_mc1._x = 0;
image_mc2._y = 0;
image_mc2._x =  0;

//create a listner that checks to see if the browser window is resized
sizeListener = new Object();
sizeListener.onResize = function() {
    // change movieclip properties when the window is resized.
var curStageheight = Stage.height;
var curStagewidth = Stage.width;
imageHolder._height = curStageheight;
imageHolder._width = curStagewidth;


//create a random velocity for x and y direction
};
Stage.addListener(sizeListener);

Loaded Image.width Be Stage.width On Resize
Hello... I am trying to make a loaded image.width be the stage.width on resize... the same for the height... I'm tweening them also... and that seems to be working... well on the yx... not so much on the width.... If I use Stage.width directly in the tween it seems to not load the image... little lost here... thank you for any help...

jeremyBass

here is what I have which is the whole file

Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;


// ***Stage aligned top left
Stage.align = "TL";
// *** Stop the stage from scaling with the browser window.
Stage.scaleMode = "noScale";
Stage.showMenu = false;
stop ();


image_mc1.loadMovie("http://hellscanyonsportfishing.com/images/testhead.png");
image_mc2.loadMovie("http://hellscanyonsportfishing.com/Scripts/flash/bk.jpg");
image_mc1._quality = "BEST";
image_mc2._quality = "BEST";
// initiate postitions and scaling values for objects

v = Math.random() * 6 - 3;
v = Math.random() * 6 - 3;
var curStageheight = Stage.height;
var curStagewidth = Stage.width;
imageHolder._height = curStageheight;
imageHolder._width = curStagewidth;
//var xScaleT:Tween = new Tween(image_mc1, "_rotation", Elastic.easeOut, 0, 10, 4, true);

var xScaleT0:Tween = new Tween(image_mc1, "_x", Bounce.easeOut, 0, -2*v, 3, true);
var xScaleT1:Tween = new Tween(image_mc1, "_y", Bounce.easeOut, 0, -6*v, 4, true);
var xScaleT4:Tween = new Tween(image_mc2, "_width", Bounce.easeOut, imageHolder._width*1.1, imageHolder._width*1.15, 3, true);
var xScaleT5:Tween = new Tween(image_mc2, "_height", Bounce.easeOut, imageHolder._height*1.1, imageHolder._height*1.15, 3, true);
var xScaleT2:Tween = new Tween(image_mc2, "_x", Bounce.easeOut, 0, 0-2*v, 2, true);
var xScaleT3:Tween = new Tween(image_mc2, "_y", Bounce.easeOut, 0, 0-8*v, 2, true);
xScaleT0.onMotionFinished = function() {
this.yoyo();
};
xScaleT1.onMotionFinished = function() {
this.yoyo();
};
xScaleT2.onMotionFinished = function() {
this.yoyo();
};
xScaleT3.onMotionFinished = function() {
this.yoyo();
};
xScaleT4.onMotionFinished = function() {
this.yoyo();
};
xScaleT5.onMotionFinished = function() {
this.yoyo();
};


image_mc1._y = 0;
image_mc1._x = 0;
image_mc2._y = 0;
image_mc2._x = 0;

//create a listner that checks to see if the browser window is resized
sizeListener = new Object();
sizeListener.onResize = function() {
// change movieclip properties when the window is resized.
var curStageheight = Stage.height;
var curStagewidth = Stage.width;
imageHolder._height = curStageheight;
imageHolder._width = curStagewidth;


//create a random velocity for x and y direction
};
Stage.addListener(sizeListener);

Finding The Width Of A JPEG Loaded Into A Movie Clip
I will be loading a page of bio information. Next to the person's photo (photos will vary in width) I want to put a column of buttons about 20 pixels to the right of the photo. So after I load the photo into an empty movie clip, I'm trying to get the width of the photo in order to figure out the x position of the buttons next to it. Here is what I have:

myImage = "images/" + _level0.images[link];
loadMovie(myImage,image_mc);
// JPEG loads okay into image_mc //

trace("image_mc._x = " + image_mc._x);
// I get "Image_mc._x = 393" as expected //

trace("myImage._width = " + myImage._width);
// I get "image_mc._width = undefined" //

trace("image_mc._width = " + image_mc._width);
// I get "image_mc._width = 0" //

How do I find the width of the loaded JPEG?

Getting The Width Height Property Of Loaded MC?
I’m playing around with properties and variables right now and I’m trying to figure out how to load in an SWF file into a MC (I got that one), and then get the property of the width and height of the file that has been loaded in. right now I can only get the property of the MC that the SWF file loads into. I need the PROP of the SWF.

That’s it for now. In the future I want to be able to get the property and then have that property effect the surrounding elements. However I’ll get to that after I have this one down.

Thanks
cooper

Finding Width Of Externally Loaded Image, Making It A Variable And Doing Stuff...
Hello,

All help very very much appreciated!... This is very much a learning curve for me...

I'm doing a fade in fade out slideshow, it all works fine. The images are loaded externally. Basically I'd like to know if there's a way of getting what the width of each externally loaded image is, assigning it to a variable and then that dictates where the title of the image is displayed... but I'm not that clued up!

Each image has a different title - I've done a "createTextField" which changes every time you press a button. The text in this image is right aligned (with the image), but some of the images are different sizes, so it would be really nice to automatically get the width of the externally loaded image, rather than find out what it is manually and then work out where x position of the type needs to be (so their aligned properly)... plus in the long term it would be quicker to update with new images...

errr, I hope I'm making sense and I'm not sure I do! Again, all help would be appreciated.

I think its something along the lines of....

(Stage width - width of text field) - (Stage width - width of externally loaded image) = x position of text field if its to right align with image.

Many Thanks,

here's a sample of some of the actionscript...



_root.createTextField("mytext",105,125,428,300,100 );
mytext.text = "TITLE OF IMAGE 1";

mytext.embedFonts = true;

myTextFormat = new TextFormat();
myTextFormat.font = "Arial";
myTextFormat.size = 11;
myTextFormat.color = 0x000000;
myTextFormat.align = "right";

mytext.setTextFormat(myTextFormat);


textInstance.setTextFormat(myTextFormat);


container_mc.loadMovie("images/1.jpg");


function fadeIn() {
var MyfadeIn = new Tween(container_mc,"_alpha",Strong.easeOut,0,100,3 6,false);
}

function fadeOut() {
var MyfadeOut = new Tween (container_mc,"_alpha",Strong.easeOut,100,5,20,fal se);
}


buttons_mc1.one_mc.onRelease = function() {
new Tween (container_mc,"_alpha",Strong.easeOut,100,0,20,fal se).onMotionFinished = function(){
container_mc.loadMovie("images/1.jpg");

fadeIn();
}
mytext.text = "TITLE OF IMAGE 1";
mytext.setTextFormat(myTextFormat);
}

Finding Stage Size Of Swf Loaded Into A Movie
Hi,

Does anyone know how I can find the original stage size of an SWF that has been loaded into a parent clip via MovieClipLoader? In the child clip, there are a number of elements that extend beyond its stage, so when I check the _width and _height properties, then they include the stage overlap.

I tried using mc.getBounds(), but it doesn't seem to give me what I'm after.

thanks
Marcus.

Finding Stage Size Of Swf Loaded Into A Movie
Hi,

Does anyone know how I can find the original stage size of an SWF that has been loaded into a parent clip via MovieClipLoader? In the child clip, there are a number of elements that extend beyond its stage, so when I check the _width and _height properties, then they include the stage overlap.

I tried using mc.getBounds(), but it doesn't seem to give me what I'm after.

thanks
Marcus.

Dynamic Movies Stage Width/Height?
Is there a way to find a dynamically loaded movies Stage width. I don't want to know what the actual movie width is (cause you can have Movie Clips that are off stage that will increase the size of the clips)?

-Ryan

Dynamic Movies Stage Width/Height?
Is there a way to find a dynamically loaded movies Stage width. I don't want to know what the actual movie width is (cause you can have Movie Clips that are off stage that will increase the size of the clips)?

-Ryan

Set Property For Loaded Movies...
Hi all,

I have a loaded movie on level 2 that I want to set property for, such as visibility. What path do I write to set that movie's property?

Thanks!!!


Beno

Stage Only / Or Masking Loaded Movies?
hello,

first: sorry about my english ;-)

second: my situation

i`m creating an best practice part in my homepage and my
main movie (include navigation etc.) should load other swf
files into an target (blank target), to position and scale
it correctly i use setproperty...(in MOST cases it worked
fine).

third: my problems :-)

i got two movies which uses movieclips outside the stage and
i dont want to show them in my final product!! so does someone
got an idea to fix this problem? or is it possible to mask
external loaded swf files to stage only?

hope to get some answers or maybe some ideas to solve my probs

Resize Scroller To Stage.width, Need To Get The Stage.width Value
hey all. I'm battling this problem and have finally caved for help. I can't seem to get the mask_mc._width to return the acurate value. at a fixed stage size the scroller seems to work fine, but changing the mask_mc.width to a variable set to Stage.width doesn't. I know the Stage.width property is read only, but does that mean i cant get a value from it. Anything i am missing? suggestions? I suppose this would be similar to resizing a scrollbar to full height. Thanks ahead of time.

mask_mc._width = Stage.width;
stageListener = new Object();

stageListener.onResize = function() {
mask_mc._width = Stage.width;
}

Stage.addListener(stageListener);

var scrollSpeed = 0.2;
var maxScrollOffset = 16;


function setContentTarget(scrollPercent) {
if (scrollPercent<0) scrollPercent=0;
if (scrollPercent>1) scrollPercent=1;
this.targetY = this.mask_mc._x - scrollPercent * ((this.contentMC._width+20)-this.mask_mc._width);this.onEnterFrame = setContentY;
}

function setContentY() {
this.contentMC._x += (this.targetY-this.contentMC._x) * scrollSpeed;
if (Math.abs(this.targetY-this.contentMC._x) < 1){
delete this.onEnterFrame;
}
}

this.onMouseMove = function() {
if (this.mask_mc.hitTest(_root._xmouse, _root._ymouse, false)) setContentTarget((this.mask_mc._xmouse-maxScrollOffset)/(this.mask_mc._width-2*maxScrollOffset));
}

Finding The Width Of Textfields
I'm working on a program that takes words in a sentence and puts each word into a new textfield. I need to make textfields that size according to the width of the words created in them. How can I do that?

Finding The Movie Height And Width
Is there any way to find the height and width of an .swf with actionscript? I want to move an MC to the center of the movie.

Finding The Width Of A Dynamic Text Box
finding the width of a dynamic text box

Hi

What is the best way to get the width of dynamic text box? I'm able to get the _length of the var, then multiply it times a made up number based on the mean width of each character to fabricate the width of the dynamic text box. Then I center the text inside a box (who's width is dependent on the dynamic text box).

Anyways, if there is a better way or more accurate way to get the width of teh dynamic text box I'd appreciate it if somebody would let me in on the secret.


Files:
http://dyometry.com/selig/flash/menu_04.html
http://dyometry.com/selig/flash/loadme.txt
http://dyometry.com/selig/flash/menu_04.swf

Sorry about this mess of code i have here.

Code:
// creates the buttons based on the vars passed to it from code;
//total = 5
amount = parseFloat(total);
count = 1;
while(amount>0){
//makes the movie clips(mc's);
newname = "mc"+count;
duplicateMovieClip("mc0", newname, count);
// gives the mc's txt thier content;
lastcount = count - 1;
set("mc"+lastcount+".txt", eval("mc"+lastcount+"_txt"));//potential problem with eval();
// gives the last mc in the loop it's content;
if(amount==1){
set("mc"+count+".txt", eval("mc"+count+"_txt"));//potential problem with eval();
}
// resizes mcX.bt according to amount of characters of mcX.txt
charmultiplier = parseFloat(_root.charmultiplier);
// trace(typeof(charmultiplier));
margin = parseFloat(_root.margin);
mc_length = eval("mc"+lastcount+".txt.length");
new_width = mc_length*charmultiplier+margin;
// this sets the width of the hit state button;
setProperty("mc"+lastcount+".bt", _width, new_width);
if(amount==0){
setProperty("mc"+count+".bt", _width, new_width);
}
// this sets the width of the drop down animation (triggered by button);
setProperty("mc"+lastcount+".drop_down", _width, new_width);
if(amount==0){
setProperty("mc"+count+".drop_down", _width, new_width);
}
// this centers the txt within the button area;
setProperty("mc"+lastcount+".txt", _x, ((new_width-(new_width-margin))/2));
if(amount == 0){
setProperty("mc"+count+".txt", _x, ((new_width-(new_width-margin))/2));
}
// tracethis = (((new_width-(new_width-margin))/2));
// trace(new_width+" minus "+(new_width-margin)+" divided by 2 equals "+tracethis);

// figures out where to positions the mc's;
newpos = (new_width + eval("mc"+lastcount+"._x"));
// trace(eval("mc"+lastcount+"._x"));
// trace(new_width);
// trace(typeof(newpos));
// positions the buttons;
//if(amount>1){
setProperty("mc"+count, _x, newpos);
//}
count++;
amount--;
}
stop();
thanks in advance!

Finding The Width Of A Single Character
Ok, so I have a whole bunch of characters flying all over the place, similar to

http://actionscript.org/showMovie.php?id=427

That. Something to note though is that not all letters are created equal. At least, not in terms of width. Rather than just spacing all letters 8 pixels, apart, I want spacing to be based on the width fo the letter.

Now, brute force way to do it would be to make a big table with the fixed-pixel width of every letter I'm using, and pray I never have to change the font. Ah, if wishes were horses...

Anyway, the _width property of my spawned letters only gives me the width of the movie clip, and the initial textbox. It doesn't resize to fit the letter. Can perhaps this be done, forcing the letterbox to snap-resize to it's contents? Perhaps an empty letterbox (of width 0) could be created, and it expands to the size of it's dynamic texts? I'll do futher experimentation of course, but ideas (or solutions!) are very welcome.

Thanks!

Finding The Height And Width Of HtmlText
Is there any way of finding the actual height and width of the text produced by TextField.htmlText ?
(I'm looking for something like textWidth and textHeight, but these don't seem to give me the desired
results when using htmlText)

Thanks,
Rick

Problem With Finding Width Of An Image
Code:

package {

import flash.display.*;
import flash.text.*;
import caurina.transitions.*;
import flash.events.*;
import flash.net.*;

public class GalleryDisplay extends Sprite {

public var gContainer:Sprite = new Sprite ();
public var thumbHolder:Sprite = new Sprite ();
public var thumbBack:Shape = new Shape ();
private var thumbLoader:Loader;
private var xml:XML;
private var gallery:String;
private var num:int = 0;
public var pos:int;

public function GalleryDisplay (src:XML,gal:String) {

xml = src;

thumbHolder.graphics.beginFill (0xCCCCCC);
thumbHolder.graphics.endFill ();

gallery = gal;
thumbHolder = null;
thumbHolder = new Sprite ();
gContainer.addChild (thumbHolder);
loadThumb ();
addChild(gContainer);
}

private function loadThumb () : void {
thumbLoader = new Loader ();
thumbLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, thumbLoadProg);
thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoadComp);
var thumbURL:URLRequest = new URLRequest ('images/' + gallery + '/' + xml.item.(@folder == gallery).image[num].@img);
thumbLoader.load(thumbURL);
}

private function thumbLoadProg (evt:ProgressEvent) : void {
}

private function thumbLoadComp (evt:Event) : void {

var thumb:Thumb = new Thumb (thumbLoader,
xml.item.(@folder == gallery).image[num].@img,
gallery,
num);
thumb.name = 'thumb' + num;

// thumb.x values can be read here
// thumb.x = num * (thumb.width + 20);
// var widthArray:Array = new Array ();
// widthArray.push (thumb.width);

thumbHolder.addChild (thumb);
thumbHolder.cacheAsBitmap = true;

num++

if (num < xml.item.(@folder == gallery).image.length ()) {
loadThumb ();
} else {
num = 0;
}
}
}
}
This GalleryDisplay.as loads in xml images and displays them. What I need to do is display them horizontally, so the second image starts to the immediate right of the first image. Normally I would use


Code:
thumb.x = num * (thumb.width + 20);
but the problem is that only works if the images are all the same size. But for this project they aren't. I have tried to add the thumb.width's to an Array but the array just adds the values to [0] not increasing and therefore becomes useless.


Code:
var widthArray:Array = new Array ();
widthArray.push (thumb.width);
Can anyone please help me solve this. Thanks

p.s. I cant seem to find the option to post ActionScript code only [code] code, how do you do it?

Unhappy Adjusting Columns And Rows On Stage Resize, According To Stage.width.
Hey fello flashers,

what i'm trying to achieve can be seen here, at the FWA's website.

When you resize the browser window the thumbnails rows and columns adjust accordingly to fit.I've managed to attach the thumbnails correct when my enableButtons() function is called but i'm unsure how to approach resizing.

if anyone has encounted this problem before or can help, then pls do i'm a little confounded on this one.

thanks
cam

Stage.align = "TL";

var numberOfGalleries:Number = 20;
var thumbMarginX:Number = 163;
var thumbMarginY:Number = 109;

function init():Void {
enableButtons(numberOfGalleries);
resizeStage();
}

function enableButtons(numberOfGalleries:Number):Void {
currentRow = 0;
currentColumn = 0;
for (i=0; i<numberOfGalleries; i++) {
tracker = i;
thumbsDisplayer = this.createEmptyMovieClip("thumbsDisplayer_mc", this.getNextHighestDepth());
currentThumbnail = thumbsDisplayer.attachMovie("thumbnail holder", "thumbnail"+(tracker+1), thumbsDisplayer.getNextHighestDepth());

currentThumbnail._x = currentColumn*thumbMarginX;
currentThumbnail._y = currentRow*thumbMarginY;
currentColumn++;
if (currentThumbnail._x>(Stage.width-(currentThumbnail._width + thumbMarginX))) {
currentRow++;
currentColumn = 0;
}
}
}

function resizeStage() {
var myListener:Object = new Object();
myListener.onResize = function(e:Object):Void {
//
}
Stage.addListener(myListener);
}


init();

Finding The Width/height Of A Movie Clip
When importing bitmaps/jpgs/pngs etc is there a way to find the height and width of that image before it loads. in the preloading stage?

basically i want my preloader to be a black box the size of the image to be loaded?

Cheers

Finding Height And Width Of Dynamically Created MCs
So, I'm using createEmptyMovieClip() to generate a number of MCs, then loading external .jpgs into each MC. Having done this, however, I need to be able to manipulate the created MCs according to the heights and/or widths of the images they now contain. But the height and width of the MCs seems always to register as 0.

Can someone enlighten me as to how I can dynamically determine the heights/widths of my dynamically loaded .jpgs?

Finding Previous Menuitem Width In Loop
Hi guys,

I'm trying to make a horizontal menu in AS3.
Now I want all menuitems to have a specific width according to the textwidth in the menuitem.
So to place all the item next to eachother the items need to know the width and x position of the previous items.

The way I thought to do this was to


Code:

for (var i:uint = 0; i < mMenu.item.length(); i++) {
var button = new menuItem();
button.id = "button" + i;
button.prevId = "button" + (i-1);
addChild (button);
var mTitle:String = mMenu.item[i].title.text();
button.mTxt.text = mTitle;
button.y = parseInt(hHeight);
button.mBg.width = Math.round(button.mTxt.textWidth + 30);
if (i > 0) {
button.x = (button.prevId.width + button.prevId.x);
} else {
button.x = 0;
}
button.mTxt.x = (button.mBg.width / 2) - (button.mTxt.textWidth / 2) - 5;
}



But this doesn't work. For some reason as3 rejects the 1st iteration because of thr name button-1. AS2 did accept this.

Anybody can help me?

Grtz,

David

Stage.width && Stage.height Doesn't Work Anymore?
How do you get Stage.width and Stage.height in ActionScript 3.0

2.0 this works like a charm. I guess they may have moved this inside a deeper class or something.

thanks in advance.

Stage.width And Stage.height Not Matching Document Settings?
Ok, so I have no idea why this would be happening and its driving me nuts. I have my Flash movie size set to 960x650. However, when I trace stage.width and stage.height, I get:

950.05x630

Why in the world would this be happening? It's screwing up all the work I'm trying to put into positioning elements relative to the stage size. Thanks for any help!

Problem Finding The Exact Width Of A Text Field
I have a field where i am calling some text from a database.
Because each time the text has a different width i generate the width of the text field counting the characters of the text. The problem is that each character width is different so i am not able to find the exact width.

textfield.text = _root.databasetext.length*19

But it s not official. Because each character has a different width.


Any ideas ?

Finding New Width And Height After Applying Blur Filter.
How???


Code:
trace(drawer.width);
drawer.filters[cloudBlurFilter];
trace(drawer.width);
var temp:BitmapData=new BitmapData(drawer.width, drawer.height, true,0 );
temp.draw(drawer, idMatrix);
trace(temp.width);
temp.applyFilter(temp,new Rectangle(0,0, temp.width, temp.height), origin, cloudBlurFilter);
trace(temp.width);
Trace output still the same both before and after applying filter for either Sprite or BitmapData. The width and height still remains the same.
64
64
103.80000000000001
103.80000000000001
103
103
36.75
36.75
36
36
82.7
82.7

Help!

Stage.height And Stage.width Erratic Values?
Hey folks,

I was wondering if it happens in all Flash everywhere, or just in mine:

When I trace Stage.height and Stage.width, I always get erratic values:

Stage.height gets me always 4 pixels less than real
Stage.height gets me always 104 pixels less than real

This, way if my stage has 760 x 400, it will return values 756 x 296.

Anybody knows why?

Thanks!

Stage.width, Stage.height, Add.Listeners Problem
Hi
i found the way yesterday to ensure my mc stays full screen. now i want to animate the same mc if i can in reaction to a button click.

not sure how this next step goes. do i need another addlistener to the background mc that im tweening ?

kindly check the .fla. to see what i mean.
its very rough cut but hopefully you can get the gist of it.
when the text button is clicked, the bg reverts to the top left of the screen.

thanks
-dj

MX2004 -- Stage.height And Stage.width Different From Mac To Windows
I have a really strange problem that is ruining my movie. I have set the size of the stage to 450px by 400px in the properties dialog. In my actionscript, I've got all kinds of things that rely on Stage.width. So, I developed everything in MX2004 on Mac, and everything worked swimmingly. So, I opened up the exact same file in MX2004 and everything is placed wrong on the stage. So when I did a trace of Stage.width, I got 940px, and a trace of Stage.height gave me a figure of 763 pixels. If I do the same traces on the Mac, I get what I expect, 450px for width and 400px for height. Does anybody have any ideas as to what might cause this kind of discrepancy?

Thanks,
John

Preloader.width = Stage.width
Hi everyone,

I'm working on a full flash site, and i'd like to make a loaderbar scaling over the stage.width. So it starts at 0% and when everything is loaded, i want the bar to be as wide as the user's window.

Works fine, but as you can see on my example, it never really touches the right edge of the screen..

http://www.dpbc.be/fullflash


I used this code to place the bar:

Code:

loader._x = 0;
loader._y = Stage.height / 2;
loader._width = 0;


and this is my preloading code:

Code:

bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;

this.loader._width = getPercent * Stage.width;

if (bytes_loaded == bytes_total) {
   this.gotoAndPlay(3);
}

(on frame 2 i have a gotoAndPlay(1)).

Thank you VERY much!
d?sh'

Loader Width Property
Hey, hows it going? I have a question that is driving me nuts.. I have xml loading in a 4 swfs, I call them out via the index number this thing [0] lol. Anyway I load my swfs via a loader called "mLoader" and then I add it to the stage via addChild....However at this point I have some trouble. I can tween "mLoader" no problem... but what I'm trying to do is tween it to the center of the stage dynamically. How can I do this if every swf I load in may be different sizes?

to simplify - If I have a loader called "mLoader" and its loads in a swf that I would like to address the width property(to properly center the image on the stage)... how do I do so? Is there an instance for each swf loaded in dynamically... or can I create me own instances?

Thank you

Stage.width & Stage.height Problems
Why is it when I use this script attached to an empty movie clip the box seems to always be short on the height side? The width is fine. See attached FLV.

frame.fla.zip

Thanks in advance for any feedback.


Code:
onClipEvent (load) {
this._x = 0;
this._y = 0;
this.moveTo(0, 0);
this.lineStyle(1, 0x000000, 100);
this.beginFill(0x000000, 0);
this.lineTo(Stage.width-1, 0);
this.lineTo(Stage.width-1, Stage.height-1);
this.lineTo(0, Stage.height-1);
this.lineTo(0, 0);
this.endFill();
}

Stage.height & Stage.width Return 0
First, hey there, cool forum. This is my first post...anyways...

I'm having what, I want to assume, is a common issue and there's something I'm missing here...I have a flash movie that works fine (that is Stage.height and Stage.width) return their proper values when the actual SWF is played in the flash player, however, when I put the movie into an HTML page and set it's height and width to 100%, Stage.width and Stage.height are 0 and my neato script breaks.

I realize I'm scaling the movie, but it seems to me that Stage.width and Stage.height should work regardless...and the fact it gives me 0 is even more odd, as though it's not working at all.

Dynamicly Created Movieclip/sprite And .width Property
I have a question on WHEN you can read the width of a dynamically created sprite.

I have a gallery package - the gallery.as file creates a thumbContainer (MovieClip) and adds each thumbnail (sprite) in a for loop, iterating through an array.

Within the for loop, i try to trace the width of the thumbContainer, but it always returns 0. What gives? I need the final width to make some calculations for the scrolling of the thumbnails to work.

I can get the final width using certain methods, such as returning the width on MOUSE_MOVE. I was able to get the width using the eventListener Event.ADDED, but that stopped working when loading images off my server instead of locally (wtf is that about?).

Can anyone give some clarification on dynamically created containers and their properties (specifically reading their width property) ?

Finding An Objects Stage
hello,
i'm trying get the stages "Document Class" (_root) of an object in its controller class with the following code:

ActionScript Code:
var targetClass:Class = Object(this.stage).constructor;

but it gives me #1023

what can i do to this?

thanks for any help

Finding Out If Any Movieclip Are On The Stage?
Hello everyone,

I would appreciate it if someone can help me out with this. I would like to write a function that would return the names of the all the movieclips that are on the stage. I have written an function but it only return true or false whereas I would like the function to return the name(s).










Attach Code

function checkClip()
{
var j:Boolean;
j = typeof(movieclip) ? true : false;
trace(j);
}

checkClip();

Finding Centre Of Stage
My code:

_root.centerXPoint = Stage.width/2;
trace("center of stage x" + _root.centerXPoint);

My problem:

When I test my movie using ctrl + return, I first get the right value, but when I hit ctrl + enter again, I get a different one. Can someone tell me why?

Finding Centre Of Stage
My code:

_root.centerXPoint = Stage.width/2;
trace("center of stage x" + _root.centerXPoint);

My problem:

When I test my movie using ctrl + return, I first get the right value, but when I hit ctrl + enter again, I get a different one. Can someone tell me why?

Finding Stage Scale
or something close to it.

I was called in to work on a project for a company, as they project has got5ten beyond the skill level of their in house developers.

This thing is Huge, and in its final stages. They want users to be able to resize the flash player window (projector) using the windows (and mac) controls outside of the move (like the maximize button) They want the scale mode to be "showall" and they want everything to scale up and dwon *except for an videos that play.

So I need a way to detect the flash player window size or the % scale of the stage as it scales with the resize.

Help!!!

Problems Finding The Stage
Hello, I am just starting out in Flash so I am sure this is something simple but it is driving me crazy. I am trying my first FMA following the tutorial in the help of Flash 8 but using my own pictures and measurements, etc. Everything goes fine until I drag the slideshow (creating the third symbol) onto the stage after creating a new symbol. The stage disappears under the slideshow which makes sense, but selecting the border layer doesn’t show the stage. When I create a new symbol for the blue area, the stage (white part) is huge, even when the properties show the proper size. I have redone everything up to this point four times, thinking I screwed something up, but the same thing happens every time. Also, I have googled but cannot find tutorials for FMA’s, any links will be a help. Thanks in advance.

Stage.width, Stage.height
Does anyone know why the stage dimensions are coming out wrong. I have a movie set at 800 x 600. I do trace(Stage.width);
trace(Stage.height); and get 796 and 596. What's going on here? I have seen at least one other post with the same issue, but there were no responses.

Best regards...
Lance

Stage Width Vs. Stage Height
hello.
still looking how to maintain max. stage width and height. i have managed to achieve it on the width, but for some reason have been unable to do it for the height. that is, i have managed to make a line go from one side to the other (almost) but cant figure out how to do it on the vertical.
zbot is the horiz line at the botton
ztop for the one above
the problem, is for xleft (the vertical lineon the left)
i have included what i think to be the nearest code yet, and a fla.

any help, thanks a lot.




Code:
Stage.align = "LT";
Stage.scaleMode = "noScale";
bg._width = System.capabilities.screenResolutionX-20;
bg._height = System.capabilities.screenResolutionY-70;
bg.onResize = function() {
this._x = (Stage.width-this._width)/2;
this._y = (Stage.height-this._height)/2;
};
Stage.addListener(bg);
zbot._x = 62;
zbot.onResize = function() {
this._width = Stage.width;
};
Stage.addListener(zbot);
////
xleft._x = 270;
xleft.onResize = function() {
this._height = Stage.height;
};
Stage.addListener(zbot);
////
ztop._x = 62;
ztop.onResize = function() {
this._width = Stage.width;
};
Stage.addListener(ztop);
// get the content clip to stay fixed horizontally centred
content.onResize = function() {
this._x = (Stage.width-this._width)/2;
};
Stage.addListener(content);
// manually invoke the onResize events for the clips to start things off
bg.onResize();
zbot.onResize();
ztop.onResize();
xleft.onResize();
content.onResize();

Copyright © 2005-08 www.BigResource.com, All rights reserved