View current page
...more recent posts


Addendum to Class #16 (because you make me crazy some days)

Before we all got sidetracked turning Flash button objects into musical instruments I was starting to explain some simple flash navigation to you. (AS1, this will be meaningless soon, but you can use it for your remaining projects if you prefer Flash to HTML)

So here were the steps: (think of this as an exciting opportunity to work with a vintage version of flash and impress your friends with your new knowledge of arcane scripting methods)

1) make a button object in flash by drawing on the stage and converting the shape to a button (F8 key).

2)open up the button from the library and create a roll-over state, a down state and a hit area, (change graphics, add an animation, add sounds in the over and down frames)

3) CREATE A NEW LAYER ON YOR TIMELINE AND CALL IT 'ACTIONS' This is the only place on the stage where you will write any scripts.

4) Select your button and in the properties window give it an instance name: button1, button1 is a nice name don't you think? Then save your file with the new instance name. (this version has a bug where sometimes the instance name doesn't save properly, it is fixed in subsequent versions) (a hell of a lot changes in subsequent versions)

5) SELECT THE EMPTY LAYER THAT YOU NAMED 'ACTIONS'. press F9 to see the actions window and then copy the following code:

button1.onPress = function(){
trace("pressed");
}
button1.onRelease = function(){
trace("released");
}
stop();



If you did it right, you will see two messages: "pressed" and "released" when you test the movie. if it doesn't work, repeat the above steps again, at least 5 times before you ask me for help.


Now change the onRelease handler to read:

button1.onRelease = function(){
trace("onReleased");
play();
}

Now create another key frame in your timeline right next to your first frame with the button (F6). make a key frame in the actions layer as well and then write stop(); in the actions window of that key frame.

Make another button that looks different than the first one. Give it a different instance name. Me, I like button2.

In the new key frame in the actions panel where you currently should only see stop(); add this script:

button2.onPress = function(){
trace("onPress");
play();
}
stop();


there are all sorts of variations on this simple navigation script that I can go through with you

OK, now make a new movie, make a round shape and convert it to a button, add your fun sounds and graphics to it, give it the instance name button1, in the properties panel.

Select the button on the stage and press F8 and convert it into a movieclip

When you open the movie clip you'll see the button you made nested in there.

Create an actions layer, hit F9 and write the following:

clip1.button1.onRelease = function(){
trace("released");
_root.moveMe();
}

moveMe = function(){
clip1._x+=100;
trace("at move me");
}
stop();


You have now started to make a game of tiddlywinks. Write your first invoice NOW. (charge them one third of the job quote)

OK, sure its out of date action script, but your client won't know. However, the tech lead will fire your ass. (so I'd advise you to get that third of the quote up front before you even start) (of course you are totally screwed if I am the tech lead on the project)


- L.M. 10-29-2008 10:28 pm [link]

older posts...


[home] [subscribe] [login]