?
Solved

Can't get children to show up on stage.

Posted on 2010-01-11
11
Medium Priority
?
341 Views
Last Modified: 2013-11-11
I'm trying to add a sprite to the stage but for some reason I can't get it to show up.  I'm setting a width for the child, but when I try tracing that width it comes up as 0.  I'm assuming that's why it's not showing up.

Any theories?
var myList:Sprite = new Sprite();
myList.x = 24;
myList.y = 33;
myList.width = 600;
myList.height = 210;
		
this.stage.addChild(myList);
trace(myList.width);

Open in new window

0
Comment
Question by:Ameronix
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
11 Comments
 
LVL 37

Expert Comment

by:CyanBlue
ID: 26285598
There is nothing in that sprite and you cannot set the width to 600 when there is nothing in it...  That's why it is not showing up...

CyanBlue
0
 
LVL 1

Author Comment

by:Ameronix
ID: 26285677
I add stuff to the sprite later.  But still can't get it to have a width, no matter when I check it.  After adding all the pieces to sprite I checked Debug > List Objects in the flash player and it doesn't list any objects.  Here's the rest of that code.


var myList:Sprite = new Sprite();
myList.x = 24;
myList.y = 33;
myList.width = 600;
myList.height = 210;

this.stage.addChild(myList);
trace(myList.width);

var panel:ScrollPanel = new ScrollPanel();
myList.addChild(panel);

var msg_container:Sprite = new Sprite();

var theMsg:TextField = new TextField();
theMsg.text = "something";
theMsg.autoSize = "left";
theMsg.y = msg_container.height;
msg_container.addChild(theMsg);

panel.addChild(msg_container);
panel.setSize(600, 210);

Open in new window

0
 
LVL 1

Author Comment

by:Ameronix
ID: 26285678
I add stuff to the sprite later.  But still can't get it to have a width, no matter when I check it.  After adding all the pieces to sprite I checked Debug > List Objects in the flash player and it doesn't list any objects.  Here's the rest of that code.


var myList:Sprite = new Sprite();
myList.x = 24;
myList.y = 33;
myList.width = 600;
myList.height = 210;

this.stage.addChild(myList);
trace(myList.width);

var panel:ScrollPanel = new ScrollPanel();
myList.addChild(panel);

var msg_container:Sprite = new Sprite();

var theMsg:TextField = new TextField();
theMsg.text = "something";
theMsg.autoSize = "left";
theMsg.y = msg_container.height;
msg_container.addChild(theMsg);

panel.addChild(msg_container);
panel.setSize(600, 210);

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:Ameronix
ID: 26285756
I've found that if I don't set the height and width I actually get things to show up.  How do I set a height and width for a sprite?  I need the children, which will be chat messages, to have a set width.
0
 
LVL 5

Expert Comment

by:NiklasMoller
ID: 26286189
dont bother messing with the width/height of the parent container. the children dont adapt to that anyway.
if you set a width or height to a sprite like you do, you will cause the object to be distorted visually. probably not what you want.

if you want to set a width to the textfields you can do that however:
theMsg.width = 500;
theMsg.height = 300;

also you can set the text to wrap, so you see multiple lines
theMsg.wordWrap = true;
0
 
LVL 1

Author Comment

by:Ameronix
ID: 26286331
is there a way to set the height on the message to auto or something based on the message length?  
0
 
LVL 5

Accepted Solution

by:
NiklasMoller earned 2000 total points
ID: 26286560
sure you can you need to add some lines of code that set certain properties of the textfield.
see attached code, should get you where you want to go
var theMsg:TextField = new TextField();

theMsg.width = 500;
theMsg.height = 5;//set the height too small, so that it has to expand to fit text
//these 3 lines of settings will create the "expand to fit" effect that you wanted:
theMsg.autoSize = "left";
theMsg.wordWrap = true;
theMsg.multiline = true;

theMsg.border = true;//just to see the text field edges more clearly

theMsg.text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum."

addChild( theMsg );

Open in new window

0
 
LVL 1

Author Comment

by:Ameronix
ID: 26286838
Is there a way to force a minimum height with that?
0
 
LVL 5

Expert Comment

by:NiklasMoller
ID: 26287439
yes. just set the first height to whatever you want the minimum to be.
for example:

theMsg.height = 100;
will make the textfield only expand beyound that if it needs to.
0
 
LVL 5

Expert Comment

by:NiklasMoller
ID: 26295756
did it work?
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 26296484
Sounds like that should...  ;)

CyanBlue
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question