Using Flash again has been something that I would not normally like to do, as I used to know the program fairly well, but ever since Adobe took it over I have gotten lost, especially when it came to the action script.
Seeing as my current project plan will involve the use of action script if I am to use Flash for it, which it looks like I will seeing as it’s being taught at Uni, I thought I’d better get back to basics with it.
I have been reluctant to start from the beginning again with tutorials as I have found myself getting frustrated quickly with them. However this time was different – I needed to go back to basics and start from the beginning.
I have been using the tutorials from the Adobe website to help teach and refresh myself as well as going over what we have been taught in our tech classes. It is really basic stuff, and the use of Flash before has helped in deciphering some of the tutorial content, and I have produced this:
The butterfly flapping its wings is a movie clip that we created in our tech lessons in class, the movement across the screen and the button is what I have taught myself the evening after class.
The movement itself was actually taught in class, but using the ‘Classic Tween’ option in this I have used the new ‘Motion Tween’ which is much easier to use after reading up about it, and realising that is more powerful, just tricky. That and I found it easier to think of it like the motions you create in 3DSMax as it was fairly similar.
I know it looks so very simple and is hardly worth mentioning on the blog, however it does represent a rather big achievement for me as I finally feel a bit better at getting my head around ActionScript 3.0. As before the script in Flash was rather crude and to do anything flashy it would take a long time and a lot of code, yet basic things like buttons were simple. They just required a simple ‘stop’, ‘play’ and ‘goto’ instruction, yet as Flash has evolved and become more powerful so has its code and old things like that are no longer valid.
ActionScript 3.0 is object orientated, and I knew this but it was just not clicking in my head, and recently after going over all this it has. Partly in thanks to what I learned on my brief appearance on a programming course, and tiny my knowledge may be from that experience, something did stick in my brain and I am now more confident at being able to learn it a bit better. It’s not going to be easy as what I have learned here is but a grain of sand over all, but it is the first grain and therefore a start. 🙂
The code that has been eluding me is this, so very small and simple….
- import flash.events.MouseEvent;
- function onClick(event:MouseEvent):void
- replay_btn.addEventListener(MouseEvent.CLICK, onClick);
From what I understand line by line:
- This is importing objects from the library built into ActionScript 3.0, which will use methods from the ‘MouseEvent’ class to call upon when the player uses the mouse.
- Calling the function ‘onClick’, which means that when the mouse is clicked it must then do the following otherwise do nothing.
- Open bracket.
- This will ensure that when the mouse is clicked the animation will go back to frame 1 and play automatically.
- Close bracket.
- This is telling the code to listen out for that mouse click on the button that has been named ‘replay_btn’ (which is done in the Instance Name box when looking at a buttons Properties).
18-01-11_Edit: Though in saying this I have already created a small animation that had to have some interactivity for Uni before. While at Sussex in the only module that I actually liked we were creating a website with a small Flash animation on it. It has to include various shape/colour/movement tweens, a walk cycle, scrolling background, a plot and buttons…I had forgotten about this until now as most of what I studied at Sussex is a blur. This particular project involved a lot of head hitting desk moments and various sleepless nights now I come to think about it.
Anyway over a year ago a produced this:
Looking back on the .fla file now it is a very confusing mess of a timeline and layers for such a small animation, which makes me wonder how daunting this current project is going to look. It is also really badly coded, I am completely unsure how those buttons are even working! 🙂
Anyway after what has been a very long post I now need to get back to:
- Researching nature/nurture effects
- Planning out the structure of events
- Learning more about buttons and mouse roll overs in Flash
- Creating a small demo with initial artwork