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
Similar Messages
-
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. -
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(); -
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 -
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(); -
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 -
How to remove all nodes (except root node)from a Jtree?
How to remove all nodes (except the root node)from a Jtree?
Either:
- remove all children of root.
- save the root node, throws away the tree model, build a new TreeModel with the saved root, set the new TreeModel in the JTree.
- implement your own TreeModel, which would support an emptyExceptRoot() method.
IMHO, using the DefautlTreeModel and DefaultMutableTreeNode does lead to all sorts of small problems when the app evolves, and implementing your own TreeNode and TreeModel is not that hard and much more efficient. -
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. -
How can i remove all of the purchased songs from my phone?
I want to remove all of the purchased songs from my phone, but I'm not having any success. I've transferred the purchases to iTunes, and turned off the cloud on my phone, but they are still there. They will not let me delete them...
Roy631 wrote:
They go away until the next sync and then they return to the list. They are shown in iTunes greyed out with a broken circle in the first column when manually viewing them.
It's an iPhone 5S, I'm running the latest OS, 8.1.
OK, maybe time to get extreme. I've had similar experiences, sometimes occurring after making direct-to-device purchases and sometimes after doing an iOS update. In the two times I've experienced what you've seen I've fixed it by digging deeper, bear with me:
If your iPhone is not set for manual management, do so. (i.e. select "Manually manage music and video")
While connected to iTunes, navigate the contents of the iPhone. Select all songs and delete them. Ignore the gray ones if still present.
Eject the iPhone and go to Settings/ General/ Usage/ Manage Storage. Let the list populate then select the Music category. In the next screen, swipe across "All Songs" from right to left and tap Delete.
Connect back to iTunes, perform a backup, then restore the iPhone and reload the backup.
Your iPhone should now have its settings, accounts, and apps back, but no music -- not even the "ghost" entries. Add the music back that you want, either via manually dragging and dropping from iTunes, or auto-syncing all or a portion of your library.
Some people reported luck with just step #3. The problem I've had with that, is any music that I want remaining on the iPhone gets corrupted, such that playback will skip and/or show the wrong artwork. By deleting all music first, then following up with a restore, that seems to clear the problem. Personally I avoid direct-to-device purchases since I've had spooky occurrences almost every time where the purchases are very difficult to remove. -
Cannot connect to the iTune Store from within iTunes.
Can not connect to the iTunes Store from within the iTunes program on my PC. Using iTunes 10.4 on a XP Sp3 system. Everything worked fine until a few days ago. Now the iTunes Store (Store) will not open. Tried rollback, disabling firewall, anti-virus etc. Not working. iTUnes Diagnostic says I can connect to the net but the screen remains blank, except "No connection to firmware update server" is listed in the Diagnostic.
Yes, I am running AVG Anti-Virus Free and was using Comodo Firewall. Uninstalled everything, iTunes Store still would not appear. Now using AVG and Windows Firewall, still can not get Store to come up. Diagnostic follows:
Microsoft Windows XP Professional Service Pack 3 (Build 2600)
GATEWAY 831GM
iTunes 10.4.0.80
QuickTime 7.7
FairPlay 1.12.20
Apple Application Support 2.0.1
iPod Updater Library 10.0d2
CD Driver 2.2.0.1
CD Driver DLL 2.1.1.1
Apple Mobile Device 3.4.1.2
Apple Mobile Device Driver 1.57.0.0
Bonjour 3.0.0.2 (333.2)
Gracenote SDK 1.9.1.485
Gracenote MusicID 1.9.1.102
Gracenote Submit 1.9.1.133
Gracenote DSP 1.9.1.43
iTunes Serial Number 0012ABA010AA0F38
Current user is an administrator.
The current local date and time is 2011-08-16 18:21:15.
iTunes is not running in safe mode.
WebKit accelerated compositing is enabled.
HDCP is not supported.
Core Media is supported.
Video Display Information
ATI Radeon HD 3400 Series
**** External Plug-ins Information ****
No external plug-ins installed.
iPodService 10.4.0.80 is currently running.
iTunesHelper is currently not running.
Apple Mobile Device service 3.3.0.0 is currently running.
**** Network Connectivity Tests ****
Network Adapter Information
Adapter Name: {11221FB9-2BC2-4E8D-A170-06A6BEBCCB07}
Description: Intel(R) PRO/100 VE Network Connection - Packet Scheduler Miniport
IP Address: 192.168.0.103
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.0.1
DHCP Enabled: Yes
DHCP Server: 192.168.0.1
Lease Obtained: Tue Aug 16 17:24:27 2011
Lease Expires: Tue Aug 23 17:24:27 2011
DNS Servers: 192.168.0.1
Active Connection: LAN Connection
Connected: Yes
Online: Yes
Using Modem: No
Using LAN: Yes
Using Proxy: No
SSL 3.0 Support: Enabled
TLS 1.0 Support: Enabled
Firewall Information
Windows Firewall is on.
iTunes is enabled in Windows Firewall.
Connection attempt to Apple web site was successful.
Connection attempt to browsing iTunes Store was successful.
Connection attempt to purchasing from iTunes Store was successful.
Connection attempt to iPhone activation server was successful.
Connection attempt to firmware update server was successful.
Connection attempt to Gracenote server was successful.
Last successful iTunes Store access was 2011-08-16 18:19:43.
Ran another test today an hour or so ago, same result except "Connection attempt to firmware up......" failed. -
Calling a function from within a movieclip
How do I do this, and Is it wrong to do it this way?
I have a movieclip on the timeline and within that movieclip
it has buttons which I've placed listeners. I'm doing it this way
rather than putting the code in the document class because the
buttons don't appear right away in the movieclip (not until around
frame 10). The function is defined in the document class because it
is used with other movieclips.
Anyone have an idea on how to properly do this?Well, I'm at least not getting an error - however, nothing is
happening when I click the button to call the function (which is
indeed public). Inside the function is a simple trace. I've even
added a param to the function just for fun, and there's no error
when calling the function from the button. -
Reffering to code in the root timeline
I'm very suprised I theres not an obvious answer to this
question to be found. In AS 2 I would often write most of my code
in the main timeline, and then refer to it from various other
movies etc. I dont seem to be able to do that in AS 3? how can I do
it in AS 3?
For example if i had a function on the main timeline, and
wanted to call it from the code in another movie. In that past I
would have just used _root.functionName();_root in AS3 is now simply root (no underscore). The root
property,
however, is only available to DisplayObject instances, not
other classes.
The root reference is also null unless the DisplayObject
instance is a child
of a display list attached to the stage. For timeline scripts
within a Flash
FLA, however, where the movie clip is added to the screen
within the Flash
environment, root is always available.
A good practice for globally accessible functions, however,
would be to
define your functions as static methods in a class. Then you
can reference
those functions anywhere from any object (even non
DisplayObject instances)
using ClassName.functionName()
"smazr123" <[email protected]> wrote in
message
news:f29rrb$4nl$[email protected]..
> I'm very suprised I theres not an obvious answer to this
question to be
> found.
> In AS 2 I would often write most of my code in the main
timeline, and then
> refer to it from various other movies etc. I dont seem
to be able to do
> that in
> AS 3? how can I do it in AS 3?
>
> For example if i had a function on the main timeline,
and wanted to call
> it
> from the code in another movie. In that past I would
have just used
> _root.functionName();
> -
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? -
How to change the default directory from within SQL*Plus ?
Hello,
I want to change the default directory directly from within SQL*Plus to be able to launch my command files with simple instructions like :
@my_command.sql
If I haven't launched SQL*Plus from the directory containing the file my_command.sql, how do I change the default directory to the directory of my command files ?
I've searched through the Oracle documentation, there's no SET DEFAULTDIR or something like that. When I do a SHOW ALL, there's no variable containing the default directory.
If you have an idea...
regards,
Jérôme.Hi Jérôme (Jé²´me ?),
You cannot directly do that, but you can use @@ instead of @ to run subscripts in the same directory as the superscript
# head /tmp/tl30/xxx/[xyz].sql
==> /tmp/tl30/xxx/x.sql <==
prompt call y
@y
prompt call z
@@z
quit
==> /tmp/tl30/xxx/y.sql <==
prompt i am in y
==> /tmp/tl30/xxx/z.sql <==
prompt i am in z
# pwd
/root
# sqlplus -s scott/tiger@lsc62 @/tmp/tl30/xxx/x.sql
call y
SP2-0310: Datei "y.sql" konnte nicht geöffnet werden
call z
i am in zKind regards
Laurent Schneider
OCM DBA -
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?
Maybe you are looking for
-
CS 5.5 Save To Web Default To Same Folder As Original?
This has driven me NUTS since CS3... I'm hoping there is a solution I just never figured out. When I open a PSD and then click Save To Web it always saves to the last folder I had Saved To Web... NOT the folder of the PSD I just opened. So about 50%
-
Error: invalidfileaccess; OffendingCommand: imageDistiller
I use AcrobatPro 8 to create pdfs from a CAD program called Chief Architect. It used to work just fine, but now whenever I try to print a CAD layout sheet with an image pasted on it (my typical image is just a black and white .tif image), Adobe will
-
Any way to set snooze time on the Alarm Clock
The default snooze time on the Alarm Clock is 10 minutes. Any way to set it to 5 minutes?
-
Adobe Muse CC on Windows Vista
Hello, I have Windows Vista installed on my PC and I want to install Adobe Muse CC. I've read in the system requirements that there are two versions of it, one of them - Adobe Muse CC 2014 requires Windows 7 SP1 and other - Adobe Muse CC (without 201
-
Notification center doesnt come down in landscape mode
I'v recently updated my ipad 2 to ios 5 and the notification center doesnt cme down when the ipad in landscape mode. And it appears to be missing the email notifications. Can you help me?