A reader emailed with a problem he’s having with the ExternalInterface. It seems that his code works fine when the page is hosted on a server but doesn’t work sometimes when accessed directly on the PC. ( Meaning opening the file locally in the browser with a C://path/filename. )
I seem to recall some issues that I had in the past but I haven’t worked with the ExternalInterface in over a year.
The error he gets is: Object or property is not supported.
The reader who asked the question said that he found no mention online nor in the documentation about this. Anyone out there know what’s the what?
Flash and XML go together like peanut butter and jelly. If your working on a project where there is data inside of Flash that is likely to change then XML is the way to go. That way you, or anyone with a text editor, can update an XML file – essentially a text file – and change things inside your Flash app.
The downside to using XML is that the data you get back can be confusing as hell to navigate through. I had to deal with it enough that I finally created a class – PXP2 – that takes care of all the mundane aspects of using XML so that you can get right to work and skip a lot of code and confusion.
In this tutorial I’ll do a simple example of how I would create a site navigation using XML.
A few notes: there is no AS3 version PXP2 of this because AS3 has the E4x class which is like PXP2 on steroids. I’ll do a tutorial on how to use E4x in a few weeks.
The <embed> tag will run in Netscape/FireFox browsers. Simply place the following attribute anywhere inside the <embed> tag:
FlashVars="var1=One&var2=Two"
Using the Flash IDE’s Javascript ( AC_RunActiveContent.js )
I add the FlashVars parameter to the end of the AC_FL_RunContent function like so: ’salign’, ”, ‘flashvars’,'var1=One&var2=Two’); //end AC code
Don’t forget to add a comma after the – ’salign’, ”, - line. If you don’t you’ll get a Javascript error and nothing works. I’ve only made that mistake a few dozen times.
And don’t forget, you have to edit the <object><embed> tags contained in the <noscript> block manually.
This video tutorial begins where the first one left off. Here you’ll learn to place your class files inside a unique name space within your global class path.
If you’ve ever downloaded someone else’s class files and couldn’t get them to work this might help.
An import statement adds that class to your SWF when it’s compiled and adds on to the file size of your SWF. If you’re importing a class but not using it then you’ll bloat your SWF filesize unnecessarily. This happens from time to time when you edit your code and remove a call to a class and forget to remove the import statement.
If you’re using class files ( .as ) you need to know where to put them. It can be a little confusing because they can go in more than one place. In the video below I’ll cover the basics of where you can put these files and make them work.
About polyGeek Dan Florio is a freelance Actionscript Flex/Flash/AIR developer. He loves playing and exploring with code and sharing what he finds with his friends and peers here on this blog. He also created the website RunPee.com that has become an international sensation and pays most of the bills.