flash (?) - movieclip as button
- Started
- Last post
- 18 Responses
- ********
Quick flash actionscript question... I've google searched and can't find a simple solution to this:
Is there a way to make a movieclip "clickable" or behave like a button?
Using actionscript 2... Simply want movie clip "x" to go to a certain frame in that timeline once you click it.... I've tried converting the symbol from mc to button and not the desired effect. Any takers? Thanks in advance.
- funkage0
yourMovieClip.onRelease = function():Void {
this.gotoAndPlay("yourFrame");
}
- Autokern0
you don't need to convert anything.
A mc with the onRelease onRollOver and onRollout functions defined will work as a button (just one of them)so, on your actions layer in the timeline just do
my_mc.onRelease = function(){
this._x = whatever
}
- noiseisthis0
and:
my_mc.buttonMode = true;
- ********0
funkage and Autokern - many thanks, but neither solution worked (been up for 4 hours trying to figure this out)... unfortunately, this is not built using the rollover/rollout technique, it uses an customizable actionscript file with alpha fade in/fade out, the script works great, just can't link to anything with my humble newbie flash actionscript skills...
- ********0
I can send someone a source file or post a link and owe you a beer if you have time... ;)
- as2 or as3?Autokern
- as2********
- use http://pastebin.com/…funkage
- original file below... flashden :(********
- ********0
Not a huge web developer and working from a simple flashden file:
http://www.chrisdarmon.com/flash…
I have the button and script all custom and ready to go, just need to figure out how to "link" one of these scripts and still have the rollover to work... (?)... If that makes sense... Thanks mate!
- funkage0
What exactly are we trying to do here? Everything looks rather straightforward to me. :)
- ********0
funkage - you da man for keeping an eye on this thread at such an hour... All I want to do is make one of those damnable movieclip buttons "linkable" aka have the property of a "button" (go to this and that frame on the timeline and still have his alpha effect work)... OR just create a decent fadeIN/fadeOUT as2 button with actionscript similar to a button if you might have an extra laying around.... (?) too much to ask for?
- noiseisthis0
it looks like you have to use the fadeIn() and fadeOut() methods... but i dont see how its attached to the object itself... i like event listeners in as3 :)
- kingsteven0
check you're in the right scope, 'this' inside an onRelease function refers to the button/movieclip itself.
the answer may be to declare a variable in the same scope as you define your handlers... it gets copied across & references back to the current scope.
var self = this;
my_mc.onRelease = function(){
self.doSomething(this);
}
function doSomething(mc:MovieClip){
trace("doing something with "+mc);
}
- funkage0
Or say you have a movie with multiple frames, named "box_mc", on the root timeline, you could simply include this into your existing code:
button[i].onRelease = doSomething;
function doSomething() {
this._parent._parent.gotoAndPlay...
}
- funkage0
Refer to this instead:
http://pastebin.com/m5d56211e
- ********0
No go on any of these, getting errors out the ying yang with "on/on Clip Handler"... I hate to give up, but I've been at it for 5+ hours now and about to give up...
Right now, I have a fully functioning button that works fine, just need it to go to a certain frame on the timeline... I'll call the movieclip "go_about"... If I wanted go_about to link to a frame, any exact codes anyone can recommend to cut and paste?
- Are the files you provided the actual stuff? I did what I suggest earlier and it works fine.funkage
- kingsteven0
are you putting the code on the timeline of the button?
this.onRelease = function(){
_root.gotoAndPlay(22);
}or in its containing movieclip?
go_about.onRelease = function(){
_root.gotoAndPlay(22);
}
- kingsteven0
also. i noticed you called your target mc "x" in the first post, 'x' is a reserved word for some usages in actionscript. choose something else.
- (unless you were being all algebraic)kingsteven
- you damn genius!********
- ********0
KINGSTEVEN (imagine Samuel L. Jackson telling you this): "You are the motherf*&king man!*$!
go_about.onRelease = function(){
_root.gotoAndPlay(78);
}(in contained movieclip) WORKED! cha-ching... I owe you...
- ********0
Replace "snakes" with movieclips and "plane" with timeline:
- me too sam, me too.kingsteven
- Seriously thanks man, you saved me a migraine and hours of sleep, many thanxxx********
- ********0
I do get an error when I compile the flash movie, BUT the script still works and all is good except:
"Statement must appear within on/onClipEvent handler