@@ -61,31 +61,27 @@ impl<'gc> EventObject<'gc> {
6161 /// It's just slightly faster and doesn't require an Activation.
6262 /// This is equivalent to
6363 /// classes.event.construct(activation, &[event_type, false, false])
64- pub fn bare_default_event < S > (
64+ pub fn bare_default_event (
6565 context : & mut UpdateContext < ' gc > ,
66- event_type : S ,
67- ) -> EventObject < ' gc >
68- where
69- S : Into < AvmString < ' gc > > ,
70- {
66+ event_type : & str ,
67+ ) -> EventObject < ' gc > {
7168 Self :: bare_event ( context, event_type, false , false )
7269 }
7370
7471 /// Create a bare Event instance while skipping the usual `construct()` pipeline.
7572 /// It's just slightly faster and doesn't require an Activation.
7673 /// Note that if you need an Event subclass, you need to construct it via .construct().
77- pub fn bare_event < S > (
74+ pub fn bare_event (
7875 context : & mut UpdateContext < ' gc > ,
79- event_type : S ,
76+ event_type : & str ,
8077 bubbles : bool ,
8178 cancelable : bool ,
82- ) -> EventObject < ' gc >
83- where
84- S : Into < AvmString < ' gc > > ,
85- {
79+ ) -> EventObject < ' gc > {
8680 let class = context. avm2 . classes ( ) . event ;
8781 let base = ScriptObjectData :: new ( class) ;
8882
83+ let event_type = AvmString :: new_utf8 ( context. gc ( ) , event_type) ;
84+
8985 let mut event = Event :: new ( event_type) ;
9086 event. set_bubbles ( bubbles) ;
9187 event. set_cancelable ( cancelable) ;
@@ -116,21 +112,18 @@ impl<'gc> EventObject<'gc> {
116112 . unwrap ( )
117113 }
118114
119- pub fn mouse_event < S > (
115+ pub fn mouse_event (
120116 activation : & mut Activation < ' _ , ' gc > ,
121- event_type : S ,
117+ event_type : & str ,
122118 target : DisplayObject < ' gc > ,
123119 related_object : Option < InteractiveObject < ' gc > > ,
124120 delta : i32 ,
125121 bubbles : bool ,
126122 button : MouseButton ,
127- ) -> EventObject < ' gc >
128- where
129- S : Into < AvmString < ' gc > > ,
130- {
123+ ) -> EventObject < ' gc > {
131124 let local = target. local_mouse_position ( activation. context ) ;
132125
133- let event_type: AvmString < ' gc > = event_type . into ( ) ;
126+ let event_type = AvmString :: new_utf8 ( activation . gc ( ) , event_type ) ;
134127
135128 let mouse_event_cls = activation. avm2 ( ) . classes ( ) . mouseevent ;
136129 Self :: from_class_and_args (
@@ -231,17 +224,14 @@ impl<'gc> EventObject<'gc> {
231224 )
232225 }
233226
234- pub fn text_event < S > (
227+ pub fn text_event (
235228 activation : & mut Activation < ' _ , ' gc > ,
236- event_type : S ,
229+ event_type : & str ,
237230 text : AvmString < ' gc > ,
238231 bubbles : bool ,
239232 cancelable : bool ,
240- ) -> EventObject < ' gc >
241- where
242- S : Into < AvmString < ' gc > > ,
243- {
244- let event_type: AvmString < ' gc > = event_type. into ( ) ;
233+ ) -> EventObject < ' gc > {
234+ let event_type = AvmString :: new_utf8 ( activation. gc ( ) , event_type) ;
245235
246236 let text_event_cls = activation. avm2 ( ) . classes ( ) . textevent ;
247237 Self :: from_class_and_args (
@@ -261,12 +251,17 @@ impl<'gc> EventObject<'gc> {
261251
262252 pub fn net_status_event (
263253 activation : & mut Activation < ' _ , ' gc > ,
264- info : Vec < ( impl Into < AvmString < ' gc > > , impl Into < AvmString < ' gc > > ) > ,
254+ info : Vec < ( & str , & str ) > ,
265255 ) -> EventObject < ' gc > {
256+ let event_type = AvmString :: new_utf8 ( activation. gc ( ) , "netStatus" ) ;
257+
266258 let info_object = ScriptObject :: new_object ( activation) ;
267259 for ( key, value) in info {
260+ let key = AvmString :: new_utf8 ( activation. gc ( ) , key) ;
261+ let value = AvmString :: new_utf8 ( activation. gc ( ) , value) ;
262+
268263 info_object
269- . set_string_property_local ( key. into ( ) , Value :: String ( value. into ( ) ) , activation)
264+ . set_string_property_local ( key, Value :: String ( value) , activation)
270265 . unwrap ( ) ;
271266 }
272267
@@ -275,7 +270,7 @@ impl<'gc> EventObject<'gc> {
275270 activation,
276271 net_status_cls,
277272 & [
278- "netStatus" . into ( ) ,
273+ event_type . into ( ) ,
279274 //bubbles
280275 false . into ( ) ,
281276 //cancelable
@@ -285,16 +280,13 @@ impl<'gc> EventObject<'gc> {
285280 )
286281 }
287282
288- pub fn progress_event < S > (
283+ pub fn progress_event (
289284 activation : & mut Activation < ' _ , ' gc > ,
290- event_type : S ,
285+ event_type : & str ,
291286 bytes_loaded : usize ,
292287 bytes_total : usize ,
293- ) -> EventObject < ' gc >
294- where
295- S : Into < AvmString < ' gc > > ,
296- {
297- let event_type: AvmString < ' gc > = event_type. into ( ) ;
288+ ) -> EventObject < ' gc > {
289+ let event_type = AvmString :: new_utf8 ( activation. gc ( ) , event_type) ;
298290
299291 let progress_event_cls = activation. avm2 ( ) . classes ( ) . progressevent ;
300292 Self :: from_class_and_args (
@@ -314,17 +306,14 @@ impl<'gc> EventObject<'gc> {
314306 )
315307 }
316308
317- pub fn focus_event < S > (
309+ pub fn focus_event (
318310 activation : & mut Activation < ' _ , ' gc > ,
319- event_type : S ,
311+ event_type : & str ,
320312 cancelable : bool ,
321313 related_object : Option < InteractiveObject < ' gc > > ,
322314 key_code : u32 ,
323- ) -> EventObject < ' gc >
324- where
325- S : Into < AvmString < ' gc > > ,
326- {
327- let event_type: AvmString < ' gc > = event_type. into ( ) ;
315+ ) -> EventObject < ' gc > {
316+ let event_type = AvmString :: new_utf8 ( activation. gc ( ) , event_type) ;
328317 let shift_key = activation. context . input . is_key_down ( KeyCode :: SHIFT ) ;
329318
330319 let focus_event_cls = activation. avm2 ( ) . classes ( ) . focusevent ;
@@ -350,12 +339,14 @@ impl<'gc> EventObject<'gc> {
350339 error_msg : AvmString < ' gc > ,
351340 error_code : u32 ,
352341 ) -> EventObject < ' gc > {
342+ let event_type = AvmString :: new_utf8 ( activation. gc ( ) , "ioError" ) ;
343+
353344 let io_error_event_cls = activation. avm2 ( ) . classes ( ) . ioerrorevent ;
354345 Self :: from_class_and_args (
355346 activation,
356347 io_error_event_cls,
357348 & [
358- "ioError" . into ( ) ,
349+ event_type . into ( ) ,
359350 false . into ( ) ,
360351 false . into ( ) ,
361352 error_msg. into ( ) ,
@@ -369,12 +360,14 @@ impl<'gc> EventObject<'gc> {
369360 status : u16 ,
370361 redirected : bool ,
371362 ) -> EventObject < ' gc > {
363+ let event_type = AvmString :: new_utf8 ( activation. gc ( ) , "httpStatus" ) ;
364+
372365 let http_status_event_cls = activation. avm2 ( ) . classes ( ) . httpstatusevent ;
373366 Self :: from_class_and_args (
374367 activation,
375368 http_status_event_cls,
376369 & [
377- "httpStatus" . into ( ) ,
370+ event_type . into ( ) ,
378371 false . into ( ) ,
379372 false . into ( ) ,
380373 status. into ( ) ,
0 commit comments