What Is The Simple Equivalent For Referencing The _root Timeline?
I've got a .swf (movie B) that gets loaded into a clip in my main movie(movie A). Movie B needs to control another clip within movie A.
In AS2, i would simply start off with a _global var on the main _root timeline, like this:
_global.home=this;
then, later in my seconday movie (movie B) i would reference that timeline simply like: home.myClip.gotoAndStop("whatever");
What is the simple equivalent for referencing the _root timeline? I've tried _parent with no results.
I'm looking forward to utilizing classes more, but for now I've got timeline code (on a single frame at least), with aspirations of moving toward a 'class-based' development style.
thanks for any help!
ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 07-24-2008, 05:54 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Referencing The Root Timeline Within Using _root In A Class
I have a class that I wrote and I need to reference the root timline but I can't use _root to do that because my movie will be loaded into another movie. Is there another way to reference root?... maybe a _global variable? If so, how would I set up that global variable on the root timline and then use it in the class?
Thanks.
_root Equivalent For This Actionscript
Howdy. I'm following a tutorial made in actionscript 2 and naturally the code is gelling well with my actionscript 3 document. I guess I have two questions. Is it easy to start a new document with what I've done non-code wise already in Flash 9 but using actionscript 2 instead of 3? Or would it be easier to redo the actionscript in 3 format?
Below is the original actionscript I'm using from the tutorial. It checks to see if a user has rolled their mouse over within 50 pixels of the left side of the screen. I just need the actionscript 3 equivalent since the whole _root issue has changed dramatically in from 2 to 3.
_root.onEnterFrame = function(){
if(_root._xmouse<50) {
imgBar.prevFrame();
}
}
Thanks in advance for any help you could offer!
- MythProd
(John David Hutton)
_root.loadMovie() Equivalent?
I need the functionality that "_root.loadMovie()" provides in every other Flash version!!
I CANNOT utilize "stage.addChild(Loader.content)" as a workaround. A Flash 6 .swf is involved whose script does NOT execute properly under an AS3 umbrella. In fact, this particular Flash 6 .swf CRASHES Flash CS3 when addChilded!! However, this crashing problem does not occur when I use _root.loadMovie() instead.
Plus, FlashVars are preserved with _root.loadMovie().
so is there an equivalent? something like "this.root.swapWith(Loader.content);"?
It's VERY important to me and I would be extremely grateful for any help.
Timeline-based Preloadeder Using Equivalent Of _framesloaded?
Hello!
I'm trying to recreate one of the old-school, timeline-based preloaders. Here's what I want:
Frame 1 starts the preloader. There's a silly frame-by-frame "jumping letters" animation until Frame 10. On Frame 10, there's a script that checks _framesTotal against _framesLoaded (whatever those commands were in AS2). If the two are equal, then I jump the playhead to Frame 11 for the rest of the movie.
How do I do that in AS3? Everything I see talks about:
1: Doing it in external class files - Not what I want to do.
2: Doing it as part of loading in some external MovieClip - Not what I want to do.
3: Using a component - Not what I want to do.
I'm thinking the crux of the matter is Frame 10's script, but I can't seem to suss out what the new AS3 commands are.
Can anyone help?
---Damian
Referencing Something In _root Not Working
I have a class 'resizingObject', with a method 'addFunction()', which is instantiated in _root as 'resizer' (im certain of this - ive checked in the debug - variables list)
I then have another class, 'layerObject', that i want to be able to call the 'addFunction()' method - so inside the layerObject i tried _root.resizer.addFunction(), _level0.resizer.addFunction() and all manner of other business but to no avail...even an attempt to trace _root.resizer returns undefined.
why cant i acces the resizer instance of the resizingObject?
Referencing Variables In A _root Function
Hi guys,
Ive function in the root of my movie which loads an xml feed into variables.
i.e... weatherType1 = weatherArray[0].childNodes.toString();
However when i try to access that variable from inside a nested MC it doesnt seem to pick it up. I am using:
var weather_txt = _root.weatherType1;
I am using the correct syntax here? Also what happens if I wanted to use it inside a nested MC?
Thanks
Damon
_root Replacement For AS3 For Object Referencing
Hello,
I am having some problems with accessing objects on the main timeline.
I am calling this function registerMenuButtons() from a function getDimensions() in AS3:
function getDimensions():void {
registerMenuButtons();
}
and registerMenuButtons accesses a textfield in a movieclip on the main timeline:
function registerMenuButtons():void {
graphics_gr.start_txt.text = "start"
}
however it seems to be a null object reference, text does not change.
In AS 2 I would have used _root to reference graphics_gr.start_txt.text. However I understand that it does not exist anymore. So I defined a variable called ref = this.root, and when I trace ref.graphics_gr it gives me "[object] point1. However this does not apply for start_txt, and instead when i try ref.graphics_gr.start_txt it gives me a null reference.
Is there any way to use a similar method like _root in AS2 to access an MC? Really don't know what's the problem, and I am not using any custom Document Class at the moment. Thanks!
Referencing _root Variables From Within Externally Loaded SWF
Hi,
What I'm about to ask may seem obvious, and probably has been answered before, but I've been searching and researching for a while, and just can't see where I'm going wrong.
I am trying to build a Desktop style application in Flash using a standard drop down menu, and load new content screens from external SWF's based on what was selected from the menu.
In the root timeline, I use the following actionscript to create a new movie clip and load external SWF's
code:
this.createEmptyMovieClip("mainContent",10000);
//Load Movie Clips for each Page
function loadPage(clipToLoad, pageTitle) {
_root.pageNumber++;
mainContent.loadMovie(clipToLoad);
mainContent._x = 50;
mainContent._y = 130;
topmessage = pageTitle;
}
However, within the external SWF's, I wish to populate the UI Controls via array elements held on the main timeline (the array is created from an XML file loaded into the main timeline). I need to do this, as many of the default values will change from time to time.
However, I can't seem to be able to reference what I want to from the external SWF. For example, I would attach the following to a combo box element in the external SWF:
code:
onClipEvent(load) {
// auditorControls is the name the array holding details for all controls
for(z=0; z < _parent.auditorControls.length; z++) {
if _parent.auditorControls[z].controls == "dob_day") {this.addItem({label: _parent.auditorControls[z].display, data: _parent.auditorControls[z].internal});}
}
}
I can't publish this, as I get the error:
Scene 1, Binding between <unknown>.. and dob_day.dataProvider.: The endpoint of the binding does not exist
**Error**
However, if I change '_parent' to '_root', it seems to be looking on its own timeline, not the main timeline.
I guess what I am asking is how can I load an external SWF, and bind several controls to data held within an array on the main _root timeline ?
Any Suggestions?
Thanks
Neil.
Child MC Timeline Controlling _root Timeline
I have a main Timeline which holds a child MC. The Child MC (text01aMC) runs to a length of 156 frames (text fades up and fades down). I'm trying to move the main time line forward one frame once the child clip has reached frame 156.
I'm using the following code:
stop();
if (_root.text01aMC._currentframe>=156) {
_root.gotoAndPlay(2)
}
This code doesn't seem to do anything?
Can anyone help.
Referencing Another Timeline
i've got 2 movieclips "primaryMC" and "secondaryMC". secondaryMC is inside primaryMC and is brought about by a button that is also inside primaryMC.
i need primaryMC to _root to the MAIN timeline and secondaryMC to reference the primaryMC timeline.
How is this done without making the primaryMC reference itself with the _lockroot command?
Referencing Main Timeline
I have a button in a movie clip(ab) I want the button to reference the main timeline (gotoAndPlay Label1 in the main timeline) can someone help me with this.
Thanks
Referencing Component Timeline
How do I refer to the timeline or an instance of a component. I just finished making a flash application in the main timeline of a movie, (http://www.52oz.com/projects/messagesWithBottom.swf ). I want to convert this into a component now. But all my referentes to _root obviousely mess up the functionality as a component. What should I replace _root to, so that it will be a direct referente to the timeline of the component? Thanks.
Referencing Wrong Timeline?
Hi, Please help!
On this page: http://www.dcssound.com/Kelly%20Website/intro.html, go to the Product tab, and select the "In-Wall Speaker" then select "LEW Series" and click on it. Notice NOTHING happens.
http://www.dcssound.com/Kelly%20Website/intro.html
On this page: http://www.dcssound.com/Kelly%20Website/product.swf
Do the same thing; select "In-Wall Speaker" then "LEW Series" and click. Nothing a list of speakers NOW SHOWS.
There is NOTHING as far as coding and design between these two pages. the ONLY different is that in the "Intro.html" page, I placed product.swf inside it(using a loader component).
The codes where I load the "LEW Series" images is this:
lew.onRelease = function(){
mcLoader.loadClip("lew.swf",_root.picViewer_mc.speakerloader);
}
Why does it work when it is in produc.swf itself but does not work when it is int Intro.html?
Thank you.
Referencing The Main Timeline From Elsewhere
From inside a movie clip (button) which is inside a display object (buttonSet), I want to gotoAndPlay a specific frame on the main timeline. I've tried stage.gotoAndPlay(thisFrame). I got closer with gotoAndPlay(stage.thisFrame). I still have something wrong.
I have about 15 frames on the main timeline. Each frame contains a myriad of objects all doing different things. Most importantly they transition from frame to frame based on the current frame (last button clicked) and the next frame (the newly clicked button).
Example: the last button that was clicked was button #4, the button I have just clicked is button #2. Based on this knowledge, I want the main timeline to gotoAndPlay frame #6.
Thanks for the aid. :)
Referencing Variable On Another Timeline
Hi gang,
I've got a simple scenario which has been causing some distress and confusion for me. I have a movie clip placed on the stage, which has a variable defined within it. My question is...how can I reference that variable from the _root timeline, without instantiating any on{} statements?
Sounds simple, yes...but I'm unable to do this. I've tried setting the variable in a variety of ways (var, global, Object, etc). No matter how that variable is set, I simply cannot reference from the main timeline, without reading the variable in an on statement block
ex.
trace(_root.mcTest.strTest); // invalid
on(press) {
trace(_root.mcTest.strTest); // correct
}
Thanks in advance to anybody who can enlighten me.
Referencing Root Timeline From Within A Mc
Hi,
This is probably a really simple question....
I have a root timeline in which contains a movie clip on a certain frame.
Inside that movieclip, on it's second frame, there is a button.
I would like to use this button, when clicked, to move take the user to a frame on the root timeline.
Anyone know the how to do this.
Peace to all mankind.
Referencing The Root Timeline
Ok, so my problem stems from my dependence on the _root object in AS2.0
If I have a movieclip that I want to call a function that is on the main timeline, which reference would I use? I tried root.testFunc() to call said function, but got no play.
Any ideas?
Referencing Variable On Another Timeline
Hi gang,
I've got a simple scenario which has been causing some distress and confusion for me. I have a movie clip placed on the stage, which has a variable defined within it. My question is...how can I reference that variable from the _root timeline, without instantiating any on{} statements?
Sounds simple, yes...but I'm unable to do this. I've tried setting the variable in a variety of ways (var, global, Object, etc). No matter how that variable is set, I simply cannot reference from the main timeline, without reading the variable in an on statement block
ex.
trace(_root.mcTest.strTest); // invalid
on(press) {
trace(_root.mcTest.strTest); // correct
}
Thanks in advance to anybody who can enlighten me.
Referencing Main Timeline From External Swf?
lo all.
here's the deal.
I've made a main movie with different scenes. I've also made another movie with forward and back buttons on it to control the main movie. The control movie is loaded into level1000 so it's always on top.
I've put the following code on the button in the loaded swf.
//this SHOULD change the scene on the MAIN movie.
on (release) {
_level0.nextScene();
}
it's not working though.. I can only assume it's going to level0 of the control movie and not the main movie. I've had a quick look through the forums and can't find an answer. I'm hoping someone here will help me out.
If anyone want to have a look at the files then just ask and I'll post a url.
cheers
Specimen
www.the-nervous-system.co.uk
Timeline Control & Object Referencing
Hi,
I'm wondering what the proper ActionScript is to control a timeline within an event handler function. In an xml.onLoad function I want to send the main playhead to a certain frame based on the content of the XML. The only way I have found to do this is using _root.gotoAndPlay within the {} of the onLoad function; using gotoAndPlay, this.gotoAndPlay, this._parent.gotoAndPlay etc. doesn't work. These would of course work if they weren't within the onLoad function -- thus something about being within an object function changes positioning/referencing of movie clips and timeline control.
_root is a workaround and it's not perfect. any ideas on how to properly control timelines from within functions such as xml.onLoad?
Thanks in advance!
External .as Referencing Timeline MovieClips
Hi,
I have a flash file which has an Movieclip "Inventory" in the library that is linked to its own external class file that is responsible for its behaviors. Within this movieclip there is another clip that is on the stage called "LevelIndicator".
I'm trying to get the external class "Inventory" to refer to "LevelIndicator" but i'm not sure how to target it in the code of the external class.
for example i have the following function within the Inventory class:
function getLevel():Number{return LevelIndicator._y;}
Actionscript produces an error saying there is no property with the name LevelIndicator.
Is it possible to target these clips, or would they have to be attached within the class itself?
Referencing The Main Timeline From A Movieclip
So I have a movieclip on frame1 of the main time line.
Once the movieclip as finished playing I want to add a line of code that tells the playhead on the main time line to gotoandplay frame 2.
If I add
Code:
gotoAndPlay(2);
predictably the movieclip repeats itself, how do i reference the main play head. I tried
Code:
_root.gotoAndPlay(2);
but it didnt like it
Any ideas?
Many Thanks
Referencing Movieclips On Main Timeline
Hi, I know this issue has been talked about a considerable amount on here and other places. I did my fair share of searching and trying a few different methods.. but nothing has worked for me yet.
I have movieclips I created sitting on the stage of the main timeline with instance names deck, titles, stats, and ui.
In frame 2 of a movieclip INSIDE the ui movieclip, I'm trying to reference the movieclips sitting on the main timeline.
I do not have a main document class- its making its own when i run the swf.
Code:
this.parent.stats
// this throws an error: 1119: Access of possibly undefined property stats through a reference with static type flash.display:DisplayObjectContainer.
this.root.stats
// this throws an error: 1119: Access of possibly undefined property stats through a reference with static type flash.display:DisplayObject.
So I also tried creating a dummy mc on the nested movieclips stage and using it to access the root.. and after that failed I tried tying the movieclips on the main timeline to a classname and adding it to the stage with code so i could type it as a movieclip.. no luck there either.. examples below
Code:
dummy.root.stats
//throws the same error as above
var stats:MovieClip = new Stats();
addChild(stats);
//didn't change a thing
As you can see I'm stretching quite a bit What's the correct to do this from code on the timeline? I'd like to not have to make this completely class based if possible.. is that the only way?
Thanks for any suggestions!
Alan
Having Trouble Referencing To The Main Timeline.
Hi, I'm working on a game for this class I'm taking.
It's a maze sort of thing and I want it to go to a losing screen when you run out of time.
This losing screen is on frame 122 of the main timeline.
I have the actual maze on only one frame, with a stop action.
The timer is a movie clip that lasts for 720 frames, just the hand going around once for 60 sec. When I try to have it gotoAndPlay at the end it goes to the frame on the timer movie clip, not the main timeline.
This is what I have, but doesn't work:
gotoAndPlay ("Scene 1", 122);
I tried everything I could think of, everything I try plays the frame 122 for the timer movie clip. So I thought that maybe I wasn't using the correct reference, so I tried this:
gotoAndPlay ("dfsgdfs", 122);
And it still played the frame for 122 on the timer clip. So I know that it doesn't think that Scene 1 is the timer clip, I'm just telling it the wrong thing.
So... yah, can someone help me with this? Please?
I just need it to play from 122 on the main timeline, thanks.
Referencing Timeline Variables From A Class
Yet another question..How do I referece, within a class function, variables residing in the timeline that is invoking the class? (Very beginner here!)
So far I've had to send the timeline variables from the timeline to the class's function as parameters, which works, but there's so many. And I know I can just make these variables reside in _root and reference them this way, but that is not smart.
Does it have to do with _parent at all? Tried using it but failed..
Thanks.
Referencing Root Timeline Within Loaded Movie
Hi, I've got a movieclip that's going to be loaded by the main stage and I'd like to know what the correct path would be inside the clip to access it's local main stage, since _root will be the parent movie clip.
The module worked fine on its own when I made _root references but now that it is to be loaded by another movie I have to replace _root with a different path. I'm somewhat familiar with levels and have been trying different things but to no avail.
Problem Referencing MAIN Timeline From Embedded SWF
Here is my problem.
I have a projector file on a cdrom.
The projector file has three scenes, INTRO, INDEX, and VIDEO INDEX.
At the begining of the cd-rom you are presented to watch a video or tour the cd-rom. the cd-rom loads a bunch of different .swf files according to what section you pick. this all works fine. When you choose to load the video at the prompt the button takes you to the INDEX VIDEO scene where the video is loaded into a dummyMC from an external .swf file.
Here is the problem, what I need to do is have the video unload, (or not if it doesnt matter that it is now inside the dummyMC) then after it is doen playing (at the last frame of that .swf) I need it to go back to the original cdrom/video prompt. So what I need the video.swf to do is go to a frame label in the INTRO scene on the main timeline of the projector. IS IT POSSIBLE to have the video.swf movie go to a frame label on the MAIN projector timeline??
if so what would be the code.
PLEASE help In dying here I have tried everything.
Thanks.
If you help I will personanlly mail you a home cooked cookie.
Referencing Function In Main Timeline From Loaded .swf
Hi,
I have a movie where I'm loading a .swf using placeholderMC.loadMovie("somemovie.swf");
Once the movie is loaded, I tell it to play, and it plays.
However, I'm needing to know when this movie has finished playing.
I put some code in the last frame of "somemovie.swf" to call a function in the main timeline.
_root.someFunction();
But it won't work.
How do I call the main timeline from a loaded .swf.
Thanks,
The Alchemist
[F8] Global Functions And Referencing The Calling Timeline
I am trying to have a single global function that handles the button presses (and results thereof) for the menubar on my website. The problem I am running into is how do I make sure that when the global function (defined on the first frame of _root) references the movieclip that calls it.
so, for example if I do something like this:
_global.ButtonClick = function () {
this.play();
}
and on the movie clip I..
on(release){
ButtonClick();
}
How do I make it so the global function plays the the timeline of the calling movieclip? Thanks for any help!
--David
Referencing Main Timeline From Symbol Instance
i have a symbol instance on the main timeline in frame 1. inside the symbol there is a button which i want, when released, to move the main timeline over one frame.
is it possible to reference the main timeline from within this instance of the symbol? i have tried placing an onRelease command both within the instance and on the button inside the symbol. neither seem to work.
Referencing A Button On Frame 2 Of MC From Main Timeline
I have these two addEventListener's on my main timeline.
ActionScript Code:
// back1_btn is on frame 1 of loadWindow_clip
loadWindow_clip.back1_btn.addEventListener (MouseEvent.CLICK, clickedgoBack1);
// back2_btn is on frame 2 of loadWindow_clip
loadWindow_clip.back2_btn.addEventListener (MouseEvent.CLICK, clickedgoBack2);
When I test the movie, I receive the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
If I remove:
ActionScript Code:
loadWindow_clip.back2_btn.addEventListener (MouseEvent.CLICK, clickedgoBack2);
I don't receive the error.
The movieclip, loadWindow_clip, has 2 frames. Frame 1 and frame 2.
On frame 1 of loadWindow_clip I have a button, instance named: back1_btn
On frame 2 of loadWindow_clip I have a button, instance named: back2_btn
What it looks like to me is that I cannot make reference to any other frame other than frame 1 of another movieclip, from the main timeline.
Am I correct?
The _root Timeline
I've been doing a lot of playing with Flash 8 using some of the more advanced tutorials to learn from and one thing that I keep running across is references that require actions be put in the _root timeline.
Could someone please explain just what this is and how I would go about putting an action in there? I know this has to be relatively simple but for some reason, I'm just not able tyo wrap my head around it.
Thanks
http://www.kb-design-studios.com
LoadMovie To _root Timeline
hi there,
I got this menu movie in the root timeline, and inside that movie I got another pop-up movie for submenu, and inside that submenu I got buttons obviously :)
I used :
on (release) {
loadMovie("h_euro.swf", "_root.now");
}
but just not work, and for some interesting reason it reloads the main movie. kinda confused here. "now" is a movie located in the root timeline.
hoping for some help
thanks
_root Timeline GotoAndStop
Hi
I'm having problems getting a movie clip button on the main timeline to tell the main timeline to gotoAndStop a label when clicked.
This shoulbe be straight forward.
The script is below - any ideas on what the issue is?
Thanx
Dirk
on (press) {
//Start Dragging Movieclip Behavior
startDrag(this, false, 168, 224, 564, 476);
this.swapDepths(this._parent.getNextHighestDepth() );
n=this.getDepth();
_root.introBox.swapDepths(n+1);
//End Behavior
}
on (release) {
if(getTimer()-lastClick < 500){
_root.gotoAndStop("nointro");
loadMovieNum("http://www.dirksmith.com/flash_2/port_allianz.swf",50);
}
lastClick=getTimer();
stopDrag();
}
on (rollOut) {
stopDrag();
}
As Won't Work Unless On _root Timeline
I have this actionscript with a MC.
_root.containerMC.loadMovie(loadswf+".swf");
however, it will online work if i put this action on the _root timeline. Does anybody know why?
_root And Timeline Control
I'm having some problems with controlling my movie clips.
I've got a .fla (flash8) file with a combo box and a submit button. I want the drop box
to hold the values of some frame names. On the submit the resutls frame just does a transition between the screens. On frame one there is this code:
Code:
function comboDisplay (component) {
combo = component.getSelectedItem().data;
_root.gotoAndStop("results");
trace ( combo );
}
// We assign the function to the combobox
nav.setChangeHandler ("comboDisplay") ;
onSubmit=function(){
comboDisplay (nav);
}
addListener(nav);
addListener(submit);
The Movie clip I'm using as a transition has an action to stop then go to the framename that is the same as the combo variable. like so:
Code:
stop();
_root.gotoAndStop(combo);
Is there something i need to do to read this as as a string or am I messing up the useage of _root? It wont go to the proper frame after the animation plays.
heres a link to a watered down version with only the barebones of the file.
Http://www.union.ksu.edu/tutorialHelp.fla
_root Timeline GotoAndStop
Hi
I'm having problems getting a movie clip button on the main timeline to tell the main timeline to gotoAndStop a label when clicked.
This shoulbe be straight forward.
The script is below - any ideas on what the issue is?
Thanx
Dirk
on (press) {
//Start Dragging Movieclip Behavior
startDrag(this, false, 168, 224, 564, 476);
this.swapDepths(this._parent.getNextHighestDepth() );
n=this.getDepth();
_root.introBox.swapDepths(n+1);
//End Behavior
}
on (release) {
if(getTimer()-lastClick < 500){
_root.gotoAndStop("nointro");
loadMovieNum("http://www.dirksmith.com/flash_2/port_allianz.swf",50);
}
lastClick=getTimer();
stopDrag();
}
on (rollOut) {
stopDrag();
}
_root Timeline Placement For AS Animated MC's
I am having problems here that might be difficult to explain, so please bear with me. I will attach my .fla in order to clarify.
I have an Actionscripted animation that works fine. Its a nice bouncing ball. It is a MC, where the AS is located within the _root.ball timeline, and consists of four frames which cycle untill the animation reaches its final position then it stop()s, but all of which runs in just one frame in the _root timeline. I also have other AS animations each consisting of one frame in the _root timeline, but within the respective MC timelines, all consist of multiple frames which all loop untill an end position is reached and then stop().
I want to run the ball MC and one other one (bottomline MC if you are looking at the .fla) at the same time, and then when the ball stops I want to run a third MC (ballmarcus), and so on. My difficulty comes in when trying to place any MC where it would run AFTER the ball one comes to completion.
Yeah, thats the situation and problem. I hope this makes sence and someone out there can offer a solution or at least guide me in the direction of where to find a solution on my own. I know this type of issue will come up often in my animations, as I am trying to do as much movement in AS as possible. If I just can learn the principles behind this solution, I am sure I can apply it as needed.
Of course, any time and help is greatly appriciated.
Advance _root Timeline With Keys
Hello,
I have flash movie that I would like to advance the frames by using the left/right, PGUP/PGDN, and down/up keys.
My problem is with the code I have created, if I start on frame 1 and advance to frame 2, everything is fine. But if I now go back to frame 1 and them advance forward one frame, I end up at frame 3.
What am I doing worng, and is there a better way of writing this code?
Note - This AS is located in a emtpy movie that I want to drop onto my stage called keycode. This works if it is on frame 1 of the root timeline.
if (myKey == undefined) {
myKey = new Object();
myKey.onKeyUp = function() {
if (Key.getCode() == Key.RIGHT) {
_root.nextFrame();
}
if (Key.getCode() == Key.LEFT) {
_root.prevFrame();
}
if (Key.getCode() == Key.UP) {
_root.prevFrame();
}
if (Key.getCode() == Key.DOWN) {
_root.nextFrame();
}
if (Key.getCode() == Key.PGUP) {
_root.prevFrame();
}
if (Key.getCode() == Key.PGDN) {
_root.nextFrame();
}
};
Key.addListener(myKey);
}
Newbie MC Problems From _root Timeline...
to whom it may concern,
If any of you ladies and fellows could advise me in this, I would be humbly grateful:
My current project has various (for this example, I'll restrict discussion to a single one of my buttons who's instance name is "A2Button") buttons that effect the alpha values of various stacked MCs so that "clip A" appears to be replaced by "clip B" on roll over and vice versa in the following manner:
on (rollOver) {
setProperty("cilpA", _alpha, 100);
}
on (rollOut) {
setProperty("clipA", _alpha, 0);
}
on (rollOver) {
setProperty("clipB", _alpha, 0);
}
on (rollOut) {
setProperty ("clipB", _alpha, 100);
}
I've tested these bits of script and all is well and it's all good. Things work. My whole movie works. However, when all is said and done and everything is moving around and doing it's thing, my frame rate drops to about 3 or four frames a second. So in the process of making things more efficient and move faster and smoothly, I've done things like eliminated as much frame by frame animations as possible in favour of tweens etc. One of the things that I'm trying to do at this point is to move as much of my scripting onto the main timeline as practically possible.
So...
I'm now attempting to move all of the aforementioned script off of the buttons themselves and onto my "actions" layer on my main timeline.
I've tried various things. My current code (which is not working) looks like this:
_root.A2Button.onRollOver = function(){
setProperty(_root.clipA, _alpha, 100);
}
_root.A2Button.onRollOut = function(){
setProperty(_root.clipA, _alpha, 0);
}
_root.A2Button.onRollOver = function(){
setProperty(_root.clipB, _alpha, 0);
}
_root.A2Button.onRollOut = function(){
setProperty(_root.clipB, _alpha, 100);
}
So, uhhh....what the hell is my problem? I feel like I'm so close to getting this right but unlike spoken language, close won't cut it at all.
Please help. Pretty please.
with courtesy,
MH
Target The _root Timeline With ' If ' Statement
Hi,
I am trying to target the stage of the sub loaded movie from the main timeline but with ' if ' statement:
For example:
1) I am inside swf file called market.swf and the length of the _root timeline is only 10 frames
2) I am on the frame 1 of the _root stage inside market.swf
3) I have a movie clip holder,
4) on this holder i load a another swf file called sales.swf
5) I am trying to control the _root timeline of the sales.swf from market.swf but depending on the current frame position of the _root stage (market.swf)
for example: if the current frame of my _root (market.swf) is frame 8 then the _root of sales.swf should stop on frame 4
this is really easy task to do, i mean i could easily achieve this by giving an instance name to the holder mc and target that mc with gotoAndStop
but what i really need to do is exactly this but with if statement
please anyone good with actionscript?
Thanks
Controlling An MC With AS On _root Timeline. What Am I Missing?
My stage is empty except for an MC with a simple animation and an AS 2 layer. There is not a button or user interaction that engages the MC. I want the MC to play when the timeline reaches the frame with the AS. My MC has an instance name of 'blueMC' and here's the AS I've tried:
blueMC.play();
_root.blueMC.gotoAndPlay("2");
on(load)
{
blueMC.play();
}
onClipEvent(load) {
blueMC.gotoAndPlay("2");
}
Shouldn't it just be this?: MCinstanceNmae.gotoAndPlay("Frame# or label");
Thanks, I feel like I'm missing something simple.
Can An External Movie Target _root Timeline?
I have a page that loads external movies.
on (release) {
loadMovie("mymovie.swf", "_root.linkmc");
}
When mymovie is loaded I then want to target _root timeline
on (release) {
_root.gotoAndstop(2);
}
I have tried _parent and tried assigning a custom name to the root timeline and then refering to that custom name, but to no avail, is it possible to target the _root timeline from an external movie thats been loaded into an empty movie clip?
Thanks
mr mooch
Droptargets Dont Work If Not On _root Timeline?
http://www.kirupa.com/developer/acti...t/dragdrop.htm
i did this tutorial, but for the life of me i just cant get the droptargets to work if the objects arent on the root timeline.
can anyone please lend a hand
Prefered Way To Make Changes To Timeline In A Class (aka Not Using _root)
I know I shouldnt be using _root in my class files to modify movieclips/etc on the timeline because in case i decide later to load this .swf in another movie, then _root will refer to wrong timeline (unless use 'lockroot')...
Anyway I was a bit confused cause people say always use the 'this' keyword instead of _root in your classes, but refering to 'this' in your class files refers to the object itself and not the timeline. so what is prefered way to make make changes to timeline in a class?
thanks, Arian
Set External Swf Preloader Bar To Width & _x _root Timeline
hi everyone,
can anyone help me with a small matter - i am loading external swf's into the main swf and want the preloader bar of the swf to be loaded to automatically locate at '0' of the main swf and set its width to the main stage width.
all help much appreciated,
thanks in advance,
pat
Referencing Buttons (simple)
I feel like chump at the moment... you guys are the only ones i can turn to for a quick answer.
All i need to know is how to referrence buttons and assign actions to them. I don't want to put the code directly on the button instance, but rather referrence the button from an actions layer.
Here is what I had.
HTML Code:
DRW.onRelease=function() { trace ("Hello")}
DRW is the instance name of the button.
Eek!
|