When I open a new doc and selct action script 3 it won't allow me to insert code by selcting the button on the stage. It does if I select action script 2. All my old pages update ok but if I make new buttons it wont take the code. CAn someone tell me what is going on??? Thanks a lot
Thanks for the reply, I tried putting the code in the timeline keyframe and it still did not work. I am in a pinch because my whole graphics arts class (two of them) have built their pages and now the old code I used does not work as it did in our schools older version. Can you please tell where to insert the load movie code? thanks This is what I am trying to get the buttons to do. on(press){ _root.loadMovie("graphic_arts/graphic_arts.swf"); }
If your in a bind at the moment, I would suggest not attempting to learn AS3. The system is very different, good, but different, the syntax structure is much more strict and most things have been revised to use a listener/broadcaster (or event dispatcher) model, as well as most coding being class oriented, additionally the graphic display structure is quite different. Now did you change your publish settings back to AS2? If so, you should still be able to apply the above code to a button instance. However, as Dave stated, even in AS2 the code is best used from the timeline, to do so with the code above (which the on handler here is meant for Object attachment) you need to write it like this: my_btn.onPress = function() { _root.loadMovie("graphic_arts/graphic_arts.swf"); } I would also consider using a MovieClipLoader and the loadClip method forloading swf files, as it gives you more control over the load targeting, progress reporting, and event notifications. All this said, to use a button and load a file in AS3, you need to add an event listener to the button instance and construct a responding function to the event, in this case the loading of a swf file. Additionally, in AS3 the MovieClipLoader class, as well as the loadMovie methods have been replaced by the Loader classes and must be used to load swf files. So construct a button in AS3 you must write something like the following: import flash.display.*; import flash.net.URLRequest; function loadSWF(event:MouseEvent) { var ldr:Loader = new Loader(); var url:String = 'graphic_arts/graphic_arts.swf'; var file:URLRequest = new URLRequest(url); ldr.load(file); addChild(ldr); } my_btn.addEventListener(MouseEvent.CLICK, loadSWF);
Don't see what you're looking for? Try a search.
|