explanation of current implementation: bool sprite_instance::get_frame_number(const as_value& frame_spec, size_t& frameno) const { //GNASH_REPORT_FUNCTION;
as_environment* env = const_cast<as_environment*>(&m_as_environment); //becuase the "toString()" is expected to be invoked... as_value str(frame_spec.to_std_string(env)); //alway convert the std_string to a number first. If this conversion succeeded, //then we try to fetch the number-th frame. We do this even the result number //is not a valid frame index. double num = str.to_number(env); if ( isnan(num) || isinf(num)) { return m_def->get_labeled_frame(frame_spec.to_string(env), &frameno); } // TODO: are we sure we shouldn't check for frames labeled with negative //numbers ? // I think so, we are not going to look for a number-labeled frame. if ( num < 1 ) return false; // all frame numbers >= 0 are valid, but a valid frame number may still // reference a non-exist frame(eg. frameno > total_frames). frameno = num - 1; return true; } the drawback of the current implementation is that even if get_frame_number() returns "true", we still need to check the "frameno" here and there, as it might be still not in the valid range.(eg, frameno > total_frames). And it's also not good to clamp the "frameno" to [0, total_frames-1] inside this function... _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit