ClanKiller.com
http://forums.clankiller.com/

Flash5 actionscripting
http://forums.clankiller.com/viewtopic.php?f=8&t=64
Page 1 of 4

Author:  Satis [ Sat Apr 12, 2003 4:33 pm ]
Post subject:  Flash5 actionscripting

Hey, Pig, you know much about actionscipting?

I recently learned how to use actionscript to set an element's alpha blend on(release). I was curious if you knew of anyway to use purely actionscript to tween, ie tweening 100% alpha to 0% across say 20 frames. Would cut down alot of work. :)

Author:  Rinox [ Sat Apr 12, 2003 6:33 pm ]
Post subject: 

Mmm, if Pig wouldn't know, i got a mate who's good at Flash, so i could try and ask him to answer this. We'll see. :)

Author:  Satis [ Sat Apr 12, 2003 8:02 pm ]
Post subject: 

hey, cool with me. I'll take any answers. Need it for a project for my Cisco class. :) Should turn out pretty cool. I'll probably make the end result available on my website. :D

Author:  Pig [ Sat Apr 12, 2003 10:22 pm ]
Post subject: 

Sorry, I'm not that familiar with action script. I let flash do all my tweening. I use action script mainly for events.

Post on the flashkit forums.

Author:  Satis [ Sun Apr 13, 2003 6:50 am ]
Post subject: 

I'm checking flashkit now. I'm pasting in what I find.

---------------------------------------------------------------------------------
onClipEvent(load){
// Set initial alpha to zero
this._alpha=0;
}
onClipEvent(enterFrame){
// As long as alpha is lower than 100, increase with five
if(this._alpha < 100){
this._alpha+=5;
}
}
----------------------------------------------------------------------------------
onClipEvent(load){ _alpha = 0; }

onClipEvent(enterFrame){
_alpha > 100 ? _alpha = 100 : _alpha++ ;
}

or control a movieclip instance - clip1 from the main timeline -

clip1._alpha = 0;
this.onEnterFrame = function(){
clip1._alpha++;
trace(clip1._alpha);
clip1._alpha > 100 ? delete this.onEnterFrame : null;
}
---------------------------------------------------------------------------------
actionscript resize

//ActionScript on your clip

onClipEvent(load) {
this.xend = 100;
}

//this bit's changed...
onClipEvent(enterFrame) {
this._xscale += (this.xend - this._xscale) * 0.5;
//change the 0.5 to get the easing you want
}

//On your button
on(press) {
clip.xend = 200;
}
-----------------------------------------------------------------------------------

Author:  Rinox [ Sun Apr 13, 2003 4:54 pm ]
Post subject: 

Copied and pasted your question to me mate and what he said was:

"Can't do that with actionscript, you gotta make a movie clip and use that as release stage of a button."(translated from Dutch by me but blah, the vital terms were English anyhoo)

Just as much Chinese to me as your question was, but hope it helps. Normally speaking he should know more than a thing or two about flash so i guess he's right. :)

Author:  Satis [ Thu Apr 17, 2003 4:59 pm ]
Post subject: 

I got it I got it I got it I got it. It works. WOOO. ahem. Anyway, this is the code I used.

on (release) {
mpconduit._alpha = 100;
mpconduit.onEnterFrame = function(){
mpconduit._alpha--;
mpconduit._alpha < 0 ? delete mpconduit.onEnterFrame : null;
}
}

mpconduit is a movie clip so I could name it, even though it's really just a graphic. It works. Now, a question. mpconduit._alpha-- increments the alpha by 1 per frame. How can I alter this to change it by 5? I mean, I could do
mpconduit._alpha--;
mpconduit._alpha--;
mpconduit._alpha--;
mpconduit._alpha--;
mpconduit._alpha--;
but that's ugly and there must be a better way. Also, ahem, there's like alot of elements in these buttons, not just one. Is there any way to lump them together under one expressoin?

Below I'm posting the entire contents of the button. It's long. :/

