PDA

View Full Version : set property button


rupa
07-31-2003, 01:20 PM
Hi there!


(Flash 5)

I made several buttons for set property.

for example

************************

on(release){
with (c4){
_x +=10;

}
}

************************

how to do that on each release the CM will +=10
but if the button will be pressed (without release)
the value 10 will be moltiplicated ? (10,20,30.....).
So that pressing the button for a while will give
the same result as clicking the button 10 times?



Sorry for my bad english.

Thanks Rupa

freddycodes
07-31-2003, 01:58 PM
On your instance of c4 place this code.


onClipEvent(load) {
this.speed = 10;
}

onClipEvent(enterFrame) {
if(this.moving) {
this._x += this.speed;
}
}



And on your button place

on(press){
c4.moving = true;
}
on(release){
c4.moving = false;
}

rupa
07-31-2003, 02:22 PM
Hi Freddycodes,

thanks for your reply.
I try your code and it works!
The problem now, is that I have 24 Frame in each frame I have one CM and

12 buttons setting different property

_x +=10;
_x -=10;


_y +=10;
_y -=10;


_xscale +=10;
_yscale +-=10;


_xscale -=10;
_yscale -=10;


c4._rotation += 10;

c4._rotation -= 10;


_alpha +=10;
_alpha -=10;


the onClipEvent will works for all 12 buttons?

What I should write instead :

c4.moving = true;

for the other properties?

When I create a new CM
I must change the clip name for each button


with (c8){
_alpha -=10;

}
}

with (c9){
_alpha -=10;

}
}

..........

Do you think it is possible to write a code
for avoid this work?


Thanks again

Rupa

freddycodes
07-31-2003, 02:36 PM
Are the buttons going to affect all the clips, or are there a set of 12 buttons for each clip.

Anyways this should mkae it a little easier.


on(press){
c4.prop = "_alpha";
c4.val = -10;
c4.action = true;
}
on(release){
c4.action = false;
}


And on the mc


onClipEvent(enterFrame) {
if(this.action) {
this[this.prop] += this.val;
}
}



So the button could be changed to any prop and value combo like

on(press){
c4.prop = "_xscale";
c4.val = 10;
c4.action = true;
}
on(release){
c4.action = false;
}

rupa
07-31-2003, 08:06 PM
Hi,
thanks again for your attention,
for me it is difficoult to write how is the file,
so I posted here:

http://www.rupak.net/working/es/FlashViewer.htm

an example,

please take a look.

Thanks Rupa