I never knew about those listeners…
As a general rule of thumb when dealing with asynchronous conflicts, always ask yourself if there is an event matching your scenario and do a search for such an event. A good place to start is the flash.events package. The Event class in particular is quite useful, check out its constants.
Could this be why when I have a simple as3 file and a load a as2 swf into it using flashs movie loader component and then it works when I first visit the frame with the external swf but then when i navigate to a different frame in the project and then back to the frame with the external swf it crashes flash. What could that be maybe. I was also looking for that code mb media I think you may have posted in the past about how to simply load a swf in as3 without using the loader component. Im hoping maybe that can solve my issue. Thanks
Using root to climb through the displayList is dangerous and a maintenance nightmare. I’ve waded through loads of this many times and when the clock is ticking, you feel that a rewrite is needed in order to continue with more maintenance patches!
Also, using long strings like parent.parent.parent.parent isn’t the way to go either since you’re creating a tight relationship. So if you add another clip inside your clip, you need to update all references. Timeline scripting isn’t very flexible, which is why using Classes is the way to go.
I’d use encapsulation to create loosely coupled components. That way your menu system doesn’t know about your loading system, etc. If you need access to data across one clip to another, you should really take advantage of AS3 ’s events. You can create a custom event by subclassing Flash.event.Events and pass data through custom events, for example:
to grab the current selected item instead of using a klugie reference such as parent.parent.parent.parent.myMenu.text
If the author is using timeline scripting, this may not be an option but you can cast root as a movieclip and still be legal:
// casts root as MovieClip MovieClip(this.root).container.clip.txt.text = "Hey Guys";
I’ve moved away from timeline scripting but some customers are still looking for that type of architecture and there are many maintenance projects I’ve worked on that still use this logic. “Why fix if it’s not broken?”
In the end, you may not see performance issues using root but in the end it’s not a best practice. Maintenance and re-usability are comprised since using that climbing logic creates a tight relationship.
AS3 coder here. Started coding AS2 on MX2004 , when it just appeared. I appreciate AS3 much more, feels not just a scripting language. Now working on CS4 Pro. Too bad FlashDen doesn’t permit CS4 files to be uploaded.
Continuous studying of new things and growing each day is my drive, that’s why I’m striving to get all the new things working.
Hi I used to code in as1 a couple of years ago and I have just jumped back in with as3 (my first class is in the upload queue). I’m probably the classic case – a designer who has gradually coded more and more as flash proceeded from timeline actions to OOP . So the last two months has been a process of refreshing my memory, then wondering why as3 works the way it does, before finally getting it.
One of my stumbling blocks was understanding the event model and wondering why things would work, and then suddenly not work. Eventually I realised that most of my problems were because I was relying on events happening in a certain order (duh).
One example of this was my assumption that the ADDED _TO_STAGE event would occur before my XML _ONLOADED event (the xml url is passed as a parameter to the class constructor and immediately loaded within the class). But of course no, it depends on the size of the XML file. Basic stumbling blocks like this have made me really start to understand the idea of encapsulation – it’s keeping things from relying on anything external to themselves right?
Anyway my point is that there are going to be a few teething troubles like this for many of us making the transition to as3 and I encourage anyone with brighter ideas than me to help pull together some general guidelines like not using stage unless you’re sure the instance is in the display list.
Or if there is already a decent guide out there, then link to it.
Hey AS3 coder here. I can try an help with some input on AS3 . I started out with flash in AS 2 .0. Didn’t do too much of it, it thoroughly confused me. After taking a break from Actionscript all together, I got back in when CS3 arrived with AS3 . I LOVE AS3 , it makes so much sense, I don’t understand how people prefer AS2 . I have been using AS3 for about the past Year and a half. My other talents lie in Animation (3D) and Design. So if anything, drop me line, I’ll try to drop in on this thread every now and again.
Well just found this…
Im not a flashden author but a buyer, and i think what MBMedia suggests is just the right thing to do… i bought a file from him some weeks ago and still have problems with external files, i´ve spent almost 100 dlls on components that haven´t work for me because they are not really made to work as that, components!!! and every time I bought a new one hoping it´ll work and doesn´t… i get the feeling of not buying anything at all ever…
It´s been really frustrating when some one like MBMedia tried to help me and explained to me why would this or that happen and then also tried to point me at the right direction… I know files here are sold as “they are” without promise of support… also know that him, as an author ,gave me all the help he could related to his file but besides that he can´t be trying to fix and make external files work for all of his buyers… the truth is most of “US” buyers don´t have enough AS knowledge to change things when they go wrong or dont work as we expected…
For instance, It´s not the first time i read about the code
“addEventListener(Event.ADDED_TO_STAGE, init); addEventListener(Event.REMOVED_FROM_STAGE, kill);”
The thing is I just dont know where it goes or how to use it… im having a problem that when i load any external swf to the template it works fine the first time… but then if i move to other section and then try to reload the external swf it wont work anymore…
I´ve tried to find an answer but nothing yet… i´ve come across some things like the need of using _lockroot = true; in the first frame of the movie so it´ll load, or to put some weird random extensions to the xml files so the browser wont “cache” them, check the paths of the xml, change them for absolute paths, go back to relative and on and on…
And i´m shure all this is because of the way components are made since this happen with two templates now….
So from now on im just gonna make shure the files i bought are fully compatible with any other file… and that, just leads me to buy only from authors I get to trust…
The main thing is that authors will lose sales because this specific problem or lack of support in many cases… and we buyers just end up looking for some other places to find answers and buy files besides flashden…
Hope this works out for the best of all parts….
I read somewhere flash as3 is having trouble with people who use the timeline and who load external swfs. its sad really I am having the same issues a quick solve I found is to have the swf you are loading on every frame and when you dont want to see the swf you just set visibility to 0. hope that helps. its wack i know