on (release) {
mpconduit._alpha = 100;
mpconduit.onEnterFrame = function(){
mpconduit._alpha--;
mpconduit._alpha < 0 ? delete mpconduit.onEnterFrame : null;
}
mpwalls._alpha = 100;
mpwalls.onEnterFrame = function(){
mpwalls._alpha_alpha--;
mpwalls._alpha < 0 ? delete mpwalls.onEnterFrame : null;
}
mpname._alpha = 100;
mpname.onEnterFrame = function(){
mpname._alpha--;
mpname._alpha < 0 ? delete mpname.onEnterFrame : null;
}
background._alpha = 0;
background.onEnterFrame = function(){
background._alpha++;
background._alpha > 100 ? delete background.onEnterFrame : null;
}
portaname._alpha = 100;
portaname.onEnterFrame = function(){
portaname._alpha--;
portaname._alpha < 0 ? delete portaname.onEnterFrame : null;
}
portawalls._alpha = 100;
portawalls.onEnterFrame = function(){
portawalls._alpha--;
portawalls._alpha < 0 ? delete portawalls.onEnterFrame : null;
}
portaconduit._alpha = 100;
portaconduit.onEnterFrame = function(){
portaconduit._alpha--;
portaconduit._alpha < 0 ? delete portaconduit.onEnterFrame : null;
}
bldganame._alpha = 100;
bldganame.onEnterFrame = function(){
bldganame._alpha--;
bldganame._alpha < 0 ? delete bldganame.onEnterFrame : null;
}
bldgaconduit._alpha = 100;
bldgaconduit.onEnterFrame = function(){
bldgaconduit._alpha--;
bldgaconduit._alpha < 0 ? delete bldgaconduit.onEnterFrame : null;
}
bldgawalls._alpha = 100;
bldgawalls.onEnterFrame = function(){
bldgawalls._alpha--;
bldgawalls._alpha < 0 ? delete bldgawalls.onEnterFrame : null;
}
bldgawname._alpha = 100;
bldgawname.onEnterFrame = function(){
bldgawname._alpha--;
bldgawname._alpha < 0 ? delete bldgawname.onEnterFrame : null;
}
bldgawwalls._alpha = 100;
bldgawwalls.onEnterFrame = function(){
bldgawwalls._alpha--;
bldgawwalls._alpha < 0 ? delete bldgawwalls.onEnterFrame : null;
}
}

Author:  Pig [ Thu Apr 17, 2003 7:07 pm ]
Post subject: 

I am certain there must be some kind of foreach() function or a while function, but I don't know action script that well.

All scripting is basically the same concepts, worded differently.

while( $i=0; $i < 101; $i++ )
{
//stuff here
}

That's what it would look like in PHP. Not sure in AS.

Author:  Satis [ Thu Apr 17, 2003 9:19 pm ]
Post subject: 

awww, you're no help. :P Looks like I'll have to actually go research. Ah well. I also found out how to disable a button via actionscript. That'll keep dumb stuff from happening, like pushing the same button twice and having it skip to 0 alpha (from 100) and fade in repeatedly.

originalbutton.enabled = false;

that's the code, in case you care. :)

Author:  Pig [ Thu Apr 17, 2003 9:48 pm ]
Post subject: 

I look forward to seeing what you are doing. I've never had to do anything so complex that I couldn't accomplish it with movie symbols and needed to use action scripting like that. Consequently, I've never bothered to learn.

Author:  Rinox [ Fri Apr 18, 2003 12:08 pm ]
Post subject: 

Hehe, like that way of thinking. :)

I'll see if i can ask my mate about it Satis, if you'd need "help".

Author:  Satis [ Fri Apr 18, 2003 3:05 pm ]
Post subject: 

whatever turns you on, Ox. :) So, you gonna tell him he was wrong about the actionscripting alpha fade? :D

Author:  Rinox [ Fri Apr 18, 2003 3:59 pm ]
Post subject: 

Hehe, i'll just link him to this topic and let him read it for himself. :twisted:

Author:  Satis [ Sat Apr 19, 2003 8:18 pm ]
Post subject: 

anyone who's interested can see what I've got so far.

http://clankiller.com/cisco

It's nowhere near done, but you can see why I needed all the flash actionscripting. Please note the movie is 1 frame long. :)

Author:  Pig [ Sat Apr 19, 2003 11:07 pm ]
Post subject: 

ermm.... I really like what you did. As far as the alpha fading thing, I think there is an easier way to do it.

1) make a layer for each item within the image, and make sure each item is a symbol (I imagine they already are).

2) create 3 keyframes for each layer, each occuring in synch with the others. first key frame is alpha=0, 2nd is alpha=100, 3rd is alpha=0.

3) tween them (duh)

4) add stop(); to each key frame, except the last, which should loop back to the first key frame.

5) for your buttons, add the AS:
on(release)
{ with (symbol_name) { gotoandplay(nextframe); } }

I'm sure my action script is a bit off, but that is how I would do it.

Page 1 of 4 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/