In my main file I have pause, resume and replay buttons that
are supposed to control the subfiles. I attach the subfiles
using an array and the following lines of code:
attachMovie("mcMain", "main_mc", 10,
{_x:36, _y:66});
main_mc.loadMovie(lessonPath+urlList[whoIsOn]);
My pause, replay and resume buttons are coded as follows in
my main file:
nav_mc.pause_btn.onRelease = function() {
main_mc.stop();
this._visible = false;
};
nav_mc.resume_btn.onRelease = function() {
main_mc.play();
nav_mc.pause_btn._visible = true;
};
nav_mc.replay_btn.onRelease = function() {
main_mc.gotoAndPlay(1);
pause_btn._visible = true;
};
This works great for the most part. However, I have a few
files that call to other files. For instance I have a review
slide that calls to other slides. The stop, pause and
replay buttons don't control my review piece. In fact, they
completely corrupt my return button in my subfile, so that
when I click them and then click return, the
reviewPiece_mc._visible = false line of code does not take
within the review button. Basically, when I click the
return button from my reviewPiece and don't click pause or
replay, the page works fine. However, if I press the replay
or resume button while I am in the reviewPiece
reviewPiece_mc._visible = false no longer works when it
returns. I hope that makes sense.
Please see my code below that is in my subfile. Any ideas
on why my buttons are having conflicts?
____________________________________________________________
__
import mx.utils.Delegate;
var reviewPiece_mc:MovieClip =
createEmptyMovieClip("reviewPiece_mc",
this.getNextHighestDepth());
var button_mc:MovieClip =
this.attachMovie("mcButton",
"button_mc", this.getNextHighestDepth(), {_x:640,
_y:400});
button_mc.return_btn._visible = false;
reviewPiece_mc._visible = false;
//************* Activate this when final *************\
var filePath:String = "lessonFiles/L1T1/"
//************* Activate to test local ************* \
//var filePath:String = "";
//***********review page ***********\
function review() {
trace(this);
movie = this;
loadMovie(filePath+movie, reviewPiece_mc);
main_mc._visible = false;
button_mc.return_btn._visible = true;
mySound.stop();
}
//*********** Close Review ***********\
function goBack() {
reviewPiece_mc.stop();
reviewPiece_mc._visible = false;
main_mc._visible = true;
button_mc.return_btn._visible = false;
mySound.start();
}
//************* Attach Sound **************\
var mySound:Sound = new Sound();
mySound.attachSound("audio");
mySound.start();
//************ Buttons ******************\
button_mc.return_btn.onRelease = Delegate.create(this,
goBack);
main_mc.test_btn.onRelease =
Delegate.create("L1T1T180.swf", review);
main_mc.fringe_btn.onRelease =
Delegate.create("L1T1T140.swf", review);
_______________________________________________
Flashnewbie chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashnewb
ie
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.c
om
|
I don't know if code gets executed again after play() or
gotoAndPlay(), and I don't have Flash to test, could you
please run a
test for me before I begin to theorize about the timeline
(only to be
wrong again)?
Just add the following code right /after/ where you attached
the
button_mc in your subfile:
var debug = _global.debug;
if( !debug ) {
trace( "ndebug init" );
debug = _global.debug = {};
debug.reviewPiece = reviewPiece_mc;
}
trace( "n****" );
trace( debug.reviewPiece == reviewPiece_mc );
trace( debug.reviewPiece._visible );
trace( this.getNextHighestDepth() );
trace( "****n" );
Please run this and press those two buttons. If it traces
multiple
times, please post the first two or three.
Next, let's give those buttons control over the subclips.
The stop
button, for example, stops the playhead from moving to the
next frame
in your main_mc, it doesn't stop animations playing in that
frame.
Btw, how many frames does the subfile have? Just one?
If you want to stop reviewPiece, the pause button would have
to call
main_mc.reviewPiece_mc.stop(). However, there will be other
subfiles
where you probably didn't call the clip reviewPiece_mc, so
that
complicates things a bit. One way would be to write a custom
stop
function for each subfile that has extra clips in it. You
would have
something like this for your example, in the subfile, plus
something
similar for the other buttons:
this.stop = function () {
reviewPiece_mc.stop();
};
This might also solve your other problem, if you're lucky.
Last, a remark about this:
> main_mc.fringe_btn.onRelease =
Delegate.create("L1T1T140.swf", review);
That's a very nice hack. Some will hate it, others will love
it, and
the kudos goes to you for finding it. But the problem with
those hacks
is that they tend to be confusing, especially to those who
aren't
familiar with them.
Now, what you do is to call a function in the scope of a
String
object. There isn't really anything wrong with that, but if
you want
to pass a value, just do it the normal way:
main_mc.fringe_btn.onRelease = function () {
review( "L1T1T140.swf" );
};
The first two lines of review would become:
function review( movie : String ) {
trace(this);
// movie = this
// ...
The normal way also lets you pass more than one argument,
without
having to do something like Delegate.create( { foo:
"foo", bar: "bar"
}, doSomething ) to then retrieve arguments as this.foo and
this.bar.
Delegate is often useful, but sometimes it's just
unnecessary.
Mark
On 6/13/07, Lord, Susan Ms. (CONTR) <susan.lord jcita.cifa.mil> wrote:
> In my main file I have pause, resume and replay buttons
that are supposed to control the subfiles. I attach the
subfiles using an array and the following lines of code:
>
> attachMovie("mcMain",
"main_mc", 10, {_x:36, _y:66});
>
main_mc.loadMovie(lessonPath+urlList[whoIsOn]);
>
> My pause, replay and resume buttons are coded as
follows in my main file:
>
> nav_mc.pause_btn.onRelease = function()
{
> main_mc.stop();
> this._visible = false;
> };
> nav_mc.resume_btn.onRelease =
function() {
> main_mc.play();
> nav_mc.pause_btn._visible =
true;
> };
> nav_mc.replay_btn.onRelease =
function() {
> main_mc.gotoAndPlay(1);
> pause_btn._visible = true;
> };
>
> This works great for the most part. However, I have a
few files that call to other files. For instance I have a
review slide that calls to other slides. The stop, pause
and replay buttons don't control my review piece. In fact,
they completely corrupt my return button in my subfile, so
that when I click them and then click return, the
reviewPiece_mc._visible = false line of code does not take
within the review button. Basically, when I click the
return button from my reviewPiece and don't click pause or
replay, the page works fine. However, if I press the replay
or resume button while I am in the reviewPiece
reviewPiece_mc._visible = false no longer works when it
returns. I hope that makes sense.
>
>
> Please see my code below that is in my subfile. Any
ideas on why my buttons are having conflicts?
>
____________________________________________________________
__
>
> import mx.utils.Delegate;
>
> var reviewPiece_mc:MovieClip =
createEmptyMovieClip("reviewPiece_mc",
this.getNextHighestDepth());
> var button_mc:MovieClip =
this.attachMovie("mcButton",
"button_mc", this.getNextHighestDepth(), {_x:640,
_y:400});
>
> button_mc.return_btn._visible = false;
> reviewPiece_mc._visible = false;
>
> //************* Activate this when
final *************\
> var filePath:String =
"lessonFiles/L1T1/"
>
> //************* Activate to test local
************* \
> //var filePath:String = "";
>
> //***********review page ***********\
> function review() {
> trace(this);
> movie = this;
> loadMovie(filePath+movie,
reviewPiece_mc);
> main_mc._visible = false;
> button_mc.return_btn._visible =
true;
> mySound.stop();
> }
>
> //*********** Close Review
***********\
> function goBack() {
> reviewPiece_mc.stop();
> reviewPiece_mc._visible =
false;
> main_mc._visible = true;
> button_mc.return_btn._visible =
false;
> mySound.start();
> }
>
> //************* Attach Sound
**************\
> var mySound:Sound = new Sound();
>
mySound.attachSound("audio");
> mySound.start();
>
> //************ Buttons
******************\
> button_mc.return_btn.onRelease =
Delegate.create(this, goBack);
> main_mc.test_btn.onRelease =
Delegate.create("L1T1T180.swf", review);
> main_mc.fringe_btn.onRelease =
Delegate.create("L1T1T140.swf", review);
>
>
>
> _______________________________________________
> Flashnewbie chattyfig.figleaf.com
> To change your subscription options or search the
archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashnewb
ie
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.c
om
>
_______________________________________________
Flashnewbie chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashnewb
ie
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.c
om
|