At 4/21/12 12:12 PM, Computoguy wrote:
At 4/21/12 11:59 AM, maringtr wrote:
Are you sure you're using the correct instance name and that the given instance has the property/method you're trying to access?
import flash.events.MouseEvent;
var cankeybedragged:Boolean = false;
keyininventory.visible = false;
****MovieClip(root).keyforinventory.addEventListener(MouseEv ent.CLICK, checkifkeydraggable);****
function checkifkeydraggable(event:MouseEvent):void{
if(cankeybedragged){
keyininventory.addEventListener(MouseEvent.MOUSE_DOWN, dragkey);
keyininventory.addEventListener(MouseEvent.MOUSE_UP, nodragkey);
}
}
function dragkey(event:MouseEvent):void{
keyforinventory.startDrag();
}
function nodragkey(event:MouseEvent):void{
keyforinventory.stopDrag();
}
I am 100% sure that it's the right instance name.
So what happens when you run your code, and what do you want to happen? Also, you can work out what's going on based on a few traces.
function checkifkeydraggable(event:MouseEvent):void{
trace(keycanbedragged);
if(cankeybedragged){
keyininventory.addEventListener(MouseEvent.MOUSE_DOWN, dragkey);
keyininventory.addEventListener(MouseEvent.MOUSE_UP, nodragkey);
};
};
should return 'false', based on what you've posted, but if something's going wrong elsewhere then nothing will happen.