Flash :: Make Button Click Event To Call A Function Which Set Another Label Text?
Jul 28, 2010
i am not an action script developer nor flash designer, i just want to have a small action script sample that i will edit a little to make it interact with my javascript code. By the way, i want to have a button and a label on a flash form, when the user clicks on this button the onclick event will call another function 'setText for example' this setText() function will change the label text. So i think the code will be something like this:
[Code]....
I managed to put the button and the label i want just the code i will write to make this work.
Im thinking this is easy but i cant figure it out. See attached file. When the side button is clicked and the user chooses the red or blue button, I want the color name that was chosen to show up and replace the word gray under the side button.The gray Dynamic text box under the side button has an instance name of myCurrentSideColor.
Below is my code. import fl.events.*; var currentObject:MovieClip;
I have created a linkbar with two labels. Now, I need to keep a track of the label clicks.i.e. If in the beginning "First" is clicked, the details will be displayed. After that, if without submitting the details, "Second" is clicked then an alert message should come to inform the user that "First is still in progress, do you want to cancel and begin Second operation". Vice-versa for Second to First transition. I need to know how to write events to keep track of which button clicked.
I'm moving on to my next massive programming project and I'm trying to decide whether I should code it in as 2.0 or 3.0. I came across the new click event model in 3.0. Right now it's looking like a pain in the butt to me. So now I have to make a function and add it as an event listener? what the hell? What's the benefit? I understand stuff like this makes AS a more complete language but it's kinda annoying.
How to make my own button with a text label on it?
I've done the following:
created the button background and added the TextField on it called txt and packed it all to Button called MyButton. I added an instance of MyButton called btn to a stage and wrote in the main class: trace(btn.txt.text); - everything was fine. But when I added states of the button (Up, Down, Over and Hit) the txt field of buttons became null.
I am still new to swish and flash and the script confuses me at times. I am doing it more for a hobby and to create interactive programs for my daughter to help her learn. I have made a parking ticket machine to help her tell the time and to count money. The problem I am having at the moment is that I am trying to make one button add 30seconds to a text box total every time it is clicked (for example click1 = 00:30, then click2 = 01:00, then click3 = 01:30 and so on). The problem I am having is that I have made an else/if statement to do just this but every time I click the button it just jumps to the last else/if and shows that total. I am trying to think logically but I may be making things more complicated or maybe the scripting is wrong and I need to try something else. Here is the script I have made for you to see and hopefully someone can tell me what I have done wrong.
I have a button to increase the scale of few items. It's suppose to increase the size with every single click. When I click the button continuously having the mouse unmoved and over, it wont increase the size. But if I rool out of the button between every click, then I works. I need to make button function with every click.
CURRENT CODE: on (press) { if(this._root.gmb_mc.rotate_mc3a._width <= 50){ this._root.gmb_mc.rotate_mc3a._xscale += 7; this._root.gmb_mc.rotate_mc3a._yscale += 7; }}
I have a map of the US and each state has a rollover that changes the color of the state...what i am trying to figure out is how to click on the state and have text appear to the side of the US map and have that text stay up until the user clicks on another state.
I've a grid view in flex, one of the columns is rendered like this:
[Code]....
now I've a problem that the function in button click is not being recognized. It says "call to a possibly undefined function" even though it was defined. What is wrong with this? How do i make a button in a grid call a function in the same mxml file??
I cant because it runs off a VideoEvent, not a MouseEvent.The obvious work around is to copy and paste the function and rename this part, or alternativly just make a function such as:
Code: button.addEventListener(MouseEvent.CLICK,callMyVideoFunction); function callMyVideoFunction (event:MouseEvent) { myVideoFunction(null);[code].....
I'm having trouble simulating a click call to a button(displayObject) thats generated via an API call( youtube as3 API). I have not seen any mention of security reasons as to why I can not simulate a click as long as something is registered with a click handler. Basically I checked to make sure the button made is listening to a mouse click event with:
trace(generatedButton.hasEventListener(MouseEvent.CLICK)) which returns true
I proceed to than call this:
generatedButton.dispatchEvent( new MouseEvent(MouseEvent.CLICK, true) );
And nothing happens yet if I physically click the button it works. Is there some security measure that prevents something from being fake clicked unless its origin is strictly from the system mouse?
I even set a timeout call on the click function and moved my cursor over the button and let it fire in case it was an issue of the mouse having to over the object but still nothing. I am kind of stumped at this point.
I'm trying to create a flash animation similar to this one and I want my text box to appear when the mouse is Down. I've created Whitebox and Text Layer but the problem is that they only appear when I make the click then dissapear immediately. How do I make the text box stay on the screen until another button is clicked?
What is the best (or the only way) to get a button in actionscript 3 to when clicked (released) jump to a specified frame label. I've seen a fair amount of little tutorials out there that can tell you how to link to a URL but not within the flash file itself.
I just started playing around with as3 and I have a function for mouse clicks that draws a shape on each click. However the mouse click event does not appear to work unless I click a movieClip object I placed in the middle of the screen. Is there a way to make the mouse click event recognize when I click anywhere on the screen?
Once the product summary label is loaded I would like to call my method setLabel to set the value of the label text. This should be really easy but cas the parameters of the method are "e: Event" I haven't been able to do "setLabel()" or "setLabel(e: Event)" and addEventListener doesn't seem to work either.
public function drawProductSummaryLabel() : void { // Create a holder that will contain the footer label. var productInfoHolder : Sprite = new Sprite(); // Add the holder to the stage. addChild(productInfoHolder); [Code] .....
I have several stage event handlers to enable mouseovers over several dynamically generated moviecilps on the stage that then change their alpha to indicate the mouse is over that particular mc... fairly trivial (mcOver handler). Additionally, I also want to know what MC is clicked, so I update a public variable (public var activemc:Number) with the ID of the dynamic movieclip when the mouse is over it (using a hitTest to check, which is why the EventListener is added to stage and not to the MC), which is checked in the mcClicked handler:This is in the constructor:
However, the mouseover behaviour (alpha 0 when over, alpha 1 when out) stops working as soon as I click on any movieclip on the stage, and the mcClicked ID checking (below) stops working completely. I don't know if this is to do with focus:
private function mcClicked(event:MouseEvent):void { myTextField.text = String(activemc); // activemc is a public var:Number with the movieclip //ID }
I then tried adding the event handler for the stage mouse_move again and this gets the mouseover working again but only for 1 more click, after which it stops again:
private function mcClicked(event:MouseEvent):void { myTextField.text = String(activemc); // activemc is a public var:Number with the movieclip //ID stage.addEventListener(MouseEvent.MOUSE_MOVE, mcOver);
what i mean is, is there a way in AS3,or in programming in general(php, js etc) to make an event fire/ activate "WHEN" something does something, as oppose to an if/else if / else statements ?for example, say i want to make an event fire /activate ONLY when a frame label is hit, and thereafter , do something else etc, essentially making it do things one by one down the line according to WHEN certain objectives are met. is there a "when" type of statement etc that will do this as oppose to if/else if etc??? for example, using the above example, instead of me doing something like this:
Code: xyz.addEventListener(Event.ENTER_FRAME / or INIT , btn); function btn(e:Event):void{ if ( externalSwf.currentFrameLabel == " label here "){[code]...
i have a little project im working on (smooth transitions of external swfs code) that is partly working but i cant for the life of me, figure out how to implement a structure like what i have directly above.