Archive for Tutorials

ActionScript 3.0 : Getting Data from Uncached Dynamic XML

Today’s tutorial is a bit complex, but it solved a lot of issues faced by flash developer in AS3.

We will be touching on various subjects such as: -

  1. Creating xml schema of your own.
  2. Easier way of doing xml data retrieval AS3 style.
  3. Loads the xml data into Listbox class.

NOTE : Listbox or List is a component in Flash so, it needs a separate import and special event Listener for that. You will get an error if you try to apply regular addEventListener like MouseEvent to it.

See the working sample below.


Read the rest of this entry »

ActionScript 3 : Where’s the _root?

Where is those _root.VariableName in ActionScript 3.0?

Good question, well _root is still there, but in ActionScript 3 is usually replaced with stage.variable_name, stage.objectname or MovieClip(”name”) commands.

A neat way to make a reference to _root is as follow. E.g. calling a _root variable called score and update it to 10.

1
2
//Accessing _root variables and object names in Actionscript 3.0
MovieClip("root").score += 10;

Handling Blue Screen of Death DIY (BSOD)

Today we are going to talk about the infamous Blue Screen of Death or known for short as BSOD. Microsoft named them as Stop errors designed to safeguard the system if the system encounters condition that compromises safe system operation. Ironically, I dont feel much of a pain when I was diagnosing BSOD for third party pcs however, I can get extremely desperate and frustrated if that BSOD happened to me.

 

Read the rest of this entry »

AS 3 : HitTest Checks on ActionScript 3.0

This is an example on how one should do a hittest in ActionScript 3.0.

This is an example of plain simple flash mode, where MovieClipA(red) and MovieClipB(blue) - Red being draggable and blue square listens to the a HitTest condition.

Some criteria needed for this task :-

  • Two movieclips - Red and Blue
  • EventListener assigned to Red to have it drag and drop able.
  • EventListener for EnterFrame for Blue to constantly checks for HitTest condition

For those new in EventListener in ActionScript 3.0 here’s a good tutorial for it.

See sample below :-


Download sample source code here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//Task to accomplish for HitTest
//1. Two movieclips - Red and Blue (Given instance name MovieClipRed and MovieClipBlue
//2. EventListener assigned to Red to have it drag and drop able.
//3. EventListener for EnterFrame for Blue to constantly checks for HitTest condition
 
 
//Task 1. is done in the stage itself.
//Task 2. Place an Eventlistener on Red have it drag nad drop able.
MovieClipRed.addEventListener(MouseEvent.MOUSE_DOWN,startDragme);
MovieClipRed.addEventListener(MouseEvent.MOUSE_UP,stopDragme);
 
// Below is the trigger function for EventListener Task 2.
function startDragme(event:Event):void{
	MovieClipRed.startDrag(true);
	StatusTxt.text = "Dragging Red";
}
 
function stopDragme(event:Event):void{
	MovieClipRed.stopDrag();
	StatusTxt.text = "Dropping Red";
}
 
MovieClipBlue.addEventListener(Event.ENTER_FRAME,checkHitTest);
 
function checkHitTest(event:Event){
		if(MovieClipRed.hitTestObject(MovieClipBlue))
		{
			StatusTxt.text = "Bingo - Blue has detected Red";
		}
}

AS3: Scripting OnClick GetURL? (Where’s GetURL)

Another big suprise for AS3 is the missing GetURL where we used to script it on buttons to open up url. However that was replaced in ActionScript 3.0. We use navigateToURL instead.

Just follow the example when scripting your button. Remember like in previous tutorials, you need to add an eventlistener to your button to attached a function to it.

1
2
3
4
5
6
this.YourButton.addEventListener(MouseEvent.CLICK,openURL);
function openURL(event: MouseEvent)
{
	var request:URLRequest = new URLRequest("http://www.isgoodstuff.com");
	navigateToURL(request);
}