Reffering to Code in 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();
RESPONCE:
_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()
RESPONCE:
Ummm... I named my document class main, thinking that might
help me refer to it from child clips, but it didnt. Using root
seems to refer to main, but then I cant refer to anything on the
stage, or any function written there. From reading the help I got
the impression that function defined in the root timeline would
become publicly accessable functions that could be accessed with
dot notation. Is this not the case?
When I trace root, or main, it outputs [object main]. So then
thats the class... Why cant I refer to the functions of that class
from another movie?
Are you suggesting I write a document class with my functions
in it? could I still refer to objects on the stage if I do that.
I've read over these subjects alot in the documentation and its
really not clear... perhaps someone could write a tutorial.
_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();
>
Similar Messages
-
I have 4 mc's on a root timeline. I'd like each, when clicked, to animate individually. Currently with the code I have, when I click one, they all play. 3 of these mc's are identical mc's (they have instance names, but aren't called out in the code, not sure how to). The fourth mc is a different mc altogether, yet this particular mc along with the other 3 (identical) all play at once.
I thought using "this" would only have the mc I click on play. Not the case. I also tried putting the instance name (i.e. onoff1) bofore "this." and after "this." and no luck.
Thanks for any help, and I regret to say that I'm not savvy in AS2, so I hope you don't mind spelling things out for me because this a bit over my head.
Also, wanted to say, that the mc's timeline do have a stop at the beginning and end. So when you export the swf (currently) the mc is stopped, and when you click on it they all play to the next stop. So they act like I want them, just that they're all animating at once no matter which one I click.
onClipEvent(mouseUp) {
this.gotoAndPlay(1);Wow! You are the man!!!!! Karma points! Thanks so much.
I've only used on(release) for buttons, and have always used onClipEvent(mouseUp) for mcs. I didn't know you could use on(release) for mcs, didn't think you could.
I know enough AS3, more than AS2. I got a gig that asks for AS2 and I had to learn it from the ground up. I miss using the function command in AS3, I think I used it for everything.
Thanks again. -
Accessing Root Timeline Button
Hi,
I think this is a fairly basic thing to do, but I can't seem
to figure it out. I have a movie clip(
mc1) with a button(
btn1) and a movie clip(
mc2) in it. The button plays this second embedded movie
clip(
mc2). In this second movie clip(
mc2), I have a button(
btn2) that, when clicked, I would like to cause the first
button(
btn1) (on the root timeline) to disappear. Is this possible,
and if so, could you help me figure out how to do so?
Thank you,
Brad
EDIT: Just so its easier to visualize, here's a hierarchy of
the relevant elements:
mc1
btn1
mc2
btn2Thank you kglad.
Unfortunately, I'm not 100% sure what you're suggesting. Are
you saying I should test to see if the btn2 will respond to a click
using hitTest? If so, I already know that I can click on btn2
because I have some actionscript that runs when I click it, and
that particular part of the code is functional. However, I'm not
sure what actionscript will allow me to modify btn1 when I click on
btn2. One snippet of code that I tried (but didn't work) was:
btn2.onRelease = function(){
_root.btn1._alpha = 0;
I'm guessing I'm doing something either wrong, or not
possible, but I'm still pretty new to actionscripting, so I
couldn't tell you. Anyway, thank you again, and I look forward to
your response.
-Brad -
Load swf AFTER playing to end of root timeline
Don't know if this can be done or not...
I have my Home page - 5 Navigation buttons on the page. Each
button "onRelease" will load an external swf file ( a new page).
The problem i'm having is getting the the buttons to play the rest
of the root timeline (after "Stop) before it loads the external
swf. The rest of the timeline is just a short fade to Alpha 0 of
all buttons before the new page comes in.
any help?
thanks in advance.michaeltowse wrote:
> Could you not assign a variable which is then picked up
at the end of the main
> timeline. This variable could be used within a loadMovie
command. Your buttons
> would have the variable declaration and then a play()
command.
>
What you seem to need is some sort of non unloading loading
of the movie.
You got the level loading method, the movieclip loading
method and the
dedicated loader class. -
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 -
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 -
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. -
What is a Root Timeline?
Hello All
I'm using CS3 (Mac) and I just bought a book on Actionscript (first timer with AS). What is a "root timline" and where is it at? For example the author says: "Since you've attached your script to the root timeline", and I'm thinking to myself, "I did?", where is it? LOL. I just made a car go from the left side of the stage to the right side with the car shaking and vibrating, and I did good with that. But I have no idea where this root timeline thing is at? Can anyone help me with this?
Thanks
Why_atlthe root timeline is the main timeline. it's the timeline you see when you open a newly created fla file.
-
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. -
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();
> -
I need to make a task with less as3 code and more timeline structure and event dispatcher !
I went to an interview in a big company. I had to make a task in which there is a wall with 3 lines and 5 columns filled with bombs.When you click on a bomb the bomb changes its scale, a robot enters, goes under the bomb and takes it, then goes to a smaller wall, makes the bomb smaller and place it at the same place it had been in the previous wall.I made the task with tween througout as3 code.The interviewer told me it was good but i need to make it with the less code possible and with more complex timeline structure and to use event dispatcher.What is the best way to do this ?
The immediate thing that comes to mind is they might want to see that you can balance work between design teams and development teams.
To do that, the robots movements (pick up bomb, bomb grows/shrinks, arms/treads/legs moving, sequences of 'doing things') can be timeline based so animators can work on those separate from code.
Developers would be working on the logic of keeping score, moving the robot around to the correct spot with path detection, collision detection, etc.
It's very similar to thinking in simple factories (which Flash is good at being automatically with timelines), and a bit of MVC (or just VC in some cases).
Big companies have lots of different types of employees so you'll probably be very specific in your role so you're efficient. -
Array to control MCs on the root timeline
HI - - - a continuing saga
I have a main timeline thats about 900 frames long. During
the course of this 900 frames I bring in short MCs (subA, subB,
subC, etc) on their own layer which play their duration - (a 90
frame sub MC gets 90 frames on the main timeline).
Using a mc I made into a play/pause btn, I can pause and
resume play of the main timeline by targeting “_root”.
I can also use the same button to pause/play the sub_mcs IF I
list each one at the pause and play commands. I thought an array
would help me avoid that code repetition but it doesn't work.
Can someone look at my code and let me know what's missing
and/or what I did wrong?
TIA
JLHi --
Try this:
obj = allSubMCs[0]
obj.play();
etc..
You have to define the index of the array. If you want the
pause/play button
to work for all MCs in the array then just loop through the
array.
Rich
"jlucchesi" <[email protected]> wrote in
message
news:ghun7u$pjn$[email protected]..
> HI - - - a continuing saga
>
> I have a main timeline thats about 900 frames long.
During the course of
> this
> 900 frames I bring in short MCs (subA, subB, subC, etc)
on their own layer
> which play their duration - (a 90 frame sub MC gets 90
frames on the main
> timeline).
>
> Using a mc I made into a play/pause btn, I can pause and
resume play of
> the
> main timeline by targeting ?_root?.
> I can also use the same button to pause/play the sub_mcs
IF I list each
> one at
> the pause and play commands. I thought an array would
help me avoid that
> code
> repetition but it doesn't work.
>
> Can someone look at my code and let me know what's
missing and/or what I
> did
> wrong?
>
> TIA
>
> JL
>
> var allSubMCs:Array = new Array("sub1_mc", "sub2_mc",
"sub3_mc");
>
>
> playPause_btn.onRollOver = function() {
>
> if(this._currentframe == 1) {
> this.gotoAndStop("pauseOver");
> }
>
> else {
> this.gotoAndStop("playOver");
> }
>
> }
>
>
> playPause_btn.onRollOut = function() {
>
> if(this._currentframe == 10) {
> this.gotoAndStop("pause");
> }
>
> else {
> this.gotoAndStop("play");
> }
>
> }
>
>
> playPause_btn.onRelease = function() {
>
> if(this._currentframe == 10) {
> this.gotoAndStop("playOver");
> _root.sub1_mc.stop(); // naming each sub mc does
> //_root.allSubMCs.stop(); // the array doesn't work
> _root.stop();
> }
>
> else {
> this.gotoAndStop("pauseOver");
> //_root.allSubMCs.play(); // the array doesn't work
> _root.sub1_mc.play(); // naming each sub mc does
> _root.play();
> }
>
> }
> //------END PlayPause TOGGLE--------
> -
Assigning co code to Root org hierarchy....
Hi
I am having a basic question in SRM4.0 org structure hierarchy.
Is it mandatory to assign a backend company code to the root organization unit in SRM organization structure?
What I know is there will be only one Root org unit for a company and it will act as a parent for that company and sub units of that root unit can be assigned to different company codes or purch organizations from backend.
Why I am asking this question is in one implementation I observed that the root org unit was assigned to one of the company codes. Now they are rolling it out to different company codes.
In that case ideally speaking a company code cannot be created under an org unit which is already assigned to one company code.
Please correct me if I am wrong.
In that situation how it is to be dealt with?
can anyone please share your experiences?
Thanks
JagdishHi Jagdish
Did you solve your problem regarding the org. structure??
I am very confused and hope you can help me.
I have 13 company codes, 1. purchasing org, 600 departments and 600 purchasing groups i must build up in a org. structure.
I have tried to build it as following:
Root - Purchase org.
- Company code A
-- Department 1 - purch. grp
-- Department 2 - purch. grp
-- Department 3 - purch. grp
- Company Code B
-- Department 1 - purch. grp
-- Department 2 - purch. grp
- Company Code ...
-- Department .. - purch. grp
This will result in a warning saying "You may not create a company below a purchasing organization (00000000)".
If I follow SAP help it says that the purchasing org must be on same level as the company code but this result in DUMPs. I therefore ask OSS for help and the answer from them is that the purchase org must be on root level !?!?
If I ask them to explain how I then must build my org structure so I do not get my warning the ask me to get remote consulting
Can you or anyone please help me.
I will give max points for a usefull answer.
Best regards
Jesper Lander -
Need help moving my code from the timeline into classes
Hello everybody,
A few months ago I made a simple flashgame with the help of a tutorial (http://www.flashgametuts.com/tutorials/as3/how-to-create-a-brick-breaker-game-in-as3-part- 1/) as a school assignment. When I turned it in to my teacher, his biggest complaint was that the code was written onto the timeline instead of in seperate classes. I know virtually nothing of programming (dealt with agoraphobia while the classes took place ), so I was wondering if someone could help me move the code into classes.
Here's the complete package for the game: https://www.dropbox.com/sh/xhjuhz04z8g129m/0nSwf1wngu
Thanks!You will need to learn about classes. I suggest that for the moment you set your actual project to the side--but keep it in mind--and work on some smaller chunks. Do some tutorials and learn a bit. Then try and apply what you have learned to your project.
http://www.untoldentertainment.com/blog/2009/08/25/tutorial-understanding-classes-in-as3-p art-1/
Work on the individual bits and post more specific questions when you run up against them.
It will require shifting your thoughts a bit on how to design and structure things. For me the really key concept is encapsulation--the idea that your classes are self-contained and have very specific routes of communication for receiving and sending information. To achieve this you need to think about methods, properties, and events. If you've done regular timeline coding you probably recognize properties (x, alpha, htmlText, etc.) and events (MouseEvent.CLICKED). Methods is a fancy word for function. So when you do something like myMovieClip.gotoAndStop(5) the gotoAndStop is a method of the MovieClip class and that just means somewhere there is code like this:
function gotoAndPlay(frame:Object, scene:String=null):void{
// code that tells flash how to move the movieclip to a frame
That is a bit of a simplification, but conceptionally it is what you will do for the methods of your classes. -
Does anyone know if it's possible to run a timecode that matches the timecode of the masterclip? I.e. if I put a clip into my timeline, can I stamp the original timecode on top of it?
I'm dealing with a project that will need subtitles, and am trying to figure out a good way to keep the timelines straight!
thanksYou may try the free filter FCE Timecode Display.
Piero
Maybe you are looking for
-
Hi all, has anyone come up with a way to access all of your secure websites without having to remember millions of passwords? Going nuts trying to remember them all
-
I am trying to do bdc for ac02, using session method, data is updating in bdcdata table, its not getting into the database, PERFORM : fill_bdc_data USING 'SAPLBAS0' '0300' 'X' ' ' ' ', fill_bdc_data USING '' '' '' 'BDC_OKCODE' '=NEW', fi
-
I am connecting to the internet using the Internet Sharing from my iMac ... The trouble is the messages in the Messages app are not sent when I am connected through my iMac ... When I key in a message and hit send a progress bar appears fills up till
-
Default namespace in WebLogic Workshop generated WSDL
Hello there, I am trying to access a very simple webservice developed in WebLogic Workshop (say something like HelloWorld.jws) from a ColdFusion application. However, I get an Axis fault on Coldfusion implying that it could not invoke the required me
-
Best Practices for using Acrobat to create resumes?
I am a professional resume writer and have been asked recently by a few customers to create resumes using Adobe. I have no experience using Adobe and would like to see if there is an "online tutorial for dummies" kind of thing. If anyone can point me