Flash ActionScripting
- Started
- Last post
- 5 Responses
- lw-d
Hi all,
Just wondering how I can add ActionScript to a button that resides in the library and not on stage.
I want to have all my AS on one frame and load objects using AS,
Thanks
- johnnyw0
You would control the object externally, so you wouldn't add code to it:
var mc:MovieClip;
function movieClipAction():Void {
mc = attachMovie("my_mc", "mc1", this.getNextHighestDepth());
mc.doSomething...
}movieClipAction();
- lw-d0
Wow, bit confused by that. So I have all my code in once place which is great. I have my initial home movie loaded using:
loadnav = function (temp:String) {
if (temp == "modeling") {
modeling_mc = this.attachMovie("modeling_mc", "modeling_mc","0",{_x:25, _y:108.8});
}
if (temp == "modeling") {
modeling_mc = this.attachMovie("modeling_mc", "modeling_mc","0",{_x:25, _y:108.8});
}
else if (temp == "home") {
home_mc = this.attachMovie("home_mc", "home_mc","0",{_x:25, _y:108.8});
}
}// calling the function on home
loadnav("home");Now I need to target buttons in the movies of each menu. Then basically change the value of loadmenu to reflect the button pressed. I thought that I would target the button using:
home_mc.modeling_btn.onPress = function() {
loadmenu = "modeling";
}That makes sense in my head with what I have learnt so far but it doesn't work :(
- cram0
well first of all, it is no great virtue to have all code on one frame. use the medium instead of fight it. (something i only recently learned)
but, to do what you say... design your movie clip symbol and make sure to give it a linkage name, for example, myClip_symbol.
var clip = this.attachMovie("myClip_symbol... "clip_1", 10);
clip.onRelease = function(){
//code here
}got it?
of course there are many ways to do this... this is only one.
good luck.
- enjine0
Use classes.
Name your attached movie, set the linkage to allow it to be exported with the movie, and link the class via the class linkage box.write your code in the external .as file that corresponds to the name you supplied in the linkage dialog.
use the program, don't fight it.
- PonyBoy0
enjine and cram gave great advice about 'not fighting the soft'...
macrodobia's smart folk who built and talk about the software also recommend that. :)