ActionScript 3.0 :: When A Button Is Pressed It Adds Another Movieclip (from The Library)?
Jan 14, 2012
When a button is pressed it adds another movieclip (from the library) to a movieclip acting as a container at the bottom of the screen. This all works fine, and the movieclip is added to the container (directly in the middle), what i need is it to be positioned to the left. Obviously i could change the .x value, but its a little bit more complicated, because if there is already one movieclip there (in the container at the bottom), the next one that is added needs to be 25 pixels to the right of the movieclip already there.
Code:
var bass1:Bass1 = new Bass1();
//navigation
help_bt.addEventListener(MouseEvent.MOUSE_UP,help);[code].....
1. How to make a button that when pressed, creates a movie clip from the library? So let's say there's a movie clip called "Guy". When I press the button, it creates "Guy" at a certain position.
2. I have a shooterish game, and I want different enemies to affect the healthbar differently. So what I have for my healthbar is a 150 frame tween of a healthbar going down. On a basic enemy that deals 1 damage/frame, I have this:
[Code]...
"marine" is my character, and "bar" is the healthbar. So to make it go down multiple frames at one time, the only way I know of is:
on (release){ _root.drew._visible =false; gotoAndPlay(31); } Above is my code which I am using to try and fade out a MC when a button is pressed. The button (and the picture it shows when pressed) are within the same MC. I have placed this MC on the root timeline and given the MC I want to fade out the instance name drew // but still not having any luck making invisible.
{URL] Here I have a movieclip that I want the clip size to change when pressed a button, and change into another size when another button is pressed. but all these, with actionscript movement. How do I...? Here is the fla: [URL]
Adobe Flash CS3 publishing as Flash 8, AS 2.0 I have a movieclip named menu (instance name = mainmenu). Inside of that there is a button named btn_about (instance name = about). On the main stage there is an empty movieclip named empty_mc (instance name = mcholder, linkage id = empty). I want a user to press the button which causes a movieclip in the library named tesst (Linkage name = testid) to load into the empty movieclip (mc_holder).
Here is the code on the button: on (release) { this._parent.mcholder.attachMovie("testid", "tesst1", this.getNextHighestDepth()); } It does not work.
Is there any possibility to combine those two handlers. I want a movieclip changing its scale when a button is pressed. The change I would write as this: onClipEvent(enterFrame) { if (_scale<200) { _scale+=10; }}
But I can't write on (release) { onClipEvent(enterFrame) { ... Is there a way to realize it?
_root.fadeBox_mc.onEnterFrame = function (){ if (fade){ this.nextFrame();[code]....
This causes a mc to fade in and out on rollover/rollout. But what I wanna make is a box that fades in when pressed on the button and fade out when pressed for the second time. But if I say
on (press){ _root.fade = true; }
the mc fades in, but I cant do another on (press) to fade out. Is this too confusing?
I'm trying to create a button that, when first clicked, will add a MC to the stage. Then, on the second and subsequent clicks will remove the existing MC and replace it with a new one. The code I'm using is:
I can find my way in Actionscript 2.0, but 3.0's hell for me. I've been following a bunch of tutorials and I suppose I understand the 'basics', although I'm beating myself over this 'cause most of you will probably consider this basic aswell.
The problem at hand : I made a few movieclips, that have a transparant button on the first frame inside of them, and on layers below it an animation that starts once you click it, then stops at the last frame.
(Example : You see a snail, you click it(but really click the transparant button that's above it) and the movieclip starts playing, showing a snail that crawls back inside it's shell, then it stops. Pretty simple, but it's a fun and easy way to have multiple interactive graphics on a page.)
The task at hand : Somehow make a score system that allows you to see how many of them you've clicked, meaning everytime you click a snail (for this example, anyway) there's a +1 function somewhere.
Currently, inside the movieclip (the transparant button) I have :
stop(); alpha_btn.addEventListener(MouseEvent.CLICK, nextClick); function nextClick(event:MouseEvent):void{ gotoAndPlay(2); }
Which is pretty straight forward. alpha_btn is the button that makes the animation inside the movieclip play. At frame 30, there's a stop(); function.Then, there's the main timeline.
function scorePoints(myPoints:Number):void { if (Number(scoreBoard.text)) { scoreBoard.text = String(myPoints);
[code]...
It works, but only once. After the snail is clicked, I have it looped (no stop(); at the end of the moveclip, but it moves to the first frame again. Meaning, the button's there again and it's clickable again.) but everytime I click it after that, there's no points added to it.So I'll break it down to this : I need simple button that, when clicked, adds a number of points to the scoreBoard.
I've moved a movieclip which is a sort of popup with two buttons on it to the library of a fla. I also have created a custom class for the movieclip and can create an instance of it using var popup1:zeePopup = new zeePopup();
Now I want to access the close button (instance name "closeIt") via the custom class as file but the button seems to have been turned into a Shape after the move into the library of the new fla from the old fla...whatever the problem is, it is not working.[code]...Movieclip button inaccessible when movieclip in library
i have an annoying problem. I have a mc that i use as a button. I have an external class that controls the button and adds interactivity to it, here's part of the code:
The problem is, i want the btn that, when clicked, remain inactive.That's why I remove all the listeners in the class. HOWEVER, it still functions as a button, I mean the functions haven't been removed at all after I click it. What's wrong here?? Why are the functions still there, if I have removed them when clicked at the btn?
Suppose there is a button on stage - on press - I want to [display / start to run] a movie clip present in library (should i place it on stage?) I tried: on (press) { loadMovie("one_mc", "1"); } not working.
How to add a listener to a button inside of a movieclip that is in the library? Example: Root->work_mc(timeline)->workss_mc(added with Addchild) There is workss_mc in the library that gets loaded when someone clicks a button inside of work_mc. This is achieved with addChild. Within workss_mc there is a close button to close this. I've run into problems with working the navigation with this b/c I need to declare and create a single instance of workss_mc at a scope where it is visible to both click handlers, Doing this will place both handlers in one location. So in order to do that I would need them all to be where the navigation code is, the root. So how can I access workss_mc from the root?
how to add a listener to a button inside of a movieclip that is in the library?
Example: Root->work_mc(timeline)->workss_mc(added with Addchild)
There is workss_mc in the library that gets loaded when someone clicks a button inside of work_mc. This is achieved with addChild. Within workss_mc there is a close button to close this. I've run into problems with working the navigation with this b/c I need to declare and create a single instance of workss_mc at a scope where it is visible to both click handlers, Doing this will place both handlers in one location. So in order to do that I would need them all to be where the navigation code is, the root.
i am new to flash AS,i have 4 movieclips, those have the 4 option of a question, when i select the answer,if it correct means my score will increase otherwise it will show alert,for that first i have to press the any one movieclip out of 4 options, in AS3.0 addEventHandler will work for AS2.0 what will i use to achive this
[Code]...
in this answer1, answer2,answer3,answer4 are the movieclip for 4 options
I'm trying to create a set of 4 vertically arranged buttons that 'split' apart when those buttons are pressed. For example, if you click the topmost (1st) button, the bottom three buttons will drop down so submenus (for the 1st button) can now be revealed beneath. Again, when you click the 2nd button from the top, the bottom two buttons drop down, revealing submenus, and so on.
Now, is there a way that I can use actionscripting to tween the buttons to not only motion tween a drop down when a button is first pressed, but also to motion tween the button to return up to its original spot when another button is then pressed? Right now, I have two keyframes, side-by-side which each containing a different y-scale value for an object. Can I do some actionscripting to get the object to motion tween upward to its original spot instead of "clicking," or snapping back to is original spot when another button is pressed?
I want the press button to detect the last button pressed and if the shapes match, make them do something...obviously. I think I'm going at it the wrong way. I need to stick a "triange" id into the button/mc then if compares that and then if there is a match works then... right?
What button event should I use to make the program understands to DO SOMETHING only when the button is pressed/dragged. In my sample code below, I want something to happens only if the button is dragged beyond 200 in y axis. I tried onRelease, onRollOver and onDragOver but still not working
I have a series of buttons inside an array. I am trying to get the buttons so that once they are pressed, they remain in the over state. Which is a darker color than the up state. So that people know which button they have pressed. Is there an easy way to do this for buttons?
I'm creating my first website. I've managed to create a homepage. On the homepage is a enter site button, which once it is pressed starts thetimeline... I have an actions/labels layer which I am writing my code in. On frame number 'one' is my code below.
stop (); enter_site_btn.addEventListener (MouseEvent.CLICK, buttonClicked) function buttonClicked (event:MouseEvent): void
what i want to do is, when certain button is clicked, replace a certain symbol(button) by another symbol(movieclip) stored in the library. i try things like loadmovie("","") to replace the symbol from a external jpg, but some how it does not align even both images are exact dimension. can i replace an image straight from the library?
I've got an problem with reading out an array, the array is filled with movieclips with each an different picture in it (php variable -an url). Basically what i want to do is get the pressed movieclip and use another method to change the _xscale and _yscale properties of the pressed movieclip (an picture) and then pass it back to the function brillenArray.onEnterFrame to change the values of that movieclip!
Only thing what i now get is that either all of the pictures move or none...
[AS] brillenArray = new Array(); for (var i = 0; i<5; i++) { if (this['plaatje'+i] != undefined) {
[Code].....
If i press one of the four pictures it does what i want to: THAT picture scales to 70. But how can i call this movieclip (the pressed one) from another method without using specified place in the array (like brillenArray[1])?
I have 2buttons. Each have 3stages: up, over, down.I want to have 1st button to stay on its 'down state' when pressed and then you should see 2nd button 'up' stage(down stage of 1st button is the same as up stage in 2nd button).If someone hovered again you see 'over' stage of 2nd button,when will click, button move to 'up' stage of 1st button.
this is the code i am using, i get what flash is doing, after i release the key it starts to play the "walking" frames- only i include the gotoAndStop("idle") so it doesn't get to play "walking".but what i am looking for it to do is play the walking only when the key is pressed and stop when released.
onClipEvent (enterFrame) { if (Key.isDown(Key.RIGHT))//68 { this._x += moveSpeed; this.legs.gotoAndPlay("walking");
I had an odd occurance where a listener was firing when I pressed on another movieclip. Both functions executed, which obviously caused some trouble. I fixed the misfiring listener by creating a new child (panel) and then adding the listener's movieclip to panel.
I have done an animation which includes a button that I want to use to start it. I've added action script to stop the animation on the last frame, I just have no idea what action script to put in to start it when the button is pressed. I have 14 layers + an action script layer. 7 of the layers are animated.