ok, i posted about this a day ago in the wee hours of the morning when i was not very comprehensive… and also i want to be able to do it now.
i have a box… it has a text box in it…
it has an X in the top right that i want to be able to minimize the box, which is dragable
im not quite sure how to go about doing the minimize thing…
my earlier drowzy speculation… was a bit… crappy…
the way i see it (in my novice AS depth) we would have the “X” be a button name… ‘minim’. then we have some code that makes it so when the box is up the variable of ‘maximized’ is set to true (or 1) whatever, and when the box is down the variable is false (or 0) whatever. then we have:
//to minimize
if maximized = true
onRelease
set maximized to false
speed = “10”
if y > 0 (or the bottom)
this._y += speed
if y = 0
this._y = 0
//and to maximize
if maximized = false
onRelease
set maximized to true
speed = “10”
if y < 0 (or the bottom)
this._y -= speed
if y = 300 (or maximum height of where i want the box to be)
this._y = 300
obviously this is rough because i am not familiar with AS much at all
recap:
i would like a dragable box that includes text to be able to be minimized and maximized from anywhere on the stage
Basically, you want to tell it that when the user clicks on the X, the Body movie clip will minimize, or hide from view. You can do this by changing the alpha value of the body, or by changing it’s visible property.
I hope this gets you on the right track. I check the MX section more than I do this one…
thx for the post, the part i got by myself was that i needed the X and the box and the dragbar, i was wondering how to group them, can you tell me how?
also, should i make them all movie clips? or should the X be a button?
im kinda lookin for some help with my script, this is all i got so far, and it took me a good 15 min to get rid of syntax errors!
onClipEvent (load) {
var max = “true”;
var speed = “10”;
}
on(release) {
if (max = “true”);
this._y += speed;
if (this._y == 395);
this._y == 395
var max = “false”
if (max = “false”);
this._y -= speed;
if (this._y == 10);
this._y == 10
var max = “true”}
i got all that on the X, which i know is wrong and i also DONT know whats right :trout:
one piece of vital info i forgo to mention, is that the way i want it to minimize is to move along the y axis down to the bottom of the screen so just the tab with the min/max button is up above the bottom of the stage
hope this helps prompt more people to post and help me out
I cannot write this whole thing for you, but I can help nudge you along (just trying to help you out)
in your if statements, you’re using = That is wrong. You always want to use == . When you use a single = it assigns the value on the left to the item on the right. The double == compares the value.
Also, it is helpful to comment your code. This will help you figure out what you’re trying to do, and it will help us figure out what you’re trying to do.
if(fruit==“apple”) // find out if the fruit is an apple
etc…
do that for me and I’ll try to get back to you on the rest. Please be patient. We all have jobs and can’t snap right back with an answer.
As far as grouping.
I would create the movie clips as I mentioned above. After you have the X as a clip and the other clips, then you’re going to put them all on the scene and select them all, and convert the whole thing to a movie clip.
If you call that entire movie clip “window”, then you will be moving the _x and _y coordinates of window to wherever you want to place it on minimize.
window._x = -145;
window._y=0;
(just an example)
if you made a movie clip called “body”, which is inside of “window”, and you made a movie clip called “ex”, which is inside window as well, then you could make body invisible like…
ok, heres an update… i got 4 MCs, one group on the main stage called ‘window’, and within that there is ‘x’, ‘dragbar’, ‘main’ and a text field that is named instanceName_0
on the ‘x’ MC i have the following AS
[AS]
onClipEvent (enterFrame) {
this.onRelease = function() {
_root.window._y += 15;
}
}
[/AS]
btw, what im trying to do is not hide the window… simply move (like a motion tween) the window until just a tab at the top is sticking up from the bottom of the stage
as of now the AS above only moves the window down 15 every time i click, the desired effect is when i click once it moves all the way down.
the only way i cant think of to make it do this is to have…
[AS]
var i==“i+=i”
var speed==i+=i
[/AS]
then…
[AS]
onClipEvent (enterFrame) {
this.onRelease = function() {
_root.window._y += speed;
}
}
[/AS]
or sumthin like that, im not sure how to make it ‘loop’ or continue to move
i have the AS to make it stop… i think
[AS]
if(_root.window._y>385){ //my stage is 400 high so i figured this number would give me some of the window sticking up
_root.window._y==385;
}
[/AS]
heres .swf so far… all it does is drag, scroll text, and when u press ‘minimize’, its moves down 25 pixels… heh, im trying to get it to loop that, and continue to move down 25 until it reaches y==385, but that is confusin me
hawk
the .fla is too large to post, so if you want to help me out, ill emial you what i have, just post ur email
I havent looked at your fla… well, because Im sleepy. I will tell you that you probably want to use a While loop. Check out your reference panel or Actionscript dictionary for it… the format is:
while(condition) {
do something;
}
in your case, you would say
while(position of mc<position desired){
move mc position down;
}
Does that make sense?
The while command will do something while it’s condition remains true. So, it will handle your loop and your stop.
lol, no… hmmmmmm… the only confusin part is where u said… ‘position of mc move mc position down’
could u traslate that to real AS… i know u dont want to do the whole thing for me and by all means i am with you there… but just do this one… when i see it in AS i will probably understand more
there is a tutorial on this somewhere in this site, you should have searched first but here is the basic code…
[AS]window.onEnterFrame = function() {
this._x = this._x-(this._x-newXpos)/1.2;
this._y = this._y-(this._y-newYpos)/1.2;
/the newXpos and newYpos is where you want the
mc to go/
/the /1.2 controls the speed of the mc/
};[/AS]
basicaly what this does is find the distance from your original position to your destination and subtracts it from your original destination. for the inertia to take place, you divide the difference ( / 1.2 ) to make the difference smaller therefore making the object move slower. If we substitute the variable for numbers and leave out the division:
this._x = 10 - (10 - 1)/1.2
= 10 - (9)/1.2
= 10- 7.5
= 2.5
therfore, the movement is a little slower and if we would do another step, we would see that it still would not get to the new position. If we would increase the division, the movement would be even slower because the difference would be smaller.