Posted by: 3wme Mar 14 2007, 09:00 PM
Another
newbie question I'm afraid. Up until now, I've been creating and adding
all the objects within the createScene function, before world.render()
is called. Now, I cant seem to add an object after the initial scene is
created. Is this not possible? I'm just trying to add a line here eg:
CODE
var path_line= new Line3D(new Vector(-300,0,0),new Vector(300,300,-300) );
var skin:Skin = new SimpleLineSkin( 5, 0xff00ff, 100 );
path_line.setSkin( skin );
bg.addChild(path_line);
It does seem to add the object as I can trace out its position and bounding box, but it doesn't actually show up on the stage?
Or is there a method for changing the vectors making up the line after the initial creation?
I simply want to draw a line between 2 objects? Anyone had similar problems?
Posted by: zeusprod Mar 14 2007, 09:28 PM
QUOTE(3wme @ Mar 14 2007, 04:00 PM)

I cant seem to add an object after the initial scene is created. Is this not possible? I'm just trying to add a line here eg:
It
s definitely possible to add an object after the scene is rendered. I
do it all the time. My first guess is that bg is not in scope or
otherwise is incorrect.
Use the instanceof and/or typeof
operators (or a trace statement) to make sure bg is what you think it
is before invoking addChild on it.
Of course, there could be other problems. And I wouldn't try to set a skin on a line. See if it works with the default skin.
Regards,
Bruce
Posted by: 3wme Mar 14 2007, 10:46 PM
You're
first guess was spot on, the scope of the bg object wasn't accessible.
I got into the bad habit of just re-using the same init() function
without really examining it. Thanks.
You dont happen to know if
it possible to alter a line after its created, do you? It must be
possible with a combination of translation,scaling and rotations, but
that seems a bit longwinded, just to change one of the two vectors
making up the line.
I did consider simply removing one line and
creating/adding another, but I'm not confident the old one is being
removed properly. I've tried: path_line.destroy();
path_line.dispose();
bg.removeChild(path_line)
but I can still access path_line.getId() and path_line.getBounds() afterwards, which looks like the lines still there?
Thanks for your help
Posted by: zeusprod Mar 15 2007, 04:16 AM
QUOTE(3wme @ Mar 14 2007, 05:46 PM)

You're first guess was spot on, the scope of the bg object wasn't accessible.
You dont happen to know if it possible to alter a line after its created, do you?
I
did consider simply removing one line and creating/adding another, but
I'm not confident the old one is being removed properly. I've tried:
path_line.destroy();
path_line.dispose();
bg.removeChild(path_line)
but I can still access path_line.getId() and path_line.getBounds() afterwards, which looks like the lines still there?
Like bad breath, 95% of the problems in ActionScript are solved by using the right scope. ;-)
I've done almost nothing with lines and don't see an obvious way (in 1.1) to alter the vertices after creation.
I'm not confident I'm destroying objects correctly either, but destroy() should do it according to the docs.
Let us know what you discover!