FORUMS: list search recent posts

adobe actionscript/ movieclips

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
christopher elligsen
adobe actionscript/ movieclips
on Dec 7, 2009 at 6:49:05 pm

I need someone to help me on a little action script troubble that im having.

Its about linking 3 buttons to movie clips.

Its a little hard to explain

e-mail me : elligscr@email.uc.edu
ill send you the file with a better explanation and lets see what we can come up with.


Return to posts index

Marcus Geduld
Re: adobe actionscript/ movieclips
on Dec 7, 2009 at 7:20:43 pm

Christopher, if you want help, please try to explain the problem here. The benefit of these forums is that they help more than one person. Chances are, someone else is having the same problem you are. An answer that helps you will also help them.

It usually helps if you describe what you'd like to happen (e.g. when the user clicks on button1, movieclip1 should appear...) and what's actually happening (e.g. when I click, I don't see anything).

It also helps if you post your code.

Also, what version of AS are you using?

Thanks!

Author "After Effects Expressions"
Co-author "After Effects For Flash, Flash For After Effects"
Artistic Director, Folding Chair Classical Theatre, Inc
Senior Flash Developer, Zeitbyte.com


Return to posts index

christopher elligsen
Re: adobe actionscript/ movieclips
on Dec 7, 2009 at 8:25:47 pm

Im using Cs4
action script 3.0

the situation is this

im creating a biology PH scale (acid base)

there are 6 video clips

acid - base
acid - neutral
neutral - acid
neutral - base
base - neutral
base - acid

and there are 3 buttons

acid , neutral , base



i have already set and defined my functions-

function fromneutral_gotoacid (Event:MouseEvent):void
{
gotoAndPlay("neutral_acid")
trace("going from neutral to acid");
}

function fromacid_gotoneutral (Event:MouseEvent):void
{
gotoAndPlay("acid_neutral")
trace("Going from Acid to Neutral");
}

function frombase_gotoneutral (Event:MouseEvent):void
{
gotoAndPlay("base_ neutral")
trace("Going from Neutral to Base");
}

function fromneutral_gotobase (Event:MouseEvent):void
{
gotoAndPlay("neutral_base")
trace("going from base to neutral");
}

function fromacid_gotobase (Event:MouseEvent):void
{
gotoAndPlay("acid_base")
trace("going from acid to base");
}
function frombase_gotoacid (Event:MouseEvent):void
{
gotoAndPlay("base_acid")
trace("going from base to acid");
}


now im scripting each movie clip with these values


acid_btn.addEventListener(MouseEvent.CLICK, from_goto);
base_btn.addEventListener(MouseEvent.CLICK, from_goto);
neutral_btn.addEventListener(MouseEvent.CLICK, from_goto);

but yet after i defined all the terms, and everything works without script errors, the move still seems to loop out,



thats why i stated id rather send the file for someone to look at, than me trying to explain it :[


Return to posts index


Marcus Geduld
Re: adobe actionscript/ movieclips
on Dec 7, 2009 at 8:49:22 pm

That's mostly clear. The one thing I don't get is what you mean by "loop out."

Author "After Effects Expressions"
Co-author "After Effects For Flash, Flash For After Effects"
Artistic Director, Folding Chair Classical Theatre, Inc
Senior Flash Developer, Zeitbyte.com


Return to posts index

Marcus Geduld
Re: adobe actionscript/ movieclips
on Dec 7, 2009 at 8:56:18 pm

Another question: in these lines...

neutral_btn.addEventListener(MouseEvent.CLICK, from_goto);
base_btn.addEventListener(MouseEvent.CLICK, from_goto);
neutral_btn.addEventListener(MouseEvent.CLICK, from_goto);

You reference a function called from_goto. But I don't see that function anywhere in your code. I see other function with similar names, such as frombase_gotoacid, but no from_goto.

Also, your parameter to all functions is named Event with a capital "E"

(Event:MouseEvent)

Please change that to event with a lower-case "e". There's an actionscript class called Event, and your code is likely to confuse Flash.

Author "After Effects Expressions"
Co-author "After Effects For Flash, Flash For After Effects"
Artistic Director, Folding Chair Classical Theatre, Inc
Senior Flash Developer, Zeitbyte.com


Return to posts index

christopher elligsen
Re: adobe actionscript/ movieclips
on Dec 7, 2009 at 9:10:37 pm

The from_goto terms are defined differently inside the flash animation,


its hard to explain

there will be an instance for the acid buton
that will pull

acid_btn.addEventListener(MouseEvent.CLICK, fromacid_gotobase);
then in another section there will be
acid_btn.addEventListener(MouseEvent.CLICK, fromacid_gotoneutral);

etc.

its a lot easier if i could send you the file.






Return to posts index


Marcus Geduld
Re: adobe actionscript/ movieclips
on Dec 7, 2009 at 9:33:11 pm

I'm going to have to post something here to train people to stop using gotos -- and to stop using the timeline in general when coding with Actionscript. Timelines and Actionscript don't mix well in my opinion, and there's usually a better way.

Take a look at this file that I've made for you. I think it does what you want. Let me know if you have any questions:

http://www.grumblebee.com/stuff/cow/colorToColor.fla

In that file, I used colors instead of acids, etc. But the idea is the same. I have three basic color strips (rectangles filled with colors): a red one, a green one and a blue one. I also have gradient strips of every combination: red-to-blue, red-to-green, green-to-blue, etc. I've named the strips for their starting and ending colors, e.g. red_red, red_blue, etc.

Note that instead of making these frames, I have made them individual movie clips:

red_red
red_green
red_blue
green_red
green_green
green_blue
blue_red
blue_green
blue_blue

These are all on the stage, but my codes only one visible at a time. Here's the code:


const RED : String = "red";
const GREEN : String = "green";
const BLUE : String = "blue";
const UNDERSCORE : String = "_";
var nextFrom : String;

//these refer to movieclips that are on the stage.
//they are all in the same position (on top of each other)
//but on different layers.
var colorStrips : Array = [ red_red, red_green, red_blue,
green_red, green_green, green_blue,
blue_red, blue_green, blue_blue ];

init();

function init() : void
{
showColorStrip( RED, RED );
makeButtonsWork();
}

function showColorStrip( from : String, to : String ) : void
{
var instanceName : String = from + UNDERSCORE + to;

hideAllColorStrips();
if ( this[ instanceName ] )
this[ instanceName ].visible = true;
nextFrom = to;
}


function hideAllColorStrips() : void
{
for each ( var mc : MovieClip in colorStrips )
mc.visible = false;
}

function makeButtonsWork() : void
{
redButton.buttonMode = greenButton.buttonMode =
blueButton.buttonMode = true;
redButton.addEventListener( MouseEvent.CLICK, clickHandler );
greenButton.addEventListener( MouseEvent.CLICK, clickHandler );
blueButton.addEventListener( MouseEvent.CLICK, clickHandler );
}

function clickHandler( event : Event ) : void
{
var button : MovieClip = event.currentTarget as MovieClip;
if ( button == redButton ) showColorStrip( nextFrom, RED );
else if ( button == greenButton ) showColorStrip( nextFrom, GREEN );
else showColorStrip( nextFrom, BLUE );
}


Author "After Effects Expressions"
Co-author "After Effects For Flash, Flash For After Effects"
Artistic Director, Folding Chair Classical Theatre, Inc
Senior Flash Developer, Zeitbyte.com


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]