PDA

View Full Version : addChild from an AS file


affirmallchance
01-08-2008, 08:47 AM
Hello,

I have a fla file with a MovieClip named Billy (class: Billy, Base Class: flash.display.MovieClip) linked to Billy.as.

I am trying to get .as file to add an instance of the MovieClip Billy onto the stage with no luck. If anybody can help me here, Thank You! I am not getting any error messages, just a blank swf file...

this is the code in Billy.as. The fla file is blank.

package
{
import flash.display.MovieClip;
import Billy;

public class Billy extends MovieClip
{
private var _billy:Billy;

public function Billy()
{
_billy = new Billy();
addChild(_billy);
}
}
}

panel
01-08-2008, 10:19 AM
I am not sure what exactyl you want to achieve here and why you are try to cteare object instance inside class witch defines object


Usually thins works sth like this:

Here is our custom class Fruit

package
{
import flash.display.MovieClip;
import Billy;

public class Friut extends MovieClip
{

public function Friut()
{
var myPicture:MyPicture = new MyPicture();//let's say my Pistuce is
//our custom class witch already contain some 'visible graphics'
addChild(myPicture) //here we are adding mypiscure instance to fruit display list (it won't be visible untill fruit instance is added to display list...)
}
}
}



Fruit object creation

var fruit:Fruit = new Fruit();
addChild(Fruit) // here we are adding fruit instance to stage display list

affirmallchance
01-08-2008, 05:41 PM
figured it out.
I had to declare the .as file as the document class in properties in my .fla file.

It's very confusing the different ways to link these files...between the actionscripting and actual settings, very easy to forget a step...