Forum ActionScript 3.0 Populate List control

Problems and discussions relating to ActionScript 3.0 here.

Populate List control

Postby WriterOfCode » February 28th, 2011, 11:16 pm

I'm a newb at Flash/actionscript, but not to programming in general. I'm quite competent in a few other languages and even hold a minor in computer science, however...learning Flash feels like one of the most obtuse things I've ever done with a computer. Why is my code housed in layers and frames instead of individual files? It feels strange.

I might feel a little less strange though if I could solve this: I have a List control that I'm attempting to populate with text from an XML file in the same directory, and yet the control renders but I never see any text.

Under output I get "Fonts should be embedded for any text that may be edited at runtime, other than text with the "Use Device Fonts" setting. Use the Text > Font Embedding command to embed fonts."

Code: Select all
import fl.controls.List;
import flash.events.Event;
import flash.xml.*;
import fl.data.DataProvider;

var swfList:List = new List();
swfList.setSize(140,140);
swfList.move(130,45);
var tf:TextFormat = new TextFormat();
tf.font = "Arial";
tf.size = 8;
tf.bold = true;
swfList.setRendererStyle("textFormat", tf);
addChild(swfList);


//ezTipType1Main

var xmlData:XML = new XML();
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load (new URLRequest("swflist.xml"));
xmlLoader.addEventListener (Event.COMPLETE, onXMLDone);

function onXMLDone (event:Event):void
{
xmlData = XML (event.target.data);
var dp:DataProvider = new DataProvider(xmlData);
swfList.dataProvider = dp;

}

this.stop(); //when do I use this.stop?


Oh, this is my first post on player. I believe this occasion requires an emoticon; here -- this one looks vaguely appropriate: :idea:
WriterOfCode
 
Posts: 1
Joined: February 28th, 2011, 11:06 pm

Re: Populate List control

Postby GameTwoThree » March 2nd, 2011, 10:56 am

Hello,
Im sorry I can't help you with your problem because I didn't have a need to use XML files for my games yet, however I just want to state a fact that you CAN acctually write the code in individual .as files and that's how the good coders do it, and so should you.

I cannot imagine writing the code in frames.

Check out this tutorial to see how it is done before you get used to that frame coding stuff:

http://gamedev.michaeljameswilliams.com ... utorial-1/

Also my first post, hello everyone. :)
GameTwoThree
 
Posts: 11
Joined: February 28th, 2011, 2:11 am

Re: Populate List control

Postby Benjaminsen » March 2nd, 2011, 4:25 pm

I will see if I can make a tutorial for getting started with Flash Builder and Player.IO. It's a much better experience if you are coming from a CS background.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark


Return to ActionScript 3.0