// invokeASCallback // call action script func void CMenuFxObj::invokeASCallback( const char* funcName, const gameswf::as_value* arguments, int argumentCount ) { //***Implement at actionscript 2.0f //onClipEvent(load) //{ // this.sayHi = function(a:String, b:String) // { // fscommand(a,b); // } //} //***Call implement at code C++ //CMenuFxObj panel = getStateObjFx().findObj("panelList"); //gameswf::as_value params[2]; //params[0] = gameswf::as_value("CStateJoinGame"); //params[1] = gameswf::as_value("update"); //panel.invokeASCallback("sayHi",params, 2); if (m_character && m_character->is(gameswf::AS_SPRITE)) { gameswf::sprite_instance* si = (gameswf::sprite_instance*)m_character; // Keep m_as_environment alive during any method calls! gameswf::gc_ptr<gameswf::as_object> this_ptr(m_character); // In ActionScript 2.0, event method names are CASE SENSITIVE. // In ActionScript 1.0, event method names are CASE INSENSITIVE. gameswf::call_method( si->get_environment(), m_character, funcName, arguments, argumentCount ); } }
void as_netstream::advance(float delta_time) { stream_event ev; while(m_event.pop(&ev)) { // printf("pop status: %s %s\n", ev.level.c_str(), ev.code.c_str()); // keep this alive during execution! gc_ptr<as_object> this_ptr(this); as_value function; if (get_member("onStatus", &function)) { gc_ptr<as_object> infoObject = new as_object(get_player()); infoObject->set_member("level", s_netstream_event_level[ev.level].c_str()); infoObject->set_member("code", s_netstream_event_code[ev.code].c_str()); as_environment env(get_player()); env.push(infoObject.get_ptr()); call_method(function, &env, this, 1, env.get_top_index()); } if (ev.code == playStop || ev.code == playStreamNotFound) { get_root()->remove_listener(this); } } }
void destroy() // nothrow { //Self destruction, so move the allocator this_allocator a_copy(::boost::move(static_cast<this_allocator&>(*this))); BOOST_ASSERT(a_copy == *this); this_pointer this_ptr(this_pointer_traits::pointer_to(*this)); //Do it now! scoped_ptr< this_type, scoped_ptr_dealloc_functor<this_allocator> > deleter_ptr(this_ptr, a_copy); typedef typename this_allocator::value_type value_type; ipcdetail::to_raw_pointer(this_ptr)->~value_type(); }
void destroy() // nothrow { //Self destruction, so get a copy of the allocator //(in the future we could move it) this_allocator a_copy(*this); BOOST_ASSERT(a_copy == *this); this_pointer this_ptr (this); //Do it now! scoped_ptr< this_type, scoped_ptr_dealloc_functor<this_allocator> > deleter(this_ptr, a_copy); typedef typename this_allocator::value_type value_type; ipcdetail::to_raw_pointer(this_ptr)->~value_type(); }
bool x3ds_instance::on_event(const event_id& id) // Dispatch event handler(s), if any. { // Keep m_as_environment alive during any method calls! gc_ptr<as_object> this_ptr(this); bool called = false; // Check for member function. const tu_stringi& method_name = id.get_function_name().to_tu_stringi(); if (method_name.length() > 0) { as_value method; if (get_member(method_name, &method)) { as_environment env(get_player()); gameswf::call_method(method, &env, this, 0, env.get_top_index()); called = true; } } return called; }