View Full Version: Actionscript 3

lassie >>Discussions >>Actionscript 3


<< Prev | Next >>

bigmac- 02-07-2008

Out of interest, whe u said E4X parsing for XML data is unbelievably cool im guessing you meant for more than just dynamic image galleries... whats so cool about it? What all can it do? Well, lets put it this way... AS2 XML parsing was notoriously bad (not unlike most platforms that integrated XML). And, like most older XML platforms, AS2 had a totally unique set of access methods that no other languages supported. XML parsing was cumbersome, ungainly, but a necessary evil. AS2 used all kinds of weird "firstChild.childNodes" references that stacked in a totally non-nonsensical way. I never really figured out the hierarchical reading of the system, so generally just added and removed child access references until I hit the tier of data that I was after. There were a lot of these sorts of complains in all languages. So, some rocket scientists who were part of the ECMA coding-standards community had this wild idea a few years back of, "Hey, maybe we should create a coding standard for XML access". And so, E4X was born, which stands for "ECMA for XML". Let me see if I can remember how AS2 worked. We'll use this as XML: <?xml version="1.0" encoding="UTF-8"?> <portfolio> <image url="http://www.mysite.com/images/image.gif"> <title>My Awesome Image</title> <caption>Caption about image</caption> </image> <image url="http://www.mysite.com/images/otherimage.gif"> <title>Another Awesome Image</title> <caption>Caption about other image</caption> </image> </portfolio> You'll notice that I've made the "url" item an attribute of the <image> nodes. So, in AS2 this would have been read as something like this: var firstUrl = xml.firstChild.childNodes[0].firstChild.attributes.url; var firstTitle = xml.firstChild.childNodes[0].firstChild.title; Mind you, I actively worked in that system for two years and can't guarantee that I've referenced everything correctly. This is a huge reason why I never even considered doing Lassie with XML. However, child access is now worlds easier. To hatch in, you do this: var imageNodes:XMLList = xml.image; var firstUrl = imageNodes[0].@url; var firstTitle = imageNodes[0].title; And... E4X is way faster than the old parser.

fatbuoy1- 02-07-2008

ah... thats a LOT simpler! So can you just read from XML, or can Flash export info in real-time to an XML file? Like for instance could you create a comments system in Flash, or a blog?

bigmac- 02-07-2008

No, unfortunately. XML is a semantic data format, not formulaic like code structures. For all intents and purposes, XML was not designed with a machine in mind. It was designed for human to read and edit. The notion of a "portfolio" or "slideshow" is meaningless to a computer. As a result, you have to manually write all XML input and output algorithms... ironically enough, that's been a huge portion of what I've been doing for the past two days... This kids game now has 5 separate editor modules, each of which has an XMLWriter class to output its XML data, then I've written a parser for each to reconstruct that into Flash data on the game end. Mind you, that's just because I find it easier to natively use Flash data. I could theoretically run everything directly off the XML data.

fatbuoy1- 02-07-2008

So... flash CAN export XML data and then reload it? What are classes btw?

bigmac- 02-07-2008

CAN in this definition means that you manually write a script that deconstructs your data format, writes its values into a string between specified node markers, then sends it off to a PHP script to save it. On import, it's looping through that node structure looking for the same markers that were written out, and parses them back into a Flash object. Everything there is using a manually created algorithm... flash does nothing automatically save for provide the data management platform. As for this one... What are classes btw? That is priceless. :) That is one of the biggest, broadest, most massively infinite questions that I have ever gotten put into an offhand "btw". :) Long and short of it: Classes ARE OOP (object oriented programming). They ARE Flash action script. They ARE the actions panel that you type code into in the Flash IDE. Everything that you do in the Flash authoring tool is an automation of generating the class architecture that drives the final compiled program. As you get more advanced with Action Script, you stop working in the actions panel and script everything as external class documents; which are raw code files that get carefully built into an application library... architecture. That's the key concept, and that's what the second Matrix movie was getting at with the old dude in the white room. In turn, you get things like the SuperSheep player which – so far – is a blank FLA document that just references an external script library. Simple abstraction? Each class defines an Object. Objects are like employees in a company... everyone has a specific job to do. If you need multiple employees with a specific skill set, you create multiple instances of that employee's Object class. This is very advanced but ultra powerful stuff. Class architecture will beat up the bully and steal his lunch money once you get the feel for it. It does have a learning curve though. If you're into this stuff and want to keep learning, we'll get there.

bigmac- 02-07-2008

Incidentally... I share all this stuff because you seem to have a curiosity and growing knack for script, and you've already proven to be a solid designer. That said, you're sitting on a gold mine potential career path. It comes down to the simple truth that you as a multimedia guy are a better artist, designer, animator, and writer than most any artist, designer, animator, or writer is a programmer... if that makes sense. There's kind of a one-way dependency on the role. A snazzy design alone is useless when the requirement is for something interactive; so to be able to walk both sides of the creative/techy fence is a very valuable skill. I know of a lot of companies, my employer being one of them, who are having a hard time finding good talent to bridge the gap. While we're on different continents, I doubt that the creative landscape is much different on your side of the ocean. Just food for though :)

fatbuoy1- 02-09-2008

