Skip to main content
Participating Frequently
April 18, 2007
Question

Height Change in Actionscript

  • April 18, 2007
  • 8 replies
  • 589 views
Can someone please tell me how to change the height of a button or movieclip in actionscript. thanks.
This topic has been closed for replies.

8 replies

StickilerAuthor
Participating Frequently
September 12, 2007
StickilerAuthor
Participating Frequently
May 5, 2007
I have a problem with the duckshoot game. The ducks all have the right code and everything but only the first 2 ducks change size. What am i doing wrong
April 23, 2007
I've had a look and done some work on it to make it easier for you. All the code is on the code layer on the timeline.
Your best bet is to do a few simple tutorials on actionscript, and work from there really, just remeber its easier of you keep all the code in one place.

www.actionscripts.org is a reasonable place to start.

Link to New Duck Shooting Galllery.fla

Anyway, hope that helps, Ade
Inspiring
April 23, 2007
I took a quick look at your fla, if I get time later on and someone else hasn't already answered , I'll get it working.

From a quick glance, you have multiple 'ducks' that you want to apply the onPress event to, and none of them had instance names. Best to give them names like duck0, duck1 etc. You would need to use a loop to set up the onPress handler for each duck to make the coding easier.

Also it appears that something in the parent hierachy is a graphic symbol and not a movie clip. I've never done this and so don't know if its a problem, but I would only ever use movieclips in the parent chain. [others may know if this is possible with a graphic symbol]
Inspiring
April 19, 2007
Well it will work if everything is done right.

2 things to check:

Make sure you change the myInstanceName to the same name of the button or movieclip that you you have assigned in the property inspector. If you see a greyed out <Instance Name> in your property inspector, then you need to put the name there first... use no spaces and no weird characters.

And make sure that the actionscript is in a frame, and not attached directly to the object (you should see a little 'a' appear in the frame in the timeline where you put the code).


You can't upload files here, you can post a link to your fla if you put it somewhere accessible via the web.

You can also post some code snippets using the attach code button here.
StickilerAuthor
Participating Frequently
April 23, 2007
i did that but it still doesn't work. this is the fla.
http://www.mediafire.com/?ehgjn2o03my
Inspiring
April 23, 2007
One note. I sometimes spend a lot of time debugging to just duscover that I have several instances with the same name assigned to different instances. Make sure that you don't confise ActionScript.

Another thing is that if your button or clip are created at runtime -- they react to resizing differnetly from the ones that are placed before.
StickilerAuthor
Participating Frequently
April 19, 2007
It Still doesnt work
im trying to build a game for a friend.
how do you upload files to this forum???
StickilerAuthor
Participating Frequently
April 19, 2007
But what if i want it to change to 20 pixels when i click on it
Inspiring
April 19, 2007
Then you could use (again in a frame action where the button or movieclip exists in the timeline):

myInstanceName.onPress = function() {
myInstanceName._height = 20;
//you could uncomment the following line if nothing else will change its height at any other time (so this only happens once):
//delete myInstanceName.onPress
}
Inspiring
April 18, 2007
Make sure you know the instance name of the movie clip or button (and the relative 'path' to it if you're not issueing the command from the level of its parent).

Actionscript versions 1 & 2:

e.g. if your button exists on the current timeline and its called myInstanceName in the property inspector, then just use

myInstanceName._height = 20;

as an actionscript command on a frame where the button or movie clip exists in the timeline. (if you want to make it 20 pixels high)