Difference between revisions of "Actionscript 3 Snippets"

From Wikicliki
Jump to: navigation, search
(removeChild)
Line 21: Line 21:
 
== removeChild ==
 
== removeChild ==
  
removeChild(video_holder);
+
<pre> removeChild(video_holder);</pre>
  
 
will return this error:
 
will return this error:
  
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
+
<pre> ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
 
at flash.display::DisplayObjectContainer/removeChild()
 
at flash.display::DisplayObjectContainer/removeChild()
 
at tanah_1920x1080_v5b_fla::gedung_vid_17/closeVideo1()[tanah_1920x1080_v5b_fla.gedung_vid_17::frame1:50]
 
at tanah_1920x1080_v5b_fla::gedung_vid_17/closeVideo1()[tanah_1920x1080_v5b_fla.gedung_vid_17::frame1:50]
at tanah_1920x1080_v5b_fla::MainTimeline/menu_press()[tanah_1920x1080_v5b_fla.MainTimeline::frame1:184]
+
at tanah_1920x1080_v5b_fla::MainTimeline/menu_press()[tanah_1920x1080_v5b_fla.MainTimeline::frame1:184]</pre>
  
  
 
BUT
 
BUT
  
if( container.contains( video_holder) ){ container.removeChild( video_holder ); }
+
<pre> if( container.contains( video_holder) ){ container.removeChild( video_holder ); }</pre>
  
 
WILL WORK!!
 
WILL WORK!!

Revision as of 00:13, 27 July 2012

Useful AS3 Snippets

Fullscreen

import flash.display.*;

stage.displayState = StageDisplayState.FULL_SCREEN;
stage.scaleMode = StageScaleMode.SHOW_ALL; // SHOW_ALL or NO_SCALE
stage.align = StageAlign.TOP_LEFT;

fscommand("fullscreen", "true");
fscommand("allowscale", "true");

No Cursor

import flash.ui.Mouse;
// Mouse.show(); - optional line
Mouse.hide();


removeChild

	removeChild(video_holder);

will return this error:

	ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
	at flash.display::DisplayObjectContainer/removeChild()
	at tanah_1920x1080_v5b_fla::gedung_vid_17/closeVideo1()[tanah_1920x1080_v5b_fla.gedung_vid_17::frame1:50]
	at tanah_1920x1080_v5b_fla::MainTimeline/menu_press()[tanah_1920x1080_v5b_fla.MainTimeline::frame1:184]


BUT

	if( container.contains( video_holder) ){ container.removeChild( video_holder ); }

WILL WORK!!