0

I have the following property defined in my webcam as3 webcam class

public function get paused():Boolean
  {
  return (cam == null);
  }

public function set paused(p:Boolean):void
  {
  if(p){picture.draw(vid,flip);cam = null;}
  else cam = Camera.getCamera();
  vid.attachCamera(cam);
  }

Is it possible to access this from javascript? When I had it as a simple function it worked with:

ExternalInterface.addCallback("paused", paused);

But that wont compile after I changed it to properties.

"Error: Implicit coercion of a value of type Boolean to an unrelated type Function."

I'm an actionscript newbie so maybe there's something obvious I'm missing.

1 Answer 1

1

addCallback() only accepts a function, so you'll need to create meaningful functions that set and get the value without the use of the get and set keywords:

function getPaused():Boolean
{
    return paused;
}

function setPaused(value:Boolean):void
{
    paused = value;
}

ExternalInterface.addCallback("getPaused", getPaused);
ExternalInterface.addCallback("setPaused", setPaused);
Sign up to request clarification or add additional context in comments.

3 Comments

Yes I know it's a property but question is how can I access this property from javascript?
In javascript I was hoping to use something like "cam.paused=true". Is that not possible?
@poby You'll need to approach it as I've described in my latest edit - the ExternalInterface API only allows you to expose methods. This way you would do cam.setPaused(true); instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.