PDA

View Full Version : I don't undersatnd proper code layout



tyrione
April 14th, 2008, 11:42 AM
Hey,

I went through a tutorial book on Flash CS3 that included some AS3 in it. The book was very good and I feel that I have a fairly solid ground level understanding of the program and of the coding structure, but when I have been looking through other books on AS3 as well as this website, it seems that the way I was taught to code is not the way that you guys are. For instance I do not understand the "import.flash.display" type coding. Here's is the way I was taught to code...


var myLoader:Loader = new Loader();
myLoader.load(new URLRequest("slideshow.swf"));
myLoader.x=-460;
myLoader.y=-220;
addChild(myLoader);


var content_req:URLRequest = new URLRequest("information.txt");
var content_ldr:URLLoader = new URLLoader(content_req);
content_ldr.addEventListener(Event.COMPLETE, onComplete);
function onComplete(event:Event):void
{
content_txt.htmlText = event.target.data;
}
If there is a "proper" way to code, then I would love to learn and understand it. Just right now, with all of this being so new, I am not at a level that I can adequately figure it out. Thank you so much for your help.

thatguythatsme
April 14th, 2008, 01:32 PM
import flash.display... is importing classes you are using in your as3 document. AS3 is completely class based now so if as in your code you want to use the Event, URLRequest, URLLoader classes you would have to import them first to have access of them.

I'd suggest Essential ActionScript 3 by Colin Moock, it really is worth every penny if not more...

Dave