Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change the property of a button? 1

Status
Not open for further replies.

Bimmel

Programmer
Feb 15, 2002
19
DE
I want to animate a button crossing the screen in a random route.
So, I decided to influence the x_position of the button randomly.
However, the x_position of a button cannot be changed, only the x_position of a movie. But a movie does not have the functions of a button.
So what should I do?
 
You could embed your button in a movieclip.#

Select your button on the stage - hit F8 and convert it to a movie clip. By editing the clip you can still get to the button to make changes but you now have access to all of the functionality of a clip too.
 
I followed your instruction.
The button is now embed in a movie. BUT this is the prob.
I cannot provoke a "on(release)" action of the button.
The mouse cursor changes into a hand, but when I release nothing happens, although I defined a "on(release)" action.

Maybe it's just me who is the mistake ;).
However, I should reconstruct what I wanted to achieve:
- a button jumping around randomly by the use of the x_position property BUT still "clickable" (sorry for my bad english , I do not know exaclty if this word really exists ;P)
 
If you want the movie clip holding this button, to move around with that button's click, you'll have to target that movie clip's instance name. Select your movie clip, and in the Instance panel give itan instance's name like jumper.
Next in the button's script add the following:

on (release){
_root.jumper._x = random(200);
// or whatever else you've been using as an _x value...
}

Regards,
new.gif
 
That's not exactly what I supposed oldnewbie,
probably you wrote your post during I wrote my post. :D

The BIG problem is that a button that IS EMBEDED in a movie does not give me the opportunity to interact with my mouse cursor. This means, my button is frozen or something like that just for an imagination.
 
Not what I wanted exactly, but my main problem is fixed in this example: - I thought of a "bird" (button) flying around like crazy. You are supposed to hit 'em to provoke an event (e.g. go to frame2).
It would be nice if I get to know the way you managed your movie/button/action relation.
So, all you have to do to make me the happiest person on earth is that you post the .fla-file of the nice example you just built. :D

thx
 
surprise, surprise :)

and now the fla-file and everything is fine =)
 
Here's an alternative version that moves more gradually.


The script is all attached to the main movieclip...


onClipEvent (load) {
// set up target on stage
xSpeed = 5;
ySpeed = 5;
_x = Math.random()*200;
_y = Math.random()*200;
}
onClipEvent (enterFrame) {
// check to see if target is past stage boundaries
if (_x>500 || _x<0) {
xSpeed = -xSpeed;
}
if (_y>400 || _y<0) {
ySpeed = -ySpeed;
}
// move target
_x += xSpeed;
_y += ySpeed;
}
 
Was it his intention to move this thing more gradually?

Regards,
new.gif
 
I only please you to send me the fla-file of either the first or the second animation you made:
Bimmel@atwork-clan.de

thx :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top