ActionScript 1/2 :: Trace "myTextBox.textWidth" And It Returns 154?
Dec 11, 2009
I've got a dynamic text field. It has text in it. I can trace "myTextBox.textWidth" and it returns 154. I'm publishing to Flash 6, but if I change to Flash 9, the trace returns 139. Any ideas why this is behaving inconsistently when changing publish settings? Any ideas how I can make this NOT happen?
I have a dynamic text box on my stage that is 400px wide. The text box is being populated with flashvars data from an HTML file and auto-sizes (myTextBox.autoSize = TextFieldAutoSize.LEFT) so it will display all content by expanding when the text spans over 400px. But when I trace 'myTextBox.width', it always returns '400'and when I trace 'myTextBox.textWidth' it always returns '0'no matter how much text I push into it through the flashvars.
This is because the trace is only tracing the previewed swf in Flash which has no ties whatsoever to the HTML file and flashvars.Therefore, when previwing the swf, my text box is always empty.The only way to see the content populating the text box is when actually launching the browser with the swf embedded in it.Because of this I cannot seem to be get flash to 'do things' based on the new width/textWidth values of my text box after it has been populated with the flashvars data from the HTML file.How can I get flash to detect the new width/textWidth of my text box after it has been populated by the flashvars data from the HTML file?
I have a simple code that seems to be giving strange results.
var startPoint:Point = new Point(x, y); // a point var r:Number = path[i].row + (-Math.floor((length * 2 + 2) / 2)); // just some math trace(r); // the math checks out and gives a 3 var tey = startPoint.y + r; //this gives a really strange return....
When I trace the next highest depth at the initial frame of my SWF it returns 9877. Is this due to the way I setup the objects and layers through authoring? The reason I ask is that this is somehow interfering with my attachMovie and unloadMovie (unloadMovie stops working after another 6 extra depths).
I'm trying to have a variable increment by a certain value every time certain radio buttons are clicked and then display that value in a dynamic text field. For ex:
var myNum:Number = 0; submit_btn.onRelease = function () { add values together[code]....
however, myTextBox always displays 0 from my original variable value. Why isnt it adding up the other values. So if I have both radio's selected it should show: 15.
I have a load file and a write to file method. We all know what they do. How ever load always returns true and write always returns false....Right there you know somethings wrong. Because The forums have an issue with me posting code...I posted it here: [URL] Based on this code what is the issue here? why is write always returning false and why is load always returning true? (even for files that do not exist). My understanding is that if flash cannot find the file it should write to it will create it and if it cant load said file, then that method should return false.
I'm trying to draw a background to a text field in AS3.I have a TextField with an embedded font and using autoSize = TextFieldAutoSize.LEFT. I assign the text to the TextField then call try to draw a roundedRect using the textWidth of the TextField. The text field width is always smaller than the actual text width.Is there another way to get the actual textwidth? I did a few quick google searched but I haven't found anything.
Code: var tfProgramName:TextField = TextUtil.createTextField(true,"Arial",20,true); tfProgramName.width = 100;
I have trouble detecting width of html formatted text,I am using textWidth property, but it looks like it gives width of default formatted text, not detecting html formating.
I create various movieClips with TextFields in them using the following function.
function AddLabel(Label,L) // create a MovieClip with a Text Field. { obj = this.createEmptyMovieClip("mc" + L,L); var tf = new TextFormat(); tf.font = "Arial"; tf.size = 12; [Code] ....
Lets say that I use the above function with the following statement: JimMC = AddLabel("JimVision",1); Then I try to assign a string to the above movieClip with some embedded html like so: JimMC.txt.htmlText = "This is my test < a href='[URL]'>link</ a>.";
When I try to run the above the results come out blank. When I list my variables I do see that my TextField is being assign the text and html code. What I also notice is that the textWidth and textHeight value become zero. Why my results are blank? Why do the textWidth and textHeight values become zero?
I'm having with a menu navigation system. I'm using Flash MX. I have created a menu system for the site I'm building ([URL]) where one of the buttons "Choose photographer" drops down a list of names. All the other buttons just jump to another page. The drop down is currently using tweens also the logo moves to the left as the dropdown appears and returns when the dropdown returns. All working fine apart from its a bit jerky.
It's I just wanted to get away from tweening and use action scripts instead, as I'm a newbie to all things Flash I trawled the net for tutorials and examples so that I could cobble together the exact same effect. I have managed to get the drop down work and return using the action script and it does seem smoother and works slightly better. But can I get the logo to move to the left and back in time with the drop down...no.
I'm trying to autosize my combobox, according to the textWidth of its biggest items. I've got the right textWidth without setting the textFormat, but by setting textFormat, with a bigger font size (like 30), the textWidth stays the same !
Code: var myFormat : TextFormat = new TextFormat("Trebuchet MS", 30, 0x0000FF);var myCbx myCbx= new ComboBox ; myCbx.x = 0;
I am having issues with a global array. I have an actionscript file called MyGlobal.as at the same level as my main FLA:
[Code]....
I am able to trace that first element while trace is called within the function... but if I try to trace that first element outside of the function it is "undefined". Do I need to return the array at the end of the function? I tried that but I cant seem to get it working correctly.
I've been playing with prototype a bit and I've noticed that either it isn't as static as it should be or that some functions are protected from altering, or that in some cases the prototype actually extends a function. For example, I was trying to modifiy the global trace function to output the current time of a trace action, something like this :
Code:trace("lulu"); // output 12:48:17.286 lulu I DID achieve something close to it, but it seems that I haven't actually modified the global trace function, but rather it's "_root" counterpart,
ive got a loaded xml list for an mp3 player. from playing track1, when i select track 2, it traces "track1" but then after a second click it traces "track2" and stays on that. the actually music for track2 does load on the first click though, but not the trace. anyone know why on the first click it would still trace the previous track? here is the code for that function...
why does the last trace not trace "32" like the second trace? I want to insert the variable "imgGal" onto the end of the mc "itemClip", how can I do this?
I have a flash file, and in it is a movieclipbutton. When you roll over the button, the button has to grow in size and change color. This animation is 10 frames long. When you roll out, the button goes back to it's original size and color, this animation is also 10 frames. But when you roll out of the button before the 10 frames of roll over animation are finished, the movie jumps to the rollout animation, which starts with the button in grown size; so you see a little jump in size. To fix this, I did the following for the onRollOut:
This however, doesn't work. When I put a trace(this._currentframe) inside, it returns 1. But this isn't right, it should return something between 10 and 20! I have the .fla file on the internet:[URL]
In Flash I load the text content of the title attribute into a text field, problem is -- the prints instead of operating as a carriage return (new line).
Again, no access to the XML so changing the TextField to htmlText and adding a <br/> tag wont work.
I have a Flash output file that uses both LoadVars and XMLConnectors. While LoadVars all work on all tested browsers, XMLConnector does something very strange and ONLY on Internet Explorer. When I try to use it, the listeners for the XMLConnector say send (using GET Method), status is correct (StatusChange), but the data that returns is crazy (outputs 11). I am suppose to get a full xml data stream, but all I get is 11. This happens in IE (PC) only. In Netscape on PC or Mac) it is fine, on Firefox (PC or Mac) is it fine, on Safari it is fine. SO, has anyone able to use the XMLConnector properly on IE (FP8)? The parameters for the problem are: Flash Player 8, Internet Explorer 6, PC.
I have few ActionScript skills. But I have built a multimedia career by stealing chunks of AS2 code and reworking them to suit my purpose. I have searched long and hard here for a solution to my current problem. I have found code here that seems to address it, but I cannot make it work. I simply have some textAreas that I wish to validate. The user may input text that could include extra spaces, returns, and odd capitalization. It would be easiest for me to simply strip out the capitals, spaces and returns. I found some simple code that changed the caps to lowercase:[code]
trying to cut text field to single letters and then do some animations on each letter. But, how do I know where to place (position) the letters? I tried using getCharBoundaries but once it reaches 3rd line, it keeps returning null values. Anybody knows why that happens
we are told to make a sort of calculator, You should be able to input a number, press a button and then it should do several mathematical steps and it would end up with the number 1
Here is what I've got so far:
ActionScript Code: var input:Number = 0; var summa:Number = 0; var output:Number = 0;
[Code].....
The script works fine when not entering a number in the text box, it calculates just as it should.
But if i enter any number, it shows up as NaN in the trace. I've asked my teacher and he doesn't see anything wrong with my code, and neither can i..
my code somehow manages to say that the result of 66.6 + 33.3 = 99.89999999999999
It might be possible in some alternate universe, but here on earth, I should get a result of 99.9... I'm really hoping one of you can explain to me why Flash returns that result, cause really, I'm at a loss here... this line:
ActionScript Code: var int_tmp:Number = int((nbUserArray[t]/nbUserTotal)*100*10)/10;
I made sure the values are the correct ones, plus the traces confirm that the first time, it equals 66.6 and the second time it equals 33.3. So really, I don't understand how it can return this... monster of a result .
When I use it with either byteArray or Vector as the input and either as the output, it returns the first few results correctly, then gives me either nonsense values or zeroes. The following shader takes values, returns the second number plus the third for the first value, a zero for the next, and the output coordinates for the last two numbers. The channel size is therefore 4. The length of data is 56 (divisible by 4).here is what I have in the evaluatePixel function:
and then, as you can see, fine again after 47. Changing the length of data to 80 is the same, only after 31, the values remain nonsense instead of eventually correcting themselves.That list is just a trace of input and output.
I'm triyng to get the browsers back-button to work with my flash site. The general principle is this:There is an index.html page containing an (not yet) hidden Iframe and the flash movie.The Iframe contains page A, which starts with JavaScript calling a BACK-function on the index-page.The BACK-function triggers an AS-function in the flash-movie that activates its own back-button, and then changes the URL of the Iframe to Page B. This causes a new History to be added to the browser.The flash movie now contains 5 frames (labeled in the middle of the stage) and two navigation buttons: back (Terug) and forward (Verder). Those buttons do exactly what you'd expect them to do (prevFrame and nextFrame).On a PC (IE) this seems to work pretty well. But on a mac nothing seems to work propperly.Here's the code I have on the first frame.