What are classes btw? The innocence of youth eh? :P So, you could write a class that creates a preloader display for you, and then just reference that same class for 20 different programs? (Though it probably wouldn't be worthwhile for something as small as a preloader but you get my point) you're sitting on a gold mine potential career path. Yeah, though my main reason for wanting to know this stuff is because it dramatically increases the amount of things I can create (both for myself and for clients).. Having said that, when the time comes I would hope to be employed because of my creativity and ideas more than my ability to use a computer, but it certainly doesnt hurt my employability :D Like I know how foreign the concept of making a contact form for a website was to me a few months ago... If I needed one I was totally dependent on someone ELSE to do it for me, which all adds to the time, cost and lack of control on a project. In fact, I think for me at this stage the 'loss of control' thing is probably the most important, because it restricted what I could design. Thanks to your help though, thats changed! I never thought I could enjoy staring at lines of code... but when those lines are making my design come alive they become a lot more interesting, and fun :D I still don't think I could ever enjoy programming for someone ELSE though, not having any creative input into the design of a project would drive me nuts I think.

bigmac- 02-10-2008

What are classes btw? The innocence of youth eh? :P So, you could write a class that creates a preloader display for you, and then just reference that same class for 20 different programs? (Though it probably wouldn't be worthwhile for something as small as a preloader but you get my point) Yep, that's exactly it. I still don't think I could ever enjoy programming for someone ELSE though, not having any creative input into the design of a project would drive me nuts I think. I said the same thing for a long time, and don't get me wrong – sometimes when I've got redundant development projects of re-inventing a slideshow for 10 different clients, it gets monotonous. However, none more so that a graphic designer who has to design the appearance of a re-invented sideshow for 10 different clients. That rut exists in all areas of the creative world, and is just part of the job. But to the point of just coding someone else's work – development is strangely satisfying, because it is very much your own "design" work. It's interactive design. This game that I'm building right now – I didn't do (almost) any of the graphics, I didn't write any of the story, nor will I have designed any of the world environments. However, the entire game experience that you'll ultimately play will be of my design – AND development. Interactive guys have to plan out every button, every transition, and every little detail of the experience. My requirements document specified that this game will "include an inventory"... ieish. That's a pretty broad definition of a very intricate system; ultimately one that I had to entirely design since no one else had. It's skinned with our art director's graphics, but it's very much the design of the interactive designer. So, it's a matter of perception where the line between design and development gets drawn.

fatbuoy1- 02-10-2008

When you put it like that I guess no matter what you do theres always going to be an opportunity to inject your own creativity into a project if you want to. :D

bigmac- 02-10-2008

When you put it like that I guess no matter what you do theres always going to be an opportunity to inject your own creativity into a project if you want to. :D No two ways about it: Yes. :D And personally, I think interactive design is one of the three most fun of all modern design mediums; its two rivals being motion graphics design and 3D design/animation. Those are the mediums that get to make everything whizz, zip, boing, bouce, beep, bloop, and splat as one unified and collective whole. :D

bigmac- 02-10-2008

PS: Don't get me wrong – I don't mean to be down on graphic designers... at all! I'm just stating my personal feelings after having started out as a graphic designer and discovering that I enjoyed interactive more so.

fatbuoy1- 02-10-2008

I agree, the interactive element has to be one of the biggest leaps in the industry in years, it has so much potential, far more than purely visual mediums. However, I still enjoy designing physical things, because theres something nice about creating something you can hold in your hand at the end of the day :) That said, I think theres potential for more traditional printed mediums, eg. books, leaflets, packaging, to be more interactive in their own way.

SeanCyrusTowel- 02-10-2008

Wow..... I've been avoiding reading this thread, mainly because of the exponential growth you two have done on it. But you know.... after reading it... I understand AS3 a lot better. Granted I have a slight programming background in C++ (and a tiny bit of Java) (and already knew what a class was ;-)). But now I feel like I could go and take an old C++ program I wrote that was functionally (only because it was text based and no graphics) minesweeper, and write it in AS3 (if I had the time to do it).

bigmac- 02-11-2008

That said, I think theres potential for more traditional printed mediums, eg. books, leaflets, packaging, to be more interactive in their own way. Heck yes! Those go out of digital mediums, but never let it be said there there is no such thing as "interactive print". I'll tell ya, there are few things more striking than getting some weird direct-mail advertisement that uses some weird folding/oragami technique to make it creative and engaging. As much as I hate getting advertisements in the mail, I still can't deny the cool-creative factor of some mail pieces. I remember one that I got which was a pop-up tent card sort of design. Neat stuff. It passed 3 of the 4 "G's" of direct mail with me, which are "get noticed", "get opened", "get read", "get response"... The one it missed on was "get response". As cool as the ad was, I wasn't going to buy the crap it was selling. Ironically enough, I can't ever remember what the product was anymore. But it had a good ad! :P

fatbuoy1- 03-27-2008

Quick question for you Greg if you get a moment... Im trying to use actionscript to generate rectangles which have a rotation of between -10 and +10 degrees. I can get it to draw one, but when I try using the timer class to draw one per second (I want the rectangles to pile up) it won't work... which means I've made an error somewhere along the line. Here's what I have so far... //Define the photo's properties function createPhoto() { var photo:Shape = new Shape(); photo.graphics.beginFill(0x999999, 1.0); photo.graphics.drawRect(50, 0, 600, 300); var photoRotate:Number = -10+(20*Math.random()); photo.rotation = photoRotate; photo.graphics.endFill(); addChild(photo); trace(photoRotate); } //Create the photo every second var tickerTimer:Timer = new Timer(1000,0); tickerTimer.addEventListener(TimerEvent.TIMER, createPhoto); tickerTimer.start(); Can you see any glaring mistakes i've made? Like I said, I can get the function createPhoto() to work, I just can't get the timer to call it. Maybe thats not such a quick question after all, but if you get a chance I'd appreciate it! :D

Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.