Controlling the root timeline from inside a MovieClip
[preface] I'll apologize in advance. I'm a designer, not a
developer. I know very little about actionscript so if you
can help me out, please pretend like I know nothing.
[/ preface]
I just need actionscript to check the value of a variable
when the end of a movie clip is reached and then call an action.
Here's what I've got and it doesn't work. Please don't laugh.
if (p == 1){
tellTarget (_root) {
play();
else if (p == 0){
stop();
(the "stop" on the "else if"
is referring to the movie clip's timeline, not the root
timeline... in case you're wondering)
Any help would be greatly appreciated. Thanks!
No it's not a school project. Good guess though. It's
actually a self-promo piece for the ad agency I work for. I'm an
art director expanding my horizons. I would take a class or run
through one of the good actionscript books but unfortunately, I
don't have time.
Thanks for the help again kglad.
btw, I've used tellTarget successfully in a few projects in
the last few months. I'm using Flash 8.
Similar Messages
-
Controll the ROOT timeline from externally loaded movie clip?
does anyone know how to controll the root timeline from an
externally loaded movie clip?
I have loaded a movie clip, which has buttons on it that I
would like to controll the main original website timeline with.
something like this.parent.parent?
thanks a lot
harkyfeedmeapples <[email protected]> wrote:
> does anyone know how to controll the root timeline from
an externally
> loaded movie clip?
>
> I have loaded a movie clip, which has buttons on it that
I would like
> to controll the main original website timeline with.
>
> something like this.parent.parent?
_root.doStuff;
Freundliche Grüße,
Franz Marksteiner -
Remove child on the root timeline from within a movieclip
Hi
How do I remove a child from the root timeline from within a separate movieclip?
I've tried
MovieClip(parent).removeChild(mc1);
But I get this error
1120: Access of undefined property mc1.
I could write a function in the root timeline that just removes child and then run that from within the movieclip but is there a better way?
Thanks in advance.Thanks for replying.
I asked on Kirupa but I couldn't access the site so I asked here.
I guy answered with this
MovieClip(parent).removeChild(MovieClip(parent).getChildByName("mc1"));
It works fine, is this the best way to do it?
Not sure if I understand what you meant?
Just to be clear I have to movie clips on the stage mc1 and mc2 and i want to remove mc1 from within mc2's timeline.
Thanks again -
Toolkit for CreateJS: How to control the main timeline from outside the canvas.
Hey Everyone,
I'm currently trying to do something simple, but my animation breaks whenever I attempt to change my code. I have created a basic animation in Flash where an object moves from the left side of the canvas, to the right, and then loops from the last frame to the first frame. Nothing else. The animation is simply put on the main timeline. I exported the animation with Toolkit for CreateJS through Flash's extension and the animation runs as it should. I am trying to start and stop (restarting from the first frame) the animation with mouse over and mouse off events. I want the events to fire when moused over/off a div OUTSIDE the animation's canvas tag. Is this possible with CreateJS? I'm trying to figure out how to control the main timeline without being inside the canvas tag.
Example HTML:
http://www.thephotoncore.com/testing/example_test.html
Example Code:
<section id="container">
<canvas id="canvas" width="550" height="400" style="background-color:#cccccc"></canvas>
<section id="animation_control">
<p>Roll over to start and stop animation.</p>
</section>
</section>
Thanks again for the help!
-DJHi DjPhantasy5,
All movieclips on the stage are children of the stage,
So on the "mouseover" all movieclips on the stage could be stopped with stop and on the "mouseout" all children could be restarted with gotoAndPlay like this:
function Stop()
if (stage && stage.children)
var i, l = stage.children.length;
for (i = 0; i < l; i++)
var child = stage.children[i];
if ("stop" in child)
child.stop();
function Restart()
if (stage && stage.children)
var i, l = stage.children.length;
for (i = 0; i < l; i++)
var child = stage.children[i];
if ("gotoAndPlay" in child)
child.gotoAndPlay(0);
See http://www.liauw.nl/forums/adobe/djfantasy5/index.html
But it is also possible to expose "ball1", for example, by adding it to the document.
This can be done by adding code to "ball1" like so:
/* js
document.ball1 = this;
Then the stopping of the animation would look like:
function Stop()
if ("ball1" in document)
document.ball1.stop();
etc.
Have fun!
Ronald -
How do I recerence Movie Clips on the Main Timeline from inside a class?
Hey everyone, this might be a stupid question but I thought
I'd ask cause it's making me nuts. I'm all of 2 days into AS3
(coming from not using Flash at all in YEARS) so feel free to
consider me ignorant. I do have plenty of application development
experience in other areas though.
I can't seem to create a class that can reference an instance
of a movie clip on my main timeline. I'd post code of what I've
tried but I've gone through so many desperate edits & wild
guesses that it was just garbled junk before I deleted it all.
Basically here's how I figured Flash could work, though maybe
it doesn't work this way at all.
I'm assuming that with AS 3 being so big on being a true
object oriented environment, I wouldn't need to mix my code and
interface together. Preferably I'd be using the Flash authoring
tools just to design my interface. Create a button... place it
somewhere... give it an instance name. Roughly the equivilant of
Apple's InterfaceBuilder for those of you that might be familiar
with Cocoa development. I can see maybe having to put a few lines
of ActionScript onto frame 1 (though really I'm hoping Flash would
have a better method of kicking off the application at this point
that using code tied to frames) to load my classes & such, but
after that I'd like all of my code to be held in external class
files.
So maybe I've got:
Interface.fla - My interface
Button_1
Button_2
TextField_1
Main.as - My main controller class using to handle all of my
applications behavior
SomeClass.as - Some helper Class
SomeOtherClass.as - Some helper Class
Main.as would have instructions in its initialization method
to go ahead & attach events to buttons & initialize
anything else that needs to happen when the application starts.
From there on it would all be objects communicating back &
forth. Button_1 would get clicked with would fire
Main.someMethod(). Main.someMethod() would then do it's thing and
set the value of TextField_1. All very clean & code is very
separated from interface.
Unfortunately I can't for the life of me figure out how AS3
classes reference each other like that. There doesn't seem to be
any kind of a global 'root' or '_root' I can use to locate any
movie clips on the stage. I've searched the help & the web for
any kind of simple tutorial but to no avail. My job has tasked me
with building a flash app for a project but I'd really rather not
have a tone of ActionScript just shoved into frame 1. That just
seems... ugh! (::shudder::)
Can someone maybe point me in the right direction here? I'm
really willing to do my homework but I can't seem to locate the
info I need to get started. Also, is there an ActionScript IRC
channel or something maybe?
Thanks,
CliffI worked with the problem last night and the solution I
started coming to involved creating my own custom document class
based off which extends MovieClip. My thought is that way I have
access to the initialization routine of the timeline itself and
that all of the elements on the main timeline should be
"properties" of my custom class.
Is this correct? Is there a down side to doing this & if
so what is it & why?
Also, just for my reference, the last time I did anything
with ActionScript I think I was using '_root' to target the main
timeline. WHat are the global variable names in AS 3? Is it just
'root' & 'stage' or 'Root' & 'Stage' or what? -
Changing stage timeline from inside a movieclip button
I create a movieclip button, and I want to change main timeline from it. what should I do ?
Is it useful to use MovieClip(root).gotoAndPlay(...) ; ?
Is there any other way to change main timeline?Example:
Add something to trigger the event in the child:
dispatchEvent(new Event("eventTriggered"));
In your parent swf, listen for the event using a listener for the child with a corresponding event handler...
childName.addEventListener("eventTriggered", eventHandler).
function eventHandler(event:Event):void {
trace("child dispatched an event");
// gotoAndPlay(etc); -
Play a frame in timeline from inside 2 movieclips.
Hi. I have tried everything but it just isn't working.
On my main timeline I have a MC called "rainbow." Inside "rainbow" I have a MC called "greenbow."
Inside "greenbow" I have a MC called "meetbtn2"
I want it to play frame 134 on the main timeline when you click "meetbtn2."
my code inside greenbow is as follows:
meetbtn2.onRelease = function () {
_root.gotoAndPlay(134);
however it doesn't work! is it because i am inside two MC's?
I have also tried
_root.rainbow.greenbow.meetbtn2.onRelease = function () {
_root.gotoAndPlay(134);
any help? Thanks!i believe you miss understood me. the actionscript and the MC are on the same frame on the same timeline.
however
on the main timeline: the MC "rainbow" doesn't appear til frame103
inside "rainbow": the MC "greenbow" doesn't appear til frame 48
inside "greenbow": the movieclip that acts as the button"meetbtn2" doesn't appear til frame 11
however all instances have been named correctly and all actionscript is on the same frame-space as its objects.... -
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(); -
Script to control main timeline from inside MC?
This is such a newb question and I'm sorry! I have a Movie
Clip on the main timeline and inside that MovieClip are several
buttons. I want the buttons to go to specific frames in the main
timeline. I have:
on (release) {
gotoAndPlay("PowerPoint");
I know there needs to be something in there to tell it the
main timeline. I searched for this very basic, simple question and
couldn't find anything.
Thanks for any help.if your buttons are true buttons use:
-
Referencing a button on main stage from inside a movieclip
I am banging my head against the wall on this.
On the main stage I have a button that I have made invisible once the file is loaded. Inside a movieclip I have on frame 15 the following actionscript 3 code
button_mc.visible = true;
I want the button to become visible at the end of this movieclip. I am not using an external as3 file, I am putting the as3 code in its own layer on the first frame.
I know it has something to do with the path to the button, but I cannot figure it out. If there is anyone who can point me in the right direction for referencing instances by instance name that reside on the main satge from inside a movieclip I would be very grateful.
Thanks
ThepopguyTry:
MovieClip(this.parent).button_mc.visible = true; -
Controlling a Movie Clip on the Main Timeline from a loaded SWF?
Is it possible to control a MovieClip on the main timelne from another loaded clip?
I see posts that control loaded clips, but most are all from the loader in the main timeline. I have a moviclip on the main timeline that I want to make visible or invisible depending on what keyframe is playing in another loaded swf.
If I try to call the movieClip from the loaded SWF I get "error #1119. Access of possibly undefined property...." because it doesn't exist in the loaded SWF, just the main timeline.
The old AS2 way just used "_root". Since "_root" doesn't exist any more, how do you control items on the main TimeLine from a loaded SWF?I am not clear what you mean because you are saying you are trying to target a movieclip that does not exist where you are trying to target it.
Try using a trace to see what you are targeting when you you target the MovieClip(parent.parent)....
trace(MovieClip(parent.parent));
The other approach I mentioned earlier is the more OOP-correct approach if you would rather try that way. Here's a rough outline of it...
AS3 - Dispatch Event
http://forums.adobe.com/thread/470135?tstart=120
Example:
Add something to trigger the event in the child (your loaded swf):
dispatchEvent(new Event("eventTriggered")); (
if dispatchEvent problem, see: http://www.kirupa.com/forum/showthread.php?p=1899603#post1899603)
In your loading/parent swf, listen for the complete event on the Loader.contentLoaderInfo. In the complete event handler, add a listener for the event on the loaded swf.
// event handler triggered when external swf is loaded
function loaderCompleteHandler(event:Event) {
MovieClip(event.currentTarget.content).addEventListener("eventTriggered", eventHandler);
function eventHandler(event:Event):void {
trace("event dispatched in loaded swf");
// this is where your main file can set the visible property of your movieclip -
Calling a variable from inside a movieclip AS3 in Flash CS4
I am trying to trace a variable string from inside a movieclip which is inside another movieclip on the main timeline using:
trace(VariableString);
and also
trace(stage.VariableString);
Neither work
The variable is an input textfield and traces fine when it is on the main timeline but will not work from inside the movieclip. I am using Actionscript 3 in Flash CS4.
I appreciate this has probably been discussed previously on this forum but I cannot find a difinitve answer that seems to work.
ThanksThanks for the reply. However this did not seem to work.
I think I had better explain a little better.
On Keyfrme1 I have a MovieClip1 containing a text input component. I have created a variable on keyframe 1 using:
var VariableString1:String = new String();
When clicking on a seperate button this happens:
VariableString1 = MovieClip1.text;
I can trace this correctly on the main timeline using:
trace(VariableString1);
However, if I try to trace this from another keyframe inside a movieclip2 which is inside another movieclip3 using:
trace(MovieClip1(root).VariableString1);
I just get the error 1180 call to a possibly undefined method MovieClip1
Sorry if this is not very clear but I am getting very confused with this.
Thanks again -
Going Back to the main frame, from inside a movie clip time line.
In flash CS5 I want to go back to the main time line, from inside a movie clip button, so when i click the the movie clip it goes to another frame on the main time line..
Can anyone help me?
Thanks
Daniel Derrickyour can use _root to reference the main timeline from anywhere though that can lead to problems if your swf is loaded by another swf. because of that eventuality, it would be better to use a relative path back to the main timeline.
so, from a movieclip's timeline (when the movieclip is on the main timeline), you can use _parent to reference the main timeline.
but even better would be to use no code on that movieclip's timeline and keep all your code on one timeline (the main one). -
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(); -
Refering to a class imported on the root timeline?
This is probably ueber basic, but I don't know how to do it.
I am importing tweenlite on the root timeline like this:
import gs.TweenLite;
I now want animate things in other MCs. I tried something like this, but it did not seem to work.
_parent.TweenLite.to(text1, 3, {_alpha:100, overwrite:0});
How would I do this?
Thanks a lot for any help with this!!!it's easiest to not even bother with the import statement and always use:
gs.TweenLite.to();
or
gs.TweenLite.from()
from any timeline.
Maybe you are looking for
-
The App "Find My Friends" in the app store is ver 4.0.1 which requires iOS 8.0.1. I wish to load onto an iPhone 4 that can only run iOS 7.1.2 Where can I find a copy of "Find My Friends" ver 3 ?
-
ITunes not showing in Applications folder
Hi there, I've just realised that iTunes has vanished from my Applications folder. I'm not sure how long it has been gone. However, as I still have iTunes in my Dock, I can boot the app from there. The programme works fine. Further, doing a Spotlight
-
NCDevCon is a 2 day, 40 session web and mobile development conference in Raleigh, NC. For $60 you get access to all 40 sessions and hands on classes. Your conference fee also includes lunch and a snazzy conference T-Shirt. Space is very limited so re
-
Compatability of oracle 8i/9i to thin driver
Hi, I am new to JDBC. will you please tell me whether Oracle 8i / 9i is compatable to use JDBC thin driver. If so, what is the SID name i need to give. Let's say i have installed oracle 9i on my machine. and set the class path to "classes12.jar". whe
-
SNAPSHOT LOG의 데이타가 지워지지 않는 이유와 강제로 지우는 방법 (V7 ~ V8I)
제품 : ORACLE SERVER 작성날짜 : 2002-05-09 SNAPSHOT LOG의 데이타가 지워지지 않는 이유와 강제로 지우는 방법 (V7 ~ V8I) ==================================================== PURPOSE 사용하고 있는 snapshot의 refresh에는 이상이 없는데 master table의 sanpshot log가 지워지지 않고 계속 늘어만 가는 경우가 있을 수 있다. 이러한