ActionScript 2.0 :: Get The Instance Name Of The Button?
Oct 7, 2004
I want the following to happen: when I press my button, it should get the instance name of the button. I have the following code:
within the instance/flash actions window
on(release) {
PressButton();
}
[Code].....
I keep getting "undefined" as my answer. Furthermore, if I put trace(this._name) I get nothing (as in I get black on the output window). However, if I put in a string within the trace (such as 'Hello'), it works. So, assume everything works but the whole NamesButton._names part.
I placed a movie clip instance inside a button, and I want this movie clip to play when the button is released. I'm using this code on the frame containing the button:
function playMovie(event:MouseEvent) { this.theButton.theMC.gotoAndPlay(3);
Does creating a new instance of an Object that uses an identical name to an older instance, delete the previous instance? Or should the original instance be deleted first? The code uses a ridiculous amount of XML vars. Isn't it less memory intensive to parse the XML and save the properties to an Object, and then delete the XML Object, rather than keep the XML Object around and reference it's child nodes directly? Is it better form to break up a huge XML file (>600lines/3200vars) into smaller chunks?
How can I change the text of a button instance without affect the other button text? I belive an AS aproach would solve it but I don't know how to do it.
I am trying to learn Flash and as soon as I think I am in good shape, comes along this "curve ball". Take a look at the .FLA from this site ([URL]) How in the world do the alpha buttons get their captions? I understand the numeric ones, but alphas completely baffle me as there is no code (that I can find) that sets them. I have deleted all of the Actions, I have deleted virtually everything there is, and I still can't figure out how does the button instance appear as the caption in the text box.
I have 4 instances of the same button on a single layer in a timeline of the mc 'coverflow_mc' named 'ThatsMe_btn_a' to 'ThatsMe_btn_d' ie same button, same position.. it just changes instance name on 4 keyframes. Why does it call the function fine for button a but not for b,c, or d? There is a stop on each of these frames and I can see from the swf that it is stopping at the correct frames.
function thatsMe() { right = new Sound(); right.attachSound("right");
I have created seven buttons in flash called "button1" through "button7" within each button is a text box. Is there a way to load XML text into each text box within the button instance?
In my timeline I have a button, with an instance name of view_only_button. On my actions layer, I have code that is attempting to add a listener for a MOUSE_DOWN event. The frame that has the button is the same as where the actionscript is going, but of course it is two different layers. When I try accessing the variable by the code below, I get the error:
Error #1009: Cannot access a property or method of a null object reference.
ActionScript Code: view_only_button.addEventListener(MouseEvent.MOUSE_DOWN, viewOnlyDownHandler); function viewOnlyDownHandler(event:MouseEvent):void{ //Code to execute inside of the event call }
When commenting the addEventListener line out, the error goes away. I am unsure why this would issue an error
I'm using a loop to generate and position a bunch of movieclips on my stage and another to add mouse eventlisteners to them, turning them into buttons.
All this works fine however when i attempt to trace the instance name of the button pressed, output is firing "instance40" or "instance41" etc.
how do i get the correct instance name? I'm attempting to get at the value of the textfield held within the movieclip i.e. trace(evt.target.value_txt.text); however this is resulting in errors.
Is there a standard procedure for generating buttons in a loop? I'm not understanding why my buttons aren't tracing the correct instance names or why i can't access the movieclips contents, specifically the value of the dynamic text field?
Code's below, if anyone wants to see the whole code, or FLA, give me a shout.
ActionScript Code: var eggs:Array = []; for(var i:uint = 0; i < 24; i++){
My library has an instance of a button symbol which brings up a popup with more information when clicked. All i want to do is change the display text of the button instance. From what i've read i thought i could just double click the instance and modify in the properties but there is nowhere in the properties to change the text.
I am trying to sort out someone else's project and am not used to AS2. There are nine people in a folder called peeps. I want to load a swf into a modal on the page based on the instance name of the button clicked on. How do I get the instance name? I put ? around where the selector should go, not sure what should be there.
I'm trying to give a button an instance name. The button is situated in the library, and i suppose that's why I cannot give it an instance name (which is really necessary.)It 's in actionscript 2.
I have about 10 buttons on the page. When you click one of the buttons, there is a popup (which is closeable). The user is meant to click all buttons (and open all of the popups) before they can move on (before the next_btn becomes visible). So far I just have a counter type of code in place (when you click a button one gets added to the counter), but you could just click on the same button 10 times and the next_btn will become visible. I cant figure out how to specialise the counter. I want the user to click ALL of the different buttons before they can click the next button and move on..
I created a button on the stage and made it a movie clip and called it's instance name "play_btn" then i made a document class "main.as" and a second class "play button.as". How is to access the instance name in the play button.as file like this...
public class login_page extends MovieClip { public function login_page() { play_btn.addEventListener(MouseEvent.MOUSE_DOWN, onPlayDown); } public function onPlayDown(evt:MouseEvent):void { trace("Test"); }}
And then I want to call the function in the main.as.. but the general problem is that I want to access the instance name "play_btn" in the "playbutton.as" file. I tried to link it to the class but i get this error: 1120: Access of undefined property play_btn.
I have a button which appears on multiple frames. I want to define an action on the button rather than each instance. Is there any way that I can do this in CS5?
I've created a button in Flash, and inside that I have a TextField and a MovieClip, both with instance names set. They cover all 4 frames of the button, with no keyframes.I found I couldn't access the objects using the instance names I'd set, so I used this piece of code to see what's going on:
var obj:DisplayObject = this.m_graphics.btnChange.upState; for ( var i:int = 0; i < obj.numChildren; i++ ) {
I have 2 instances of a button wich is red and has a white label I have to edit the buttons so one button is red, and the other is green I was doing this, but when applied Also the title of label goes green instead of being white...
I've been learning AS3 lately and am trying to put together an interactive map. I've brought in some map data and converted it to individual movie clips, each of which has an instance name that I'd like displayed when each clip is clicked on. ideally an informational box would appear with the name of the clip and some other info that I've specified.
What do I need to script so that if one clicks on a movie clip, the instance name is displayed?
I've got a really weird one here. I have a movie A. Inside movie A, I have another movie 3 more movies B, C, D. B, C, D are all instances of the same movie. Inside this movie is a button, given in an instance name of button. When B, C, D are clicked, they put text inside a text box. The actions for this are assigned using frame actions. The exact action is as given below:
I need to retieve the instance name of a button but cannot do it the same with a dynamic button the same as I can with a component button.For a built in component button the below code would output _level0.buttonName, however for a dynamic button i have created it only outputs _level0.
How do you disable only the MOUSE_OVER event for a an instance of the Button class in AS 3? MyButton.Mouse_OVER = null ; Will not work as it is not a writable property. MyButton.enabled = false Will not work as that disables the entire Button and that is not what I want.
Just wondering how I reference A button that I have within a movie clip, within a movieclip to and instance on the parent timeline.At the moment I am using, but not getting the correct result:MovieClip(parent).NavBar.gotoAndPlay("About");