Ejemplo n.º 1
0
void
NetConnection_as::connect(const std::string& uri)
{
    // Close any current connections. (why?) Because that's what happens.
    close();

    // TODO: check for other kind of invalidities here...
    if ( uri.empty() )
    {
        _isConnected = false;
        notifyStatus(CONNECT_FAILED);
        return;
    }

    URL url(uri, getRunResources(owner()).baseURL());

    if ((url.protocol() != "rtmp")
        && (url.protocol() != "rtmpt")
        && (url.protocol() != "rtmpts")
        && (url.protocol() != "https")
        && (url.protocol() != "http")) {

        IF_VERBOSE_ASCODING_ERRORS(
		 log_aserror("NetConnection.connect(%s): invalid connection "
			     "protocol", url);
				   );
Ejemplo n.º 2
0
/// Return true if the specified (first arg keycode) key is pressed.
as_value   
key_is_down(const fn_call& fn)
{

    if (fn.nargs < 1) {
        IF_VERBOSE_ASCODING_ERRORS(
            log_aserror(_("Key.isDown needs one argument (the key code)"));
        );
Ejemplo n.º 3
0
void
XMLNode_as::insertBefore(XMLNode_as* newnode, XMLNode_as* pos)
{
    assert(_object);

	// find iterator for positional parameter
    Children::iterator it = std::find(_children.begin(), _children.end(), pos);
    if (it == _children.end()) {
        IF_VERBOSE_ASCODING_ERRORS(
        log_aserror(_("XMLNode.insertBefore(): positional parameter "
                "is not a child of this node"));
        );
Ejemplo n.º 4
0
as_value
camera_activitylevel(const fn_call& fn)
{
    Camera_as* ptr = ensure<ThisIsNative<Camera_as> >(fn);

    if (!fn.nargs) {
        log_unimpl("Camera::activityLevel only has default value");
        return as_value(ptr->activityLevel());
    }

    IF_VERBOSE_ASCODING_ERRORS(
        log_aserror(_("Attempt to set activity property of Camera"));
    );
Ejemplo n.º 5
0
void
Sound_as::start(double secOff, int loops)
{
    if ( ! _soundHandler ) {
        log_error(_("No sound handler, nothing to start..."));
        return;
    }

#ifdef USE_SOUND
    if (externalSound) {
        if ( ! _mediaParser ) {
            log_error(_("No MediaParser initialized, can't start an external sound"));
            return;
        }

        if (isStreaming) {
            IF_VERBOSE_ASCODING_ERRORS(
            log_aserror(_("Sound.start() has no effect on a streaming Sound"));
            );
            return;
        }

        // Always seek as we might be called during or after some playing...
        {
            _startTime = secOff * 1000;
            boost::uint32_t seekms = boost::uint32_t(secOff * 1000);
            // TODO: boost::mutex::scoped_lock parserLock(_parserMutex);
            bool seeked = _mediaParser->seek(seekms); // well, we try...
            log_debug("Seeked MediaParser to %d, returned: %d", seekms, seeked);
        }


        // Save how many loops to do (not when streaming)
        if (loops > 0) {
            remainingLoops = loops;
        }

        startProbeTimer();

    } else {
Ejemplo n.º 6
0
/// Order of property lookup:
//
/// 1. Visible own properties.
/// 2. If DisplayObject, magic properties
/// 3. Visible own properties of all __proto__ objects (a DisplayObject
///    ends the chain).
/// 4. __resolve property of this object and all __proto__ objects (a Display
///    Object ends the chain). This should ignore visibility but doesn't.
bool
as_object::get_member(const ObjectURI& uri, as_value* val)
{
    assert(val);

    const int version = getSWFVersion(*this);

    PrototypeRecursor<IsVisible> pr(this, uri, IsVisible(version));
	
    Property* prop = pr.getProperty();
    if (!prop) {
        if (displayObject()) {
            DisplayObject* d = displayObject();
            if (getDisplayObjectProperty(*d, uri, *val)) return true;
        }
        while (pr()) {
            if ((prop = pr.getProperty())) break;
        }
    }

    // If the property isn't found or doesn't apply to any objects in the
    // inheritance chain, try the __resolve property.
    if (!prop) {

        PrototypeRecursor<Exists> pr(this, NSV::PROP_uuRESOLVE);

        as_value resolve;

        for (;;) {
            Property* res = pr.getProperty();
            if (res) {
                resolve = res->isGetterSetter() ? res->getCache() :
                                                  res->getValue(*this);
                if (version < 7) break;
                if (resolve.is_object()) break;
            }
            // Finished searching.
            if (!pr()) return false;
        }

        // If __resolve exists, call it with the name of the undefined
        // property.
        string_table& st = getStringTable(*this);
        const std::string& undefinedName = st.value(getName(uri));

        fn_call::Args args;
        args += undefinedName;

        // Invoke the __resolve property.
        *val = invoke(resolve, as_environment(getVM(*this)), this, args);

        return true;
    }

    try {
        *val = prop->getValue(*this);
        return true;
    }
    catch (const ActionTypeError& exc) {
        IF_VERBOSE_ASCODING_ERRORS(
            log_aserror(_("Caught exception: %s"), exc.what());
            );
        return false;
    }