Actionscript 3

Loading Multiple XML Files in Flash

Wednesday, April 21st, 2010

While working on my second version of RocFolio, I came across a few errors while trying to load multiple xml files in Flash AS3. When loading the files sometimes Flash would randomly put additional characters at the end of my xml file giving me parsing errors. So I had to figure out a way to cut those out, and I’ll try to explain real quick what I did.

So to load your XML you have to create your load and request variables and then you should create a few event listeners for progress and complete events, like this:

1
2
3
4
5
6
var loader:URLLoader = new URLLoader();
var requestURL:URLRequest = new URLRequest(xmlfilename.xml);
 
//create progress and complete event listeners for the loader, and load the urlrequest
loader.addEventListener(ProgressEvent.PROGRESS, getBytesLoop);
loader.addEventListener(Event.COMPLETE, loadXML);

Now in your loadXML function all you have to do is figure out where the xml file actually ends, and then index that spot and then cut the rest of the string out with the substring() command. Here is how you do that.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//function loadxml loads the xml and handles assigning to places
function loadXML(e:Event):void {
 
	var dataString:String = e.target.data;
	var finalString:String = "";
	var endofString:uint;
 
        //find out where the end of the xml file is, however your set it up it should be the last closing tag, this one is </settings>
	endofString = dataString.indexOf("</settings>", 0);
 
	//cut out the good part of the xml using substring, then use 0 as your starting point to where you got your endOfString
        //make sure to add whatever amount you need to be at the end of the your last closing tag, </settings> has 11 characters in it so +11
	finalString = dataString.substring(0, endofString+11);
 
	//then assign the finalstring to your XML variable
	try {
		var theXML:XML = new XML(finalString);
	} catch (e:TypeError) {
		//loader.load(requestURL);
		trace("A TypeError has occurred : \r\t" + e);
	}
 
//then go on with setting up your XMLLists so you can access the data how you want
}

So hopefully this helps those out there that are getting weird parsing errors when trying to load multiple XML files. I know I tried finding the solution out on the web and couldn’t so that’s why I wrote this, if it helps you out please leave a comment.

Cya

New Flash Horizontal Menu

Tuesday, March 23rd, 2010


I have another file for sale on ActiveDen and it’s called Flash Horizontal Menu. This flash horizontal menu is great for any site or flash project. It is written in AS3 (Actionscript 3.0) and can be used as the navigation on any website and is super easy to use and setup. This menu supports loading swfs, going to frame labels, frame numbers, external links, and calling functions. If you want to use it in your flash file just drag and drop it. If you don’t know Flash and you are linking to several web pages, use the provided swf and XML file and you don’t even have to open up Flash. Some of the special features are that its customizable by XML, you can easily change the width and height, and a special javascript function handles the resizing in the browser. There is no need to even open the flash file, unless you want to use it in another Flash project then its just drag and drop, easily change the initial font color and the hover font color, easily change the font size and font type, easily change the space between items and navigation padding on the left to easily center it, it handles most html tags for even more customization, and you can add as many items to the menu as you want.Click the image above to view the flash in action.

Cya

Mini RocPod – XML Flash Music MP3 Player

Friday, February 19th, 2010

I have another file for sale on ActiveDen, its called Mini RocPod – XML Flash Music MP3 Player. Some of the special features of this flash mp3 player is that it is fully XML driven, it streams the mp3s, you can add unlimited amount of songs, it has auto start feature, you can auto hide the panels on start up or show them on start up, it can be easily added to actionscript3 files by just dragging and dropping. you can easily change the color of the music player through the xml, it displays album art, and it has 7 different background skins or art to choose from.  I used a lot of the same functionality as my first flash music player I creatd,  the RocPod – Flash and XML MP3 Player, but I wanted something that was a little more standard so I took out the circular scroll wheel volume controller and the ipod style menu. I still wanted to mix it up a bit so I added 7 different background arts and the hide-able panels  and appropriate settings in the xml for them. In the end I was really happy with the design.

Cya

PureMVC – A Lightweight Open Source Framework for Flash

Monday, February 1st, 2010

I was looking around on the internet and come across the PureMVC website and was pretty impressed. PureMVC is a lightweight framework for creating applications based upon the classic Model, View and Controller concept. This concept is an architectural pattern used in coding that isolates the application logic for the user from the GUI, allowing development to come from different places “permitting independent development, testing and maintenance of each”.  PureMVC is open source and was originally implemented in the ActionScript 3 language for use with Adobe Flex, Flash and AIR, is now being ported to all major development platforms. I have taken a very quick look at it but it seems very cool. An example of this in use is the T-mobile website, which has a very cool flash GUI on the front page, take a look and see what I mean. The picture above is taken from the PureMVC website.

Cya

Flash Text Ticker / Scrolling Text in AS3 Revisited

Friday, January 29th, 2010

After looking at my google analytics for some time, I noticed I get  a lot of hits from this post:  “Flash Text Ticker / Scrolling Text in Actionscript 3.0“.   Its a basic tutorial on how to create scrolling text in Flash. I wanted to revisit that component and make it better, and integrate it with a XML file so users can easily edit things. I have finally finished working on it and it got approved for sale on activeden. Its called Flash Text Ticker / Scrolling Text Actionscript 3 and here are some of its features, and you click the image below to view the fullscreen preview:

  • Fully Customizable by XML
  • Easily change the width and height, and a special javascript function handles the resizing in the browser
  • No need to even open the flash file
  • 3 Different direction types to choose from
  • Easily change the scrolling speed, delay time, and duration
  • Easily change the font size, font color, font type, and link color
  • Handles most html tags for even easier customization
  • Add as many items as you want (Displaying one at a time)

Cya