ActionScript 3.0 :: Flex - Accessing TextWidth Of A Text Component?
Mar 25, 2010Code:
import mx.core.mx_internal;
use namespace mx_internal;
[code].....
Code:
import mx.core.mx_internal;
use namespace mx_internal;
[code].....
[code]...
But I get TypeError: Error #1009: Cannot access a property or method of a null object reference.
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.
View 3 RepliesI 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?
when I try to loop through the children of a List component that has buttons in it, I can't seem to access those children. I try
for(var btnNum:Number = 0; btnNum < myList.numChildren; btnNum++)
{
trace(myList.getChildAt(btnNum);[code]......
enter code hereI am loading an external swf into an component. It loads everything fine and I can see buttons working in the swf, I can add a movieclip to the but I can't then access that movieclip (or don't know how), and it keeps telling me numChildren = null when I try to trace it out. This is set up as a custom component like this:
<cynergy:imageZoom
id="zoomComponent"
borderStyle="solid"
source="{_data.map.@url}"
[code]....
how I would access the children in the loaded movieclip?I have tried
mycomponent.image.getChildAt(2) and it returns and error that the index is out of bounds.
In Flex Builder 3, I am trying to access the main applications view state from within a component.On initialize I show the Loginpage-component. When I click the login button I want to hide the loginpage and show my "controlpanel" page, which also is a component.I try with this, and also placing this function in the main application.[code]
View 1 RepliesI need to be able to call a method from a component located under the main application in Flex 4. Can anyone tell me please how to do this without using FlexGlobals please?[code]
View 3 RepliesI use a popup loaded from different MXML file:[code]The problem is I don't know how to pass text values from text inputs to the main component after buttonOK is clicked in the popup. I tried custom events, but it didn't work.url...
View 1 RepliesI created a somewhat custom Spark button by doing the File > New > MXML skin and basing it on spark.components.button. The problem is that I need to add an extra text field to the button component and dynamically change that text...but of course, the property isn't recognized on a Spark Button.
Is there a simple way to add this field to my custom button skin & its property so it can be addressed? If not, is there a simple way to take what I've done and just extend the Spark Button? I can't seem to find any examples that show how to do it without writing it all up in ActionScript.
I can't seem to find anything in Adobe's documentation about accessing the HTML of a web page through the HTML component in AIR.
I've looked into "domWindow", but that seems to only return Javascript.
Is there a property I can access that has the whole of the HTML in string format or do I need to use URLLoader or something like that?
I have an problem that i want to add textinput or Any Component to TextArea Component..
View 1 RepliesI'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;
[code]....
I have a component "child" which has a cancel button. Now this component is placed in a state called "newChildComp" I also have another component called "parent". In the parent component, i have a button that dispatches an event. Here is the event code:
[Code].....
so, basically,i am checking to see if the cancel button component in the Child component, while i am still in the parent Compoent, was clicked, if it was clicked, call the cancelButtonHandler. The problem is by the time the addNewChild handles the event, that cancel button was still null. My question is how do i solve this without using the itemCreationPolicy on the cancel button?
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?
How can I create a Create a Flex4 component to have the typewriter effect in text, like shown here.
View 1 RepliesHow do I get corner radius on my TextInput component in Flex 4.
<s:TextInput prompt="username" width="150" maxChars="100" id="txt_username" color="#000000"/>
unable to figure out how you can access a List Component Skins using ActionScript. What I'm trying to do is access the CellRenderedSelectedUp skin and:
1. Change it's color using ActionScript
2. Make it change its' color when that list item is clicked
So, let's say that the first item in the List is clicked. I want ActionScript to override the default coloring of the Selected Up skin (say change the color to yellow) and stay that color(yellow) until another list item is clicked on.
I have been stuck on this problem for a while, and wonder if anyone knows the answer. It is concerning accessing some properties of a custom component. I marked the problem with the keyword [PROBLEM] in the following snippets of code.
components/State1UI.mxml
--------------------------------
<?xml version="1.0" encoding="utf-8"?>
[code].....
I have a two components Test_Interface.mxml & teacher_fullscreen.mxml. I called teacher_fullscreen.mxml from Test_Interface.mxml by
[Code]...
Now I created an instance of Test_interface in my 2nd mxml by
Code: public var par:Test_Interface=new Test_Interface(); Actually, I wanted to disable a button in Test_interaface.mxml with id = "b1" from my 2nd mxml using the object created above. So I gave par.b1.enabled=false; It did not give any compile errors but during run time cannot access object or method of null reference sandbox error was returned for the statement par.b1.enabled=false. So how do I change the property of a button in one component from other.
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;
[code]...
I'm trying to use a custom Text component to show a series of comments. I got the original idea from:
[URL]
I've got the base case working but I am stuck with 2 problems I cant seem to figure out:
Since I am drawing around the text, the actual height of each bubble is greater than that of the Text field, as a result, the last bubble is always chopped off. I have tried explicitly overriding the height getter, and adding some padding, but I cant seem to get it right. You can see an example here: [URL] In my layout, I have 2 VBoxes (one nested inside the other). The first vbox shows a form where the user can enter a comment, and the second box has all the comments. In order to ensure that the scrollbars only show up on the second box, I set minHeight="0" on the nested VBox, but then for some reason, some comments' text is shifted to the right. You can see an example here (look at the first comment): [URL]
Rather than posting the code here, I've provided some links:
[URL]
I have custom components which must adjust their text content based on space constraints. For example a component adds labels until there is no space, and then the content of the last label becomes "(x more)"
I do not have access to size of child controls before adding them. When in updateDisplayList, I make changes to the layout of the component, but for labels, lblInstance.text property fires events, which lead to updateDisplayList being called again. I know that updateDisplayList may be called more than once, but if there is a way to modify text without triggering events, that'd be really useful. For example, setActualSize method in UIComponent allows this kind of modification. Anything similar for text controls? Or do you have best practices for laying out and managing text content, in the context of custom Flex components?
Is it possible (if so how) to find out what word the cursor/mouse is over when it is moving over a < mx:Text > component?So for example as the user moves the mouse along a sentence (inside text component), each word will highlight as they go (I know you can highlight while pressing the mouse button down - but that not how I wish to do it).
View 2 RepliesFlex front-end using AMF to Java back. Trying to read, in real-time, a file that is being written to. For example, a log. I'm using Java's RandomAccessFile class to read the "new" lines of the file and send them back to the UI as a byte array along with the byte offset to start reading from next time. Using an mx:List to display all lines of the text file. The problem I'm running into, is Flex, or Flash Player, running out of memory on mildly large files, >25MB. Is there any preferred method of displaying large amounts of text data in Flex that I'm missing? Or does Flex/Flash just handle this poorly and I'm basically screwed?
View 2 Replies(Actionscript 2 btw - and actually cs4, not that it really makes any difference?) I have a class that instantiates a movieclip from the library, e.g.:
Code:
debugbar:MovieClip = thing.AttachMovie("debugbar", "debugbar_mc", 999);
So attaching it to the where ever "thing" is - could be movie clip or level0 or whatever, doesn't matter as "debugbar" is a private variable of the class. Now the important part - debugbar in the library is a movieclip that contains some components - buttons and textInputs. The problem comes when trying to access these components.
I would have thought that this would work:
Code:
debugbar.input_txt.text = "hello";
In order to set the text of "input_txt", the instance name of a TextInput component on the timeline of the movie clip (put there in author time). However, this does not work. Infact, I cannot access any specific "component" properties - they come back undefined. I can however set and retrieve MovieClip properties for the "input_txt", such as _x. However there is one added strange thing with this too - setting _visible to false doesn't seem to work (however perhaps a component by default overrides this).
I also appear not to be able to add event handlers to the component - at least for the usual component events. I tried casting it to a component, such as:
Code:
var temp:TextInput = TextInput(debugbar.input_txt);
trace(temp);
which gave "temp" as null.
However if you trace the thing itself without casting to what it is, it gives the path to correctly. It almost seems like the components are somehow broken when trying to access them this way - or that they cannot be accessed this way?
The thing is, I was able to access all of this before, when the code to do it was placed on the timeline (frame 1, the only frame) of the debugbar itself, where the components were child instances. This meant I could just reference them directly too - so input_txt rather than debugbar.input_txt , although that is probably largely irrelevant. I need to have it in a class though, as I need to pass in certain objects that need to be accessed by the mc.
I'm having trouble accessing some components that reside inside of a movieclip that i'm displaying inside of a window component through the PopUpManager:
Code:
var my_MC = mx.managers.PopUpManager.createPopUp(_root, mx.containers.Window, { title:"movieClip", contentPath:"my_MC", closeButton:true });
how can i access any components that exist within the linked movie clip in my library? i have two labels that I want to update but can't figure out for the life of me how...
i've tried:
Code:
_root.my_MC.content.<label name>.text = "blah blah blah"
but no worky.
Is it possible in Flash 8 accessing from the linkage class, associated to a component, the graphics elements (for instance, a standard UI component, like a tree or a comboBox) that are on the movieclip this class refers to?
View 1 Replieshow do i get an ordered list using htmltext property of Text component? I tried using this: <ol><li>item</li><li>item</li></ol> but it rendered like an unordered list.
View 2 RepliesI have an application which displays employee information. If the user opening the detailed employee information page is not authorized to make changes I set the TextInput to disabled. Some users are reporting rendering issues with this. The TextInput's text value does not appear inside the box but is misaligned and is outside of the component. You can see the screenshow below of the disabled ID column where the numbers which are supposed to be in the TextInput box are far off to the right.
[Code]...