ActionScript 2.0 :: Find The Width Of A Text Box And Set A Variable With That Value?
Sep 3, 2003how do i find out the width of a text box and set a variable with that value?
View 1 Replieshow do i find out the width of a text box and set a variable with that value?
View 1 RepliesSuppose I have a (Spark) label. What is the best way to find the length of the text in it? I looked at the myLable.measureText("bla bla") method but it says: To measure text in Spark components, get the measurements of a spark.components.Label or spark.components.RichTextfter looking around I cannot find what this is refering to. I tried myLabel.measureWidth() but this does not return anything usefull (it frequently returns zero). Note: I am explicitly setting the width like this:<s:Lable width="{globalWidthVariable"} .../>If the text overflows I would like to increse the globalWidthVariable to the size of the text.
View 1 RepliesIs there a way to set the width of a text field equal to the width of the text in it?
View 1 RepliesI have fla file with 550px width . how to find out that document width in as3.
View 3 RepliesHow can I get the width of an externally loaded picture? I have this:
Code:
pic_mc.loadMovie("images/pic.jpg");
pic_mc.onEnterFrame = function() {
if (this._width) {
trace(this._width);
}
}
but it is not working. I've also tried calling this.getBytesLoaded/Total within the onEnterFrame and as ic_mc.getBytesLoaded alone, but it returns 4 and my picture is 40k. I've also tried pic_mc.onLoad, but it never advances. I think it is trying to get the width before it loads, but how do I prevent that?
How can I get the width of an externally loaded picture? I have this:
Code:
pic_mc.loadMovie("images/pic.jpg");
pic_mc.onEnterFrame = function() {
if (this._width) {
trace(this._width);
}}
But it is not working. I've also tried calling this.getBytesLoaded/Total within the onEnterFrame and as pic_mc.getBytesLoaded alone, but it returns 4 and my picture is 40k. I've also tried pic_mc.onLoad, but it never advances. I think it is trying to get the width before it loads, but how do I prevent that?
I am creating an upload and view function for my canvas website. The website lets you upload an image and view what it would look like on the wall. As the images are dynamically loaded I need to find the width of the image so that I can position it in the correct place.
The dynamic images are loaded into an empty movie clip called _root.canvas_preview
The code below works fine for finding the width of jpeg's when loaded into the canvas_preview movie but returns no value when the images are gif's, PNG etc. Does anyone know why this is or could suggest another way of finding the width of a dynamic movie clip. I am using Flash 8[code]...
I have a small issue in ActionScript 2.0. I want to know the stage width and height for external SWF file. I used the following code:
var loader:MovieClip = _root.createEmptyMovieClip('loader', 1);
var obj:Object = new Object();
var mcl:MovieClipLoader = new MovieClipLoader();
[code].......
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
Trying to do a scroll effect of some images I am loading in from an xml file. Problem is I need to limit the amount of scroll based on the width of the images - the number of images is controlled by the client and can vary. The problem is the actionscript does not seem to be able to detect the width of the combined images - heres the scroll code...
[Code]...
I have loaded in an external swf file and it works fine.
However, when I get the width dimensions of the movieclip that is housing the external swf file it gives me a '0' for the width.
I have a small issue in ActionScript 2.0. I want to know the stage width and height for external SWF file. I used the following code:
var loader:MovieClip = _root.createEmptyMovieClip('loader', 1);var obj:Object = new Object();var mcl:MovieClipLoader = new MovieClipLoader();mcl.loadClip("external.swf",loader);mcl.addListener(obj);
obj.onLoadInit = function(mc){ trace(mc._width); trace(mc._height);};
It's showing the whole animation's width and height but I want only stage width & height?
How can I find the width of an external jpg BEFORE it's been loaded into my movie? I can easily find the width of it AFTER loading by loading it into an empty movie clip and returning the width of this AFTER the jpg has loaded using the _width command. But what I want is to find the width BEFORE loading.I have tried "trace(1.jpg._width);" but this returns undefined, obviously as 1.jpg is not an object from my library, it's an external file. Any other ideas anyone?!
View 1 RepliesI am dynamically creating a 2 movie clips in a class. in one movie clip i am loading the image using MovieClipLoader. everything is working fine. but the onLoadComplete method is not working properly. i am using onLoadComplete method to find the width of the image but in onLoadComplete event the exact width is not calculating
[Code]...
Is there a function or property or better way to do what the following code do?
var width:int = 20
while (textField.defaultTextFormat.size > 1 && textField.width > width) {
textField.defaultTextFormat.size--
}
I am creating a nav in flex that pulls in buttons dynamically from xml. THe problem i am having is setting the button width to the text width. currently the buttons are all the same width and if the text is larger then it just cuts off. I've tried a few ways of doing this:Setting button width to 100%On creation of the button try to set the width of the button to the text programmatically. Something like evt.target.width = evt.target.textWidth;
View 1 RepliesI'm creating a mute/unmute button.I have it working correctly, except 1 part.I want to make my SoundChannels remove themselves when the SOUND_COMPLETE Event is fired.I'm storing my Sounds and SoundChannels in an array called "soundsPlayingArray".I want to do 1 of 2 things.Either:
1) Have my "unMuteAll" function check to see whether a song is "playing" before unmuting it.
2) Remove the Sound + SoundChannel from array (and make them null) when the SOUND_COMPLETE Event fires.
How can I figure out what the instance name of the SoundChannel that dispatched the SOUND_COMPLETE event is?[code]
My project goal is almost in sight.I've been learning how to use arrays properly.Have some variables that get sent from php to flash.
Code:
lv2.sendAndLoad("phppage.php",lv2,"POST");
lv2.onLoad = function(success){
[code].....
I have a php script that calls a result from the DB and gives it a variable. I then have a dynamic text box in flash that I want to say "goto read.php, find the variable and display the variable's contents in this text box"...
View 1 RepliesAs title states, I'm seeing an error in Safari's error console when trying to view a site I'm building with swfaddress.I've got the Flash side of things worked out (I have a textfield which updates with the parsed SWFAddress.setValue value in Flash), but it doesn't appear to be making its way to the browser (the address bar doesn't change), and I'm assuming it's because of this javascript error.Using the latest versions of both swfobject and swfaddress.
View 5 RepliesIs there a way to find all the public variable names in a class (given the instance of the class)?
View 2 Repliesi want to populate a horizontalList component from a xml file, the width value will be inside the xml file as well with all the data.actually i have this code:
<mx:Model id="epg" source="epg.xml" />
<mx:Component id="customRend">
<mx:Label text="{data.description}" width="{data.width}"/>
[code].....
I have a loader mc which scales to the width of the Stage. The loader mc has 3 nested mc's.A bg mc, progressBar mc, and loadBar mc.The loader and all nested mc's scale properly when I test it in the flash IDE but once I place the swf in a html page then the width is not accurate anymore. Another issue is since the loader stretches across the stage it needs to resize correctly in fullscreen mode. Click here here to view the example
// This is the code
// ----- [ Stage Align ] ----- //
Stage.scaleMode = "noScale";
[code].....
I have a number inside a variable. How do I trace the square root of the variable? for example: var xxyy = 57;
I want to trace the square root of 57;
A flash application in flash builder is currently throwing this error:
ReferenceError: Error #1065: Variable is not defined.
Not telling me which variable it is that's not defined, but note there are two spaces between 'variable' and 'is'. and it gives me some more feedback as to what lines of code are having trouble, but those lines are all within the actual flash/mxml packages and not any of the files in my own project.
I suspect it's related to my php data/services, but I don't see what variable would not be defined. I'm not very familiar with debugging, so I'm not sure how to determine with it where the problem is cropping up.
[Code]...
i wanto to load several images from xml but with a variable with and keeping the same space between them...
import flash.display.Loader;
import flash.net.URLLoader;
import flash.net.URLRequest;
[Code]....
I'd like to create a tab system where the tab text is populated by an external XML file, and the tab width is based on whatever the width of the text is.
I couldn't just use button symbols because when I resized them the text got squished
I have an mc that loads thumbnail images which are then displayed sequentially in a scroller. I have an array that contains the individual widths of the images and i can get them correlating to the specific images. However: when I try to change the hit size of the images (controlled by a hitSize mc which is just a red box) it won't change the ._width of the hitSize mc according to the variable.
This is what I can do:
Code:
hitSize._width = 100;
(which works)
This what I have:
Code:
hitwidth = _root.projectsB[this.menuNum]; //this is the individual width of the image being loaded
hitwidth = this.hitSize._width;
if I trace(hitwidth); I get the correct number, but the above code won't change the size of the mc.
I'm trying to reference a dynamic variable for PayPal but can't seem to find the right function for it. Here's an example:
Code:
_global.paypalObj = new Object();
paypalObj.item_name_1 = 'Book';
[code]....
What code can I use to shrink a piece of text in a dynamic text field to fit within a certain height and width.
View 1 Replies