Ref functions on main timeline within MC
Does any one know of a way I can call a function thats set up on the main timeline using AS in movie clip thats a child of the timeline?
IE:
I have a function called setName(); on the main timeline.... I also have a movieclip called contact_mc and I need to add EventListeners within the contact_mc that would some how call the setName(); function thats in its parent timeline... Any advise you can offer is apperciated!
try:
MovieClip(this.parent).setName();
to reference the movieclip. i'm not sure what events you want to trigger that function call.
Similar Messages
-
Call function in main timeline from class file
Hi all, How can a function in main timeline be called from class file?
Hi all, How can a function in main timeline be called from class file?
You can, but you really shouldn't.
Classes shouldn't "talk" to the outside directly.
Use Event dispatching to get things done.
"root" (i just threw up by just typing that word) should be avoided at all cost, especially in AS3. -
How to remove a function on the main timeline within a movie clip
How do you remove a function that is coded on a frame in the main timeline from within a movie clip? I tried this, but no dice:
infoGraphicDisparity.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene);
function fl_ClickToGoToScene(event:MouseEvent):void
parent.removeEventListener (Event.ENTER_FRAME, parent["enterFrameHandler"]);
MovieClip(this.root).gotoAndPlay("disparity");
this is the event I am trying to remove:
stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
any help would be appreciated as always.
Thanks!from any frame (that executes after enterFrameHandler is defined) in any display object in the display list
stage.removeEventListener(Event.ENTER_FRAME, MovieClip(root).enterFrameHandler); -
Use button on mc to perfrom function on main timeline
I Was wondering how (or if it is posiible) to use a button I
have in a movie clip to perform a function on the main timeline.
Specifically, I want the button in the movie clip to gotoAndStop on
a frame in the main timeline. Any suggestions?Hi,
Then you would target the movie clip.
So you would give the mc an instance name (like myClip_mc )
then just add this into your code ....
button1.onRelease = function() {
_root.myClip_mc.gotoAndStop(20);
This would tell the myClip_mc to stop on frame 20. Providing
the mc is located in the main timeline that is.
You can see from the code that we are going to the _root and
looking for the myClip_mc. If it is held within another mc (say
Holder_mc) then the code would change to
_root.Holder_mc.myClip_mc.gotoAndStop(20;
for cs3 (actionscript 3) it would be this
button1.addEventListener(MouseEvent.CLICK,clickHandler);
function clickHandler(event:MouseEvent):void{
_root.myClip_mc.gotoAndStop(20);
Hope this helps
Alan -
How to add button inside move clip and call it from main timeline?
Hi,
On the main timeline I have a movie clip called clock_mc and playBtn
playBtn is placed in the center of clock_mc
When you press playBtn clock_mc starts playing
playBtn.addEventListener(MouseEvent.CLICK, playClock);
function playClock(event:MouseEvent):void
if (event.target == playBtn)
clock_mc.play();
playBtn.visible = false;
trace ("play button was clicked");
This is working fine for me.
But I want to add replayBtn to the last frame of clock_mc and set up the function on main Timeline.
Another words when the clock_mc rich last frame you see replayBtn.
code example:
replayBtn.addEventListener(MouseEvent.CLICK, playClock);
if (event.target == replayBtn)
clock_mc.play();
replayBtn.visible = false;
trace ("replay button was clicked");
I've tryed to placed the replayBtn on the stage on the main timeline and I've set it up to replayBtn.visible = false;
And then I add replayBtn.visible = true; to last AS frame of clock_mc but it wont work
Even when I put the button physically to the last frame of clock_mc it will not work either.
Please helpI've solved the problem:-)
I've set replayBtn.visible = false; on first frame of clock_mc
and replayBtn.visible = true; at the last frame
and than as you sugested I'v add:
clock_mc.replayBtn.addEventListener(MouseEvent.CLICK, replayClock);
function replayClock(event:MouseEvent):void
clock_mc.play();
trace ("replay button was clicked");
I couldn't see replayBtn at the firs stage because I have clockTween assosiated with clock:
clockTween = new Tween(clock_mc, "x", Regular.easeOut, -469,438, .5, true);
and I had replyBtn in the wrong place so when clock_mc was coming up on the stage replayBtn was on the left side of the stage :/
Now I have to solve only one thing.
Maybe you would have any suggestions please.
I've set up stop(); in a first frame of clock_mc
that when you see clock_mc sliding in it has to wait for playBtn to be clicked
because I have two tween:
clockTween = new Tween(clock_mc, "x", Regular.easeOut, -469,438, .5, true);
playTween = new Tween(playBtn, "x", Regular.easeOut, -720,514, .5, true);
playBtn.visible = true;
so when you click on playBtn:
function playClock(event:MouseEvent):void
if (event.target == playBtn)
clock_mc.play();
playBtn.visible = false;
trace ("play button was clicked");
everythink is working fine except when I clik on replayBtn it play for I sec because there is stop(); on the first frame of clock_mc -
How do I set a variable on the main timeline from within a symbol?
Just getting started with Animate and coming to it from Flash, as may be apparent from my question. How do you set a variable to the main timeline from within a symbol?
I have 24 pairs of clickable elements, each in their own symbols, and all 24 of those symbols sit inside another symbol. I want all 24 to be able to set the same global variable when clicked. I can't find that this question is addressed anywhere, which makes me think I may be stuck in a Flash mindset and approaching the task in the wrong way. (There are however MANY discussions of how to address objects at different levels in the hierarchy. That's well covered.)
Relatedly, how do you access a function on the main timeline from within a symbol?
Adobe should consider putting together a support page (or pages) just for folks migrating form Flash. In the materials I've encountered so far there seems to be a studied effort to refrain from mentioning Flash in any way. I imagine there are a lot of people out there like me who have a deep background in Flash coding, but are just getting started with Animate. We don't need help with most of the basic concepts, but we may still have some pretty basic questions about how to accomplish some things in Animate because our Flash knowledge is getting in the way.Hi Bill,
There are plenty of threads on here about scope, but here's one way to create a global variable:
// code on Stage.compositionReady
sym.myGlobalVar = 1;
Then, anywhere in your project, you can check/set that var like so:
sym.getComposition().getStage().myGlobalVar = 2;
And here's one way to create a global function:
// code on Stage.compositionReady
sym.myGlobalFunction = function(){
console.log('myGlobalFunction');
Then, anywhere in your project, you can call that function like so:
sym.getComposition().getStage().myGlobalFunction(); -
Play animation on main timeline from within a mc
this is probably the most basic question of the day, but how
do you get the main timeline to play from within a mc?
say I have a mc called jolly_mc and within it is an action on
it's timeline at keyframe 10. That action needs to jump to a
certain frame on the main timeline and play.
I've tried
_level0.gotoAndPlay(492);
_root.gotoAndPlay(492);
_level0.gotoAndPlay("animation");
_root.gotoAndPlay("animation");
and non of these work, can anyone clear the haze in my day :)
thanks in advance._root.mainText = "Obtain 0.2 grams of Ascorbic Acid using the
Spattula.";
This line is fine. It's fine to have full-stops inside a
string. It doesn't effect the code.
this._root.bkg.gotoAndStop(3);
Your pathing is a little strange in this line. As you can't
go any further up the hierarchical tree than _root, if you're
referencing objects via the root, it should be the first object in
the target. So if you want to refer to your target using an
absolute reference(ie by using root) then your line should read:
_root.bkg.gotoAndStop(3);
alternatively, since your AS is in a movieclip inside bkg,
you can refer to your target using a relative reference like so:
this._parent.gotoAndStop(3);
this._level0.bkg.power.powerOne.gotoAndStop(2);
similar story here. _level0 is the highest up you can go, so
putting this before it is a little strange. Fixing this using
absolute referencing:
_level0.bkg.power.powerOne.gotoAndStop(2);
or:
_root.bkg.power.powerOne.gotoAndStop(2);
or relative referencing(assuming the movieclip where the AS
is is not power):
this._parent.power.powerOne.gotoAndStop(2);
if it is power then you could have simply written:
powerOne.gotoAndStop(2);
yes, the syntax you suggested for trace is correct.
but anyway, i don't think that any of this advice is helping
you with your problem. sorry i can't see the solution with the
information you've provided. maybe upload?
how'd you go with sourcing a flash book? -
Okay so I am unfortunatly new to AS3, so I apologize if there
is a very obvious answer to this question.
Okay Say I have a movie Clip on my main timeline and with in
that movie clip is a button. That button has a CLICK event that I
want o go back and refer to a "frame" on the main time line. How
would I go about doing that?
Here is what I thought I should do
import flash.events.MouseEvent;
WebSitesBtn.addEventListener(MouseEvent.CLICK,WebDesignBtnClick);
function WebDesignBtnClick(event:MouseEvent):void{
_parent:gotoAndStop("Web Design");
"Web Design" is the Frame Label which I want to refer too
Any ideas on what I am missing or how I can properly refer to
the main time line?
Thanksuse parent, instead of _parent, if that code is in your
movieclip. -
How to call a function in a class from the main timeline?
Hey Guys
I have a project in Flash with four external AS files, which are linked to items in the library using AS linkage.
What I want to do is call a function in one of these files from the main timeline, how would I go about doing this? I'm not currently using a document class, most of the code is in Frame 1 of the main timeline.
Thanks// change type to the class name from the instance
ClassNameHere(this.getChildByName('instance_name')).SomeFunction(); -
How to control the main timeline from within a symbol?
I have a small world map as a symbol called "verden" and I want the user to click Europe, Asia, or Africa and jump to named labels in the main timeline.
http://www.dagbladet.no/grafikk/neshorn/neshorn.html
On the main timeline a have the label "intro" with a Stop action and the label "europa". At label "europa" I have a symbol also called "europa" which has a display of None at label "intro" and On at the label "europa".
The animation never goes to label "europa"
I have this code on europa in the symbol "verden" :
// insert code for mouse click here
sym.getComposition().getStage().getSymbol("europa").play("europa");
The files are on Dropbox here
Update, now it works:
sym.getComposition().getStage().play("europa");Hi Bill,
There are plenty of threads on here about scope, but here's one way to create a global variable:
// code on Stage.compositionReady
sym.myGlobalVar = 1;
Then, anywhere in your project, you can check/set that var like so:
sym.getComposition().getStage().myGlobalVar = 2;
And here's one way to create a global function:
// code on Stage.compositionReady
sym.myGlobalFunction = function(){
console.log('myGlobalFunction');
Then, anywhere in your project, you can call that function like so:
sym.getComposition().getStage().myGlobalFunction(); -
Execute functions in document class when main timeline reaches a frame
Hi,
I have 3 functions in my main document class that I want to execute when the main timeline reaches a particular frame number.
how do I do that?
see the code and comments
public function mainClass()
//stage declaraction
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, stageResized);
//wrap these next 3 lines in an if statement that says if maintimeline currentframe = x
position();
loadXml();
initArrowButtons();
slideTimer = new Timer(timer_delay);
slideTimer.addEventListener(TimerEvent.TIMER, nextSlide);It's still undocumented, but something like this would do it:
package
import flash.display.MovieClip;
public class FrameScript extends MovieClip
public function FrameScript()
addFrameScript( 3, frameFour );
private function frameFour():void
trace( "you have reached Frame 4" );
You can test this as a documentclass. -
Forcing a symbol within a symbol to play out when a button on the main timeline is clicked?
I have a buttons that play to symbols on the timeline. Once another button is clicked on the timeline the symbol will playout then start playing the next symbol. This is the code used on the onClick event on the introduction button.
var current = sym.getVariable("current");
if (current != "") {
sym.getSymbol(current).play("out");
sym.getSymbol("intro").play("in");
else {
sym.getSymbol("intro").play("shortIn");
sym.setVariable("current", "intro");
The problem I'm having is with the technology symbol. I have buttons within this symbol that link to other symbols. I would like these symbols to playout like the other buttons, but the content of the symbol stays on the stage and does not play out when I select a button on the Stage. Here is the code I have on the click event on the button within the symbol.
var current2 = sym.getVariable("current2");
if (current2 != "") {
sym.getSymbol(current2).play("out");
sym.getSymbol("optical1").play("in");
else {
sym.getSymbol("optical1").play("shortIn");
sym.setVariable("current2", "optical1");
Any help would be greatly appreciated. Thank you very much!Thank you very much for responding so quickly! When I do this all of the nested timelines play from the out label on their timeline. I want the one that is currently being viewed to be the only one that plays out, not all of the symbols within the symbol. Here is the code I'm using on the buttons on the main timeline:
var current = sym.getVariable("current");
if (current != "") {
sym.getSymbol(current).play("out");
sym.getSymbol("spec").play("in");
else {
sym.getSymbol("spec").play("shortIn");
sym.setVariable("current", "spec");
var techSym1 = sym.getSymbol("tech").getSymbol("techSym1")
if (current = "techSym1") {
sym.getComposition().getStage().getSymbol("tech").getSymbol("techSym1").play("out");
var techSym2 = sym.getSymbol("tech").getSymbol("techSym2")
if (current = "techSym2") {
sym.getComposition().getStage().getSymbol("tech").getSymbol("techSym2").play("out");
var techSym3 = sym.getSymbol("tech").getSymbol("techSym3")
if (current = "techSym3") {
sym.getComposition().getStage().getSymbol("tech").getSymbol("techSym3").play("out");
var techSym4 = sym.getSymbol("tech").getSymbol("techSym4")
if (current = "techSym4") {
sym.getComposition().getStage().getSymbol("tech").getSymbol("techSym4").play("out");
var techSym5 = sym.getSymbol("tech").getSymbol("techSym5")
if (current = "techSym5") {
sym.getComposition().getStage().getSymbol("tech").getSymbol("techSym5").play("out");
var techSym6 = sym.getSymbol("tech").getSymbol("techSym6")
if (current = "techSym6") {
sym.getComposition().getStage().getSymbol("tech").getSymbol("techSym6").play("out");
If just techSym1 is being shown on the screen I don't want techSym2 and all the others to be shown going out at all, just techSym1.
Thank you,
Kristin -
Trying to make the switch from AS2 to AS3 and like many
before me, becoming confused.
I've laid out three movieClips on my main timeline (named,
"main") and spaced them five frames apart, nice and tidy, like I
like to do. Each frame on the main timeline containing a movieClip
has been given a unique frame label. My problem is, I want to have
the movieClips jump to the next targeted movieClip on the main
timeline after clicking a button, or upon entering the last frame
of its predecessor, in some cases. In AS2 the was easy to do this
was by using the gotoAndPlay function and targeting to the_root
timeline. Now I can't figure out what to do. I can make any button
inside a movieClip target a specific frame within that same mc, but
cannot make a jump to the main timeline to play the next movieClip.
What am I missing here? I'm a noobie at AS3 and fumbling my
way forward. (should be obvious now) Is there a simple way to refer
back to the main timeline, which is only one level up? What am I
missing?
Here's as far as I got with the AS3 code within the mcs:
stop();
cont5_mc.addEventListener(MouseEvent.CLICK, onClick2);
function onClick2(event:MouseEvent):void
trace("test");
cont5_mc.buttonMode = true;
The trace function runs true so it's a matter of telling the
player how to get to the main timeline and frame label.
TIA for your help, all you flashy genius . . . Speak to me
like I am a three year old. -grin-
thokittskglad:
Thank you for your instant reply. I see you sent it out last
night. Really appreciated. Got my button in movieClip1 to refer
back to movieClip2 on the main timeline with your help but now am
presented with the issue of having the last frame of movieClip2
automatically taking the viewer back to the main timeline to begin
playing movieClip3, located on frame label "gsm".
Again, I know this should be easy, but conceptually I am
having a problem with how to do this. I don't have a button to
attach the AS3 to and this new syntax is confusing to me. Nor do I
want this to be a button based decision on the viewer's part. How
do I attach this automatic jump back to the main timeline, frame
label "gsm"? By an enterFrame event, which seems old school AS2? or
stage.addEventListener? Is enterFrame even the way to do it
anymore?
Lynda.com tutorials are great but I'm struggling with this.
TIA
Thomas -
I am making a website based in flash actionscript 3.0 i have a button nested in its own movie clip, because I have the button expanding to be able to read it i have figured out the only way to do this is by creating it as a movie clipa nd inside the movie clip creating it as a button
I added an event listener to the blog button by saying,
blog.addEventListener(MouseEvent.ROLL_OVER,gotoblog);
function gotoblog(evtobj:MouseEvent){
gotoAndStop(2)
this part of the code works it goes to the 2nd frame of the timeline it is in and stops wich is a blown up version of the origanal symbol
i added on frame 2 a second command
blog.addEventListener(MouseEvent.CLICK.gotoblogpage);
function gotoblogpage(evtobj:MouseEvent){
gotoAndStop("blogframe")
trace("the blog button was clicked")
i have named the symbol blog and have name the frame of where the blog page is going to be "blogframe" this line of code at the bottom is where i run into trouble the output window in Flash is saying "The blog button was clicked" just like i want it to. no errors are accouring why than is the playhead not going to frame "blogframe"? if the button is working when i click it the code is right i belive the problem here is it does not want the playhead to go to the frame i want it to. So i gues my question is, how can i make a button withing a movie clip interact with the main timeline?I have a similar problem if could please help me i'd really apreciate it!!
So i have a looping animation of some thumbnails, the hierarchy goes like this
Scene1(main timeline) -> imgBar(MC)->imgBarB(MC within the imgBar MC)
My buttons symbols are in the last MC "imgBarB" where i have this code:
ss1.addEventListener(MouseEvent.CLICK, OneButtonClicked);
function OneButtonClicked(event:MouseEvent):void{
MovieClip(root).gotoAndStop("ssbox1");
I want to control the Btns in my "imgBarB" MC to play a labeled frame(named "ssbox1") on another MC on the main timeline,this other MC goes like this:
Scene1(main timeline)->ssbox_mc(MC where my labeled frame is) -
Can't get button in sub movie to link back to main timeline
Hi All.....
First, thank you for helping me! I am pulling my hair out. I
know there is an easy answer to this question, but I can't figure
it out.
I have my main timeline (Scene 1) and then on frame 5, I have
a movie that plays for about 70 frames (within itself). On the main
timeline it is only 3 frames long, and I have an action at the top
layer to stop at the first frame.
At the end of the 70 frame movie, I have a "next" button; the
action is in normal mode;
on (press) {
gotoAndPlay("Scene 1", 11);
I am ultimately telling this button to go back to the main
timeline (scene 1) and continue on with the next movie.
When I publish, the movie goes through just fine, gets to the
next button, I press it and it goes to the 11th frame of the that
same movie, instead of the 11th frame of the main timeline (scene
1).
Help! I appreciate it...let me know if I left anything
out...........
Aubryaubrycan wrote:
> Ahh!
> Thank you! It worked!
>
> You have saved me. :-)
better yet label the frame you like to target and target that
label
_root.gotoAndPlay("labelNameHere");
There is no scenes in SWF file upon export. So if you have 10
frame in scene 1
and 10 in scene 2, the frame 10 in scene two become frame
number 20.
The action sugested by FamousSeamus is not really correct
even tho it might work,
but as soon as you try to target frames across multiple
scenes, you can't refer to them
by their numbers unless it's one long scene only.
Best Regards
Urami
<urami>
If you want to mail me - DO NOT LAUGH AT MY ADDRESS
</urami>
Maybe you are looking for
-
How do you view what the dimensions of a document are in preiew?
-
Sto process find vendor and customer
we are Creating STO with ME27 tcode from one plant to another plant ie from A120 to S122. Already the configurations are done by someone. Now i took the purchase order xxxxx and open in me23n. As per the process we need to Assign vendor to Deliverin
-
EA6500 AC1750 - choppy streaming video
I have an excellent internet connection - 100Mbps dn and I put a new EA6500 router on it and got all my devices connecting and speedtests showing 40 - 60Mbps on 2.4 band, higher on 5ghz, couple different computers and operating systems throughout my
-
Adobe air ane for android build
I have created a ane of android. with an error that it is jdk1.7, there is no problem that it is jdk1.6. it's jdk1.7 the jar of ane do not create?
-
Reg : Value Help in interactive forms
Hi, I am trying to fill the ValueHelp drop down list Ui Element in the interactive form design. I am able to get the value in the dropdownbykey UI element of the view but i couldn't get it in the Interactive form. Could anyone please help me to