-
Senior Member
understanding vars
Hi all
This is what I'm trying to do. I want my movie to loop certain frames unless a button is pressed to make the movie play straight through. Then if a different button is pressed it again loops the choosen section. Both buttons are within movieclips on the main timeline. This is what I've tried unsuccessfully
I set a variable in frame 1 on the main timeline
later on the timeline I check that var with this code
Code:
if (fullplay="off") {
_root.gotoAndPlay("slogan");
} else {
_root.gotoAndPlay("ricky");
}
trace(fullplay);
the trace is coming back with 'off' as I'm expecting. However the movie is continuing to ("ricky") instead of looping back to the beginning of ("slogan")
also I have a button that is suppose to set the continue playing but that's not working either, it doesn't change the var. This is my code:
Code:
on (release) {
set (fullplay,"on");
}
I think I've completely misunderstood how vars works, can someone please point me in the right direction or suggest a better way to achieve what I'm after
Thanks in advance
Only after the last tree has been cut down, after the last river has been poisoned, after the last fish has been caught, then will you find that money cannot be eaten. Cree Indian Prophecy.
-
FK's Geezer Mod
fullplay = "off"; is ok to use when setting the variable, when you want to call it, like inside your if statements, use _root.fullplay = "off"; The lifespan of that kind of variable is limited to the frame you write it in, so later on, call it with the path to it, meaning _root.
-
Senior Member
Hi iaskwhy
Thank you for replying.
I just tried your suggestion, this is the change to the code
if (_root.fullplay="off") {
_root.gotoAndPlay("slogan");
} else {
_root.gotoAndPlay("ricky");
}
trace(fullplay);
but it's still continuing on to "ricky" and not going back to "slogan" and my trace is coming back with fullplay as "off"
Is there a better way to set the var? you said
The lifespan of that kind of variable is limited to the frame you write it in
does this imply i should be writing some other kind of var?
thanks again
Only after the last tree has been cut down, after the last river has been poisoned, after the last fish has been caught, then will you find that money cannot be eaten. Cree Indian Prophecy.
-
Senior Member
hey... i thought about the problem your facing.. but i'm not sure if i got you right... anyway i have something to propose.. here we go:
-you have a MC with an instance name: mc
-you have 2 buttons : "button1" and "button2"
in the first frame of the main timline add this code:
then in each button add this code:
Code:
on (release) {
if (playing == 0) {
mc.play();
playing = 1;
} else if (playing == 1) {
mc.stop();
playing = 0;
}
}
and finally add this code to the MC:
Code:
onClipEvent (load) {
this.stop();
}
ofcourse if you want your mc to play when it loads just change the
to:
*edit*forgot to add the source file*edit*
Last edited by AROM; 07-19-2005 at 05:47 PM.
-
Senior Member
Hi arom
Thanks for that, I think it would work, problem is the movie is actually completed but i left the coding til last ...various reasons not least my coding sucks :-) so it would mean completely redoing the whole thing, if i understood you properly. but thanks anyway ... however i jst noticed you used dble == hmm, off to try that
Only after the last tree has been cut down, after the last river has been poisoned, after the last fish has been caught, then will you find that money cannot be eaten. Cree Indian Prophecy.
-
Senior Member
okay brilliant that bit worked .. movie is now doing the loop bit as required. thanks arom :-)
but the button for 'play all' still doesn't work ...
Only after the last tree has been cut down, after the last river has been poisoned, after the last fish has been caught, then will you find that money cannot be eaten. Cree Indian Prophecy.
-
Senior Member
you can find explanation on alot of the signs used in the actionscript dictionnary.
the == is used in condition validation which simply verifies equality.
btw, i dont think you should redo the whole thing.. you can just spend some time before entering the new code by trying to figure out what you should change, a pen and a piece of paper work very well in this case!
good luck
-
Senior Member
the button for play all is supposed to play all what?
-
Senior Member
Hi Arom
sorry to take and run, it had got late and i was dropping off to sleep. The button for playall basically changes the fullplay var to 'on' thus making the movie play along it's main timeline instead of looping each section.
I've tried these codes on the button, which is inside an MC on the main timeline
on (release) {
_root.fullplay=="on";
}
and
on (release) {
set (_root.fullplay, "on");
}
but neither seems to be setting fullplay to 'on'
Thanks for your help
Only after the last tree has been cut down, after the last river has been poisoned, after the last fish has been caught, then will you find that money cannot be eaten. Cree Indian Prophecy.
-
Senior Member
Code:
on (release) {
_root.fullplay = "on";
}
would set the value of _root.fullplay to "on"
if you then wanted to test to see what the value was you would use == instead of =
Code:
if (_root.fullplay == "on") {
trace("it's on!");
}
-
Senior Member
Thanks Catbert
Thats sorted it, tho' i'm sure i used the code like that at some point during testing! who knows maybe i didn't :-)
Would the space before and after the = sign make a difference?
Only after the last tree has been cut down, after the last river has been poisoned, after the last fish has been caught, then will you find that money cannot be eaten. Cree Indian Prophecy.
-
Senior Member
the spaces around the = sign shouldn't make a difference, I just prefer to write it that way
-
Senior Member
well then I'll definetly never know whether i did or did not write that bit of code at any point :-) Except that now it works and it didn't before, suggesting possibly i didn't ho hmm
Anyway Thankyou all for helping me out and fixing my coding, i think i took a little from all of you.
Only after the last tree has been cut down, after the last river has been poisoned, after the last fish has been caught, then will you find that money cannot be eaten. Cree Indian Prophecy.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|