Hi,
This problem was discussed a couple days earlier as well but it was not resolved. and after wasting tow more days I still have no clue and banging my head in the wall. Alright, Here is the question first before I start describing in detail:
Why this code is working
if(event.target.hitTestObject(testMC.myBorder1))
{}
While this code is not working(it works only for myBorder1)
for(var i:int=1;i<=6;i++){
var abcd:String="myBorder"+i;
trace(abcd);
if(event.target.hitTestObject(testMC.getChildByName(abcd))){}}
I have tried many ways and figured this was working too
var check1:String="myBorder1"; if(event.target.hitTestObject(Object(sp.content).getChildByName(check1)))
But the corresponding code is not working for any other myBorder except myBorder1
for(var i:int=1;i<=6;i++){
var abcd:String="myBorder"+i; if(event.target.hitTestObject(Object(sp.content).getChildByName(abcd))){}}
======================================
Here are the details
The stage is empty
the code where I am creating the scrollpane
var sp:ScrollPane = new ScrollPane();
sp.move(10,10);
sp.setSize(400,150);
sp.source = panedata;
sp.scrollDrag = true;
addChild(sp);
Inside the scrollpane there is a panedata movieclip which has 6 instances of myBorder namely myBorder1,myBorder2…myBorder6
Then I create 2 instaces of a movieclip and add ONE of them to stage and add eventlisteners to it
var F22o:F22 = new F22();
var F22mc:F22 = new F22();
addChild(F22o);
F22o.x=451;
F22o.y=308;
F22o.addEventListener(MouseEvent.MOUSE_DOWN, startdrag);
F22o.addEventListener(MouseEvent.MOUSE_UP, stopdrag);
Start Drag Function
function startdrag(event:MouseEvent):void {
event.target.startDrag(true);
startX = event.target.x;
startY = event.target.y;
}
Here is the stopdrag function
function stopdrag(event:MouseEvent):void {
event.target.stopDrag();
testMC = sp.content as MovieClip;
[COLOR="Red"]**Code: Here is should check with all the myBorder's if there is any hit and place it on the specific myBorder or throw the mc back to irs original position(incase there was no hit)**[/COLOR]
}
Lemme know if there is any other info needed.
Here images *** well
Image of stage and library
Image of panedata(named myBorder1,myBorder2,myBorder3,myBorder4,myBorder5,myBorder6)
Here I uploaded the swf:
http://www.swfupload.com/view/142693.htm
http://megaswf.com/serve/87256/
In the uploaded, swf’s it only works for myBorder1
Here is the previous thread we discussed this matter in:
http://www.kirupa.com/forum/showthread.php?t=358374
Thanks in advance