Display library content from .as file

Hi, using actionscript 3.0 and I have no problem grabbing an object from my library and putting it on stage, works great. However when I try the same technique using an .as file the addChild() dosent work. Its probably something small but can’t seem to figure it out. If someone knows the answer or could show me another related discussion I would be very thankful.

Jeff

You have to link your library symbol with the .as file. So if you have a symol in library say mc you link it with some class say McClass.as.(You can link by right clicking the symbol in library and selecting linkage)

After that you have to create an object of that class on the maintimeline var _mc:McClass = new McClass();

add then add that to the stage as addChild(_mc);

Ps if you are still not clear let me know I will supply you more code and info

[QUOTE=adnan794;2325216]Ps if you are still not clear let me know I will supply you more code and info[/QUOTE]

Thanks for the quick response I’m going to try to get it working on my own again with that little bit of info.

Thanks
Jeff

After a few more hours of trial and error I’m still creating the same problem. Here is my code

--------------- . fla ------------------

import LoadImage;

var myTest : LoadImage = new LoadImage();

btn.addEventListener(MouseEvent.CLICK, myTestFunction);

function myTestFunction(event : MouseEvent):void {
myTest.init();
}

------------ LoadImage.AS -------------------

package {

import flash.events.*;
import flash.display.*;
import testBut;

public class LoadImage extends MovieClip {

	public var viewTestBut:testBut;

	public function LoadImage() {
		init();
	}
	public function init():void {
		viewTestBut = new testBut();
		addChild(viewTestBut);
		viewTestBut.x = 100;
		viewTestBut.y = 100;

	}
}

}


in the linkage properties dialog I have the class set to testBut.

I do not get any errors, but nothing shows up on the stage If someone has some insight it would be appreciated.

Thanks
Jeff

Your code is fine for the class but in the main fla your doing a big mistake your are creating LoadImage object i.e myTest in this case but you are never adding that object to the stage. so you have to use addChild to add your myTest object.

here is the code.

var myTest : LoadImage = new LoadImage();
addChild(myTest);

Alrighty sounds good, thanks for the response.

Jeff