[COLOR=“Red”]Please Refer to Post #9 for complete details of the the code[/COLOR]
Hi,
I was working on a little code in which I am inserting a few movieclips within a scroll pane and then user is able to drag stuff(a movieclip) from stage to the movieclips inside the srollpane.
SWF uploaded:http://megaswf.com/serve/87256/
Now, when I am accessing a movieclip inside the scrollpane like this
testMC.addChild(F22omc);
It works perfectly fine. But when I try to do it using getchild by name like this
testMC.addChild(getChildByName("F22omc"));
I am getting the ole “TypeError: Error #2007: Parameter child must be non-null.”
Any help will be really appreciated. Here is the full code
// * import necessary classes
import flash.display.MovieClip;
import fl.containers.ScrollPane;
import fl.events.ScrollEvent;
// * createScrollPane
/*function createScrollPane(target:Object, xPos:Number, yPos:Number, wSize:Number, hSize:Number):void
{*/
var sp:ScrollPane = new ScrollPane();
sp.move(10,40);
sp.setSize(400,150);
sp.source = panedata;
sp.scrollDrag = true;
addChild(sp);
//}
// * add ScrollPane to a movieclip linkage name “ScrollableMC” from library, then place it on stage
//createScrollPane(testMC, 10, 10, 400, 150);
//////////////////////////////////////////////
var startX:Number;
var startY:Number;
var testMC:MovieClip;
testMC = sp.content as MovieClip;
trace(testMC.myBorder2.x);
var fname:String;
var F22o:F22 = new F22();
F22o.name='F22o';
var F22omc:F22 = new F22();
F22omc.name='F22omc';
addChild(F22o);
F22o.x=myBorder2a.x;
F22o.y=myBorder2a.y;
F22o.addEventListener(MouseEvent.MOUSE_DOWN, startdrag);
F22o.addEventListener(MouseEvent.MOUSE_UP, stopdrag);
function startdrag(event:MouseEvent):void {
event.target.startDrag(true);
trace(event.currentTarget.name);
//event.target.parent.addChild(event.target);
startX = event.target.x;
startY = event.target.y;
//trace(startX);
//trace(startY);
}
function stopdrag(event:MouseEvent):void {
event.target.stopDrag();
fname=event.currentTarget.name;
if(F22o.hitTestObject(testMC.myBorder2))
{
trace('myBorder'+i+'a');
removeChild(F22o);
testMC.addChild(F22mc);
//F22mc.x=testMC.getChildByName('myBorder'+i+'a').x;
//F22mc.y=testMC.getChildByName('myBorder'+i+'a').y;
trace("hit here");
trace(fname);
}
}