ActionScript 3.0 :: Giving A Button An Instance Name Via Xml?
Sep 27, 2009I am creating my first AS3 flash site and i am using a menu which gets links from a .xml file
[Code]...
I am creating my first AS3 flash site and i am using a menu which gets links from a .xml file
[Code]...
I'm Loading swf into a movieclip name main_mc. After successfully loading it into main_mc. I had written a function to get all children present in that movieclip(main_mc). It is getting Children present in that, but every time it give [Object MainTimeLine] as instance3 or sometime instance10. How can i control instance name of maintimeline as it is randomly getting its name.... I'm attaching code use in getting child and loading it...
quote:
Clip=new Loader();
var urlRequest:URLRequest=new URLRequest("test.swf");
Clip.contentLoaderInfo.addEventListener(Event.COMPLETE,LoadingDone);
Clip.load(urlRequest);
[Code].....
Ive been using adobe flash cs4 for a while now and have had little trouble giving things instance names. Now though, whenever I double click on something like i normally do to give it an instance name, the blue box no longer comes around it, I click on properties, and change the instance name. I now get a dashed line along the lines of the picture. And when I go to properties, it just says shape, and I cant edit the instance name. Just position and size, then the fill and stroke. What is going on?
View 5 RepliesI have this movieclip that i made in flash. How would I go about duplicating it and giving its parts instance names using AS3?
View 3 RepliesI am making a game where I reference "Player_mc" quite a lot. I have a bunch of full characters (movieclips) in the library that work as the player when put on the stage and referenced as "Player_mc". I need a code that can reference those characters (movieclips) in the library, and move them onto the stage and name them "Player_mc". Also I need a way of removing an existing "Player_mc" so that another character can be referenced and brought onto the stage as "Player_mc". Here is what I have: if (this.P1Character==(Whatever that character's number is)){
View 3 RepliesI have a folder full of SWF files. Each SWF is its own animation. I have several people submitting their animations for this project. I would like to embed all these SWF's into my project and use .play() .stop() and other movieclip related commands on them as a whole. By this I mean, the artist sends me the SWF, my AS3 script embeds it, then I can access it with say animation_1.stop(); without the artist ever having to enter a instance name, or export for ActionScript name.
I plan to create a shell script which will take all the swf's in a folder and create a AS3 file with all the embed statements. The instance name that will be given to each one by the shell script will be the file name. Is this possible to embed a SWF and access it without giving any movie clips instance names or exporting for Actionscript? UPDATE: @annonymously answer below helped a lot. Here are some other resources that helped me: Great Resource - [URL]
I am using the following .as file as the component for an itemrenderer in a list. Basically each item is rendered in a TextInput and each TextInput has a remove button as you can see from the code. When clicking the remove button, I want to remove the selectedItem..so I am putting the function removeItem() in MainMxml.xml and calling it from the .as file.
However I am getting an error "Cannot access a method or property of a null object reference".
The .as file as follows:
package components {
import flash.events.Event;
import flash.events.MouseEvent;
[Code]...
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);
[code].....
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?
View 1 RepliesI have a few buttons rigged up for downloading word.doc, mp3 etc
Problem is its opening the file rather than giving a download this file option.
How do you view and edit a button symbol's instance name after you have made the button symbol?
View 3 Replieson (rollOver) {
butID=1;
butName=this._name;
trace(butName);
}
the third line, is that not it?? When I trace I get nothing. Why do buttons have to act weird...
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.
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.
View 1 RepliesI 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.
View 6 RepliesI 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");
[Code]....
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?
View 4 RepliesOn a button I have this action: [ocde]On press I need to know the instance name of pressed button.I tried [code]
View 0 Replies 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++){
[Code].....
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.
View 2 RepliesI 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.
Code:
peeps.?button?.onRelease = function() {
var peepName = this._name;
trace(peepName);
getURL('javascript:loadVid(cmsflash/'+peepName+'.swf);');
};
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.
View 3 RepliesI 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..
View 4 Replieshow do you access a button inside a movie clip by instance name? i want to add an event listener to the button.
i tried:
Code:
myMovieClip.myButton.addEventListener(MouseEvent.MOUSE_DOWN etc......
and got no errors but at the same time it didnt respond to my event listener
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?
View 4 RepliesI'm so use to timeline code, that this baffles me. How do I get a button class to recognize a button instance on stage?
[Code]...
Error: 1120: undefined property The error indicates it's the mouse event, not my instance name mc. LINK TO THE FILE
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++ )
{
[code]....
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...
[Code]....