It is currently Sat Apr 27, 2024 2:10 pm



Reply to topic  [ 56 posts ]  Go to page 1, 2, 3, 4  Next
Flash5 actionscripting 
Author Message
Felix Rex
User avatar

Joined: Fri Mar 28, 2003 6:01 pm
Posts: 16650
Location: On a slope
Reply with quote
Post 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. :)

_________________
They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.


Sat Apr 12, 2003 4:33 pm
Profile WWW
Minor Diety
User avatar

Joined: Mon Mar 31, 2003 7:23 am
Posts: 14878
Location: behind a good glass of Duvel
Reply with quote
Post 
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. :)

_________________
"I find a Burger Tank in this place? I'm-a be a one-man cheeseburger apocalypse."

- Coach


Sat Apr 12, 2003 6:33 pm
Profile
Felix Rex
User avatar

Joined: Fri Mar 28, 2003 6:01 pm
Posts: 16650
Location: On a slope
Reply with quote
Post 
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

_________________
They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.


Sat Apr 12, 2003 8:02 pm
Profile WWW
Duke
User avatar

Joined: Mon Mar 31, 2003 8:59 am
Posts: 1358
Location: right behind you
Reply with quote
Post 
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.


Sat Apr 12, 2003 10:22 pm
Profile YIM WWW
Felix Rex
User avatar

Joined: Fri Mar 28, 2003 6:01 pm
Posts: 16650
Location: On a slope
Reply with quote
Post 
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;
}
-----------------------------------------------------------------------------------

_________________
They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.


Sun Apr 13, 2003 6:50 am
Profile WWW
Minor Diety
User avatar

Joined: Mon Mar 31, 2003 7:23 am
Posts: 14878
Location: behind a good glass of Duvel
Reply with quote
Post 
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. :)

_________________
"I find a Burger Tank in this place? I'm-a be a one-man cheeseburger apocalypse."

- Coach


Sun Apr 13, 2003 4:54 pm
Profile
Felix Rex
User avatar

Joined: Fri Mar 28, 2003 6:01 pm
Posts: 16650
Location: On a slope
Reply with quote
Post 
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;
}
}

_________________
They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.


Thu Apr 17, 2003 4:59 pm
Profile WWW
Duke
User avatar

Joined: Mon Mar 31, 2003 8:59 am
Posts: 1358
Location: right behind you
Reply with quote
Post 
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.


Thu Apr 17, 2003 7:07 pm
Profile YIM WWW
Felix Rex
User avatar

Joined: Fri Mar 28, 2003 6:01 pm
Posts: 16650
Location: On a slope
Reply with quote
Post 
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. :)

_________________
They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.


Thu Apr 17, 2003 9:19 pm
Profile WWW
Duke
User avatar

Joined: Mon Mar 31, 2003 8:59 am
Posts: 1358
Location: right behind you
Reply with quote
Post 
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.


Thu Apr 17, 2003 9:48 pm
Profile YIM WWW
Minor Diety
User avatar

Joined: Mon Mar 31, 2003 7:23 am
Posts: 14878
Location: behind a good glass of Duvel
Reply with quote
Post 
Hehe, like that way of thinking. :)

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

_________________
"I find a Burger Tank in this place? I'm-a be a one-man cheeseburger apocalypse."

- Coach


Fri Apr 18, 2003 12:08 pm
Profile
Felix Rex
User avatar

Joined: Fri Mar 28, 2003 6:01 pm
Posts: 16650
Location: On a slope
Reply with quote
Post 
whatever turns you on, Ox. :) So, you gonna tell him he was wrong about the actionscripting alpha fade? :D

_________________
They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.


Fri Apr 18, 2003 3:05 pm
Profile WWW
Minor Diety
User avatar

Joined: Mon Mar 31, 2003 7:23 am
Posts: 14878
Location: behind a good glass of Duvel
Reply with quote
Post 
Hehe, i'll just link him to this topic and let him read it for himself. :twisted:

_________________
"I find a Burger Tank in this place? I'm-a be a one-man cheeseburger apocalypse."

- Coach


Fri Apr 18, 2003 3:59 pm
Profile
Felix Rex
User avatar

Joined: Fri Mar 28, 2003 6:01 pm
Posts: 16650
Location: On a slope
Reply with quote
Post 
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. :)

_________________
They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.


Sat Apr 19, 2003 8:18 pm
Profile WWW
Duke
User avatar

Joined: Mon Mar 31, 2003 8:59 am
Posts: 1358
Location: right behind you
Reply with quote
Post 
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.


Sat Apr 19, 2003 11:07 pm
Profile YIM WWW
Display posts from previous:  Sort by  
Reply to topic   [ 56 posts ]  Go to page 1, 2, 3, 4  Next

Who is online

Users browsing this forum: No registered users and 57 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware.