[Xerte] AS3 Code doesn't work in Xerte?

Deborah Delin admin at strivney.com
Fri Jul 1 13:11:07 BST 2011


Hi,

I may be duplicating one part of this plea - my previous post didn't seem to
come through.

I have to use Actionscript 3 for a particular exercise and the code, which
works fine in the SWF, doesn't work in Xerte.  Is there a problem with Xerte
and AS3?

This is the code:

1) To attach sound to a movie clip:

/var snd:grey_rod= new grey_rod();

//speaker_grey.addEventListener (MouseEvent.CLICK, soundbutton_Handler);

//function soundbutton_Handler (e:MouseEvent):void {
//snd.play();

2) for a drag and drop game:

var objectoriginalX:Number;
var objectoriginalY:Number;

triangle_mc.buttonMode = true;
triangle_mc.addEventListener(MouseEvent.MOUSE_DOWN,pickupObject);
triangle_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);

function pickupObject(event:MouseEvent):void {
  event.target.startDrag(true);
  event.target.parent.addChild(event.target);
  objectoriginalX = event.target.x;
  objectoriginalY = event.target.y;
    response_txt.text = " "
}
function dropObject(event:MouseEvent):void {
  event.target.stopDrag();
  var matchingTargetName:String = "target" + event.target.name;
  var matchingTarget:DisplayObject = getChildByName(matchingTargetName);
  if (event.target.dropTarget != null && event.target.dropTarget.parent ==
matchingTarget){
   event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
   event.target.removeEventListener(MouseEvent.MOUSE_UP, dropObject);
   event.target.buttonMode = false;
   event.target.x = matchingTarget.x;
   event.target.y = matchingTarget.y;
    response_txt.text = "You did it!"
  }else {
   event.target.x = objectoriginalX;
   event.target.y = objectoriginalY;
    response_txt.text = "Try again"

  }
}

Please help - why might Xerte not like this code?

Deborah
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20110701/ec43856c/attachment.html>


More information about the Xerte mailing list