How do I access the root element of an MXML document if I can't set an id?

To access the component specified by the root node from within an mxml file, you can use this keyword. Any code inside an mxml runs in the context of this object - you can as well omit the keyword if you don't have any local variable by the same name this. Width = myWidth; this.

Height = myHeight For your second question: Let's say your mxml file's name is MyCanvas. Mxml You'd add this to another component using ns:MyCanvas tag. You can set an id there and access it using that ns:MyCanvas id="myCanvas Inside script: myCanvas.

Width = whatever.

To access the component specified by the root node from within an mxml file, you can use this keyword. Any code inside an mxml runs in the context of this object - you can as well omit the keyword if you don't have any local variable by the same name. This.

Width = myWidth; this. Height = myHeight; For your second question: Let's say your mxml file's name is MyCanvas.mxml. You'd add this to another component using tag.

You can set an id there and access it using that. Inside script: myCanvas. Width = whatever.

This makes sense, however whenever I call myCanvas. Width, I'm getting "Error: Access of undefined property myCanvas" -- looks like I'm missing an import somewhere, but I'm importing com.foo.bar.view. * -- do I need to somehow import main.

Mxml from my ActionScript code to get at the instance of myCanvas? – Aaron B. Russell Aug 31 '10 at 14:48 @Aaron make sure that you're spelling it correct.

Also, remember that myCanvas. Width is only for accessing it from another file. Within the same file, use this.

Width or just width. – Amarghosh Aug 31 '10 at 15:06 Ah, looks like I needed to add a var myCanvas : MyCanvas; line. Thanks everyone for your help.

:) – Aaron B. Russell Aug 31 '10 at 15:55.

You don't need to if you make myWidth and myHeight bindable, and set width="{myWidth}" and height="{myHeight}" in the Canvas declaration. Any changes to myWidth and myHeight would then update the size of the Canvas.

Hmm, that's an interesting idea. I never thought of just binding it to something I could get a handle on... – Aaron B. Russell Aug 30 '10 at 22:53 Okay, that definitely seems to do what I'm after, though I have one catch: I need to get at those variables from outside this MXML file -- this is a Cairngorm 2.

X project, so I need my Command classes to be able to edit the height/width of this canvas, but I'm seeing this compiler warning: Warning: var 'canvasWidth' will be scoped to the default namespace: ProjectName: internal. It will not be visible outside of this package. Var canvasWidth = model.

SomethingWidth; – Aaron B. Russell Aug 30 '10 at 23:02 What if you create a public setter for myWidth and myHeight? – rlovtang Aug 31 '10 at 6:22 You should probably not need to create your own variables and bind to them, but rather use Amarghosh's solution.

But if you need to bind the width and hight to some deeper nested variables or a function, then binding is a good option. – rlovtang Aug 31 '10 at 7:24.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions