PDA

View Full Version : how to make a variable = several MC's


MadWilson
09-13-2002, 08:32 PM
Is ther a way to make a Variable calld "test" and every dragable MC That i make = that Variable

Thanks

tg
09-13-2002, 09:33 PM
not sure i understand...
a movieclip is an object
a variable "test" is a string
you cant make a movieclip a string.

you can set a variable inside your mc to equal the variable on the main timeline, if thats what you want to do.

??? post more info.

MadWilson
09-15-2002, 05:21 PM
I didn't mean for the Test to be taken as a string so here is my code

Test = MyMovieClip;

and then make a second MC have the same variable but act as its own MC.

Thanks

flx
09-15-2002, 07:34 PM
Still a bit puzzled.. but then i'm just a newbie so i'm always confused.. :confused:

Perhaps if you explain the reason for the variable "test" it may make the answer to ur problem a lil clearer.

Hope to hear from you soon... :)

MadWilson
09-15-2002, 08:18 PM
The reason for make every MC that you can drag = to The variable Test so that when you go to drag the MC your constraning actons will work for every MC that you have on the screan.

The constraning box is not found in side the button it is on the main time line and it is looking for a sertin variable the variable is "Test". with out this "Test" you can drag the MC all over the screan and i don't won't that.

thanks

Odoacer
09-16-2002, 03:24 AM
well im not sure if this is what you want but you can give a MC a name and dictate the MC's actions through that name.

You can make it so that if your MC affects your variable "test" - say, changing it from "true" to "false" or whatever. And when "test"'s T/F state changes, you can impose movement restrictions on your MC.

Two MC's cant have the same name but you can control both of them through one function.

I hope thats what you were going for.

flx
09-16-2002, 08:54 PM
If my understanding is correct the answer to your problem lies within the first 'reply'.
As tg said...

tg - you can set a variable inside your mc to equal the variable on the main timeline


My flash isn't working properly at the moment so i cant check the exact code.. but the basics of what you'll have is:

On the main time line

// how far left you want the MCs to go
Left = (input number here)
// How far right you want the MCs to go
Right = (input number here)
// Top value - u get the idea
Top = (input number here)
// Bottom value
Bottom = number


The code for the button within the MCs


on (press) {
//left /right constraints
if (this._x <= _root.Left and this._x >= _root.Right) {
startDrag (this, true);
// top/bottom constraints
if (this._y <= _root.Top and this._x >= _root.Bottom) {
startDrag (this, true);
}
}


This code is made up off the top of my head.. it may work... but i doubt it will 100%

Basically though.. the limits are set by the variables in the timeline (Left,Right,Top,Bottom) and the code within each movie clip targets these variables and uses them. This method will allow you to simply copy and paste the code into the button of each MC and easily change the constraints for all the MCs by simply altering the variables in the timeline.

Hope this makes sense.. but above all... i hope it helps! :)

As mentioned before - i'm still relatively new to actionscripting (also confined to flash 5 actionscripting for the moment) so any experts plz do correct my errors.