Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash








Detect All OnEnterFrame Events


hi all,
i had this thought and wonder if anyone has an idea if it is possible:

scenario: you have a swf with several different animated movieclips inside. each one has an onEnterFrame function (or an interval) inside that powers the animation.

question: is there a way of detecting all onEnterFrame (and/or intervals) in the movie from the root without having to store a reference to every single one?

any pointers appreciated.




ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 02-09-2007, 06:08 PM


View Complete Forum Thread with Replies

Sponsored Links:

How Do You Use OnEnterFrame For Multiple Events
I have written some code for a movie clip's onRollOver like this:

this.my_mc.onRollOver = function() {
this.onEnterFrame = function() {
this._alpha -= 0.8;
this._rotation -= 3;
this._xscale += 5;
this._yscale += 5;
if (this._alpha <= 0) {
delete this.onEnterFrame;
this.removeMovieClip();


Now as i understand it, you can only use onEnterFrame once per movie clip, so how would i have my_mc change some of its other properties on onRollOut using onEnterFrame as well the onRollOver (say decrease _xscale to zero. Any ideas ??

thanks
Greg

View Replies !    View Related
Conflicting OnEnterFrame Events
I've gone through past posts and this seems to be a common problem: one onEnterFrame event cancelling the other. Set Interval is suggested but I'm not sure if it could work in my case: I use one onEnterFrame for a preloader and the second for movement of the images (that function basically checks what's the current position of the image in relation to point X and moves it accordingly to the left or right). It is my impression that in both situations onEnterFrame is necessary but I'd love to be wrong

View Replies !    View Related
Add Functions To OnEnterFrame Events..
hi,
is this possible to add things to do in onEnterFrame events ??
for exemple i have two function:

function movex() {
t++;
this._x = Math.cos(t/10)*100;
}
function movey() {
t++;
this._y = Math.cos(t/10)*100;
}

what i want to do is call the function on a MC:

myMC.onEnterFrame = movex

and later, add the other function to the onEnterFrame event without killing the first one...

see what i mean ?

View Replies !    View Related
OnEnterFrame Triggered By Mouse Events
So basically my idea is as follows, i have this shape stored within a movie clip, instance named "maskMC", that i want to use as a mask for other movie clips, no big deal so far.
But the idea is to trigger onEnterFrame events for this mask to expand in x and y whenever i mouse over or click it etc.
My first attempt was to write something like this. Code:

_root.maskMC.onRollOver.onEnterFrame = function(){}
However i quickly realised this wasn't gonna work, so i tried variables instead, but for some reason, it seems like Flash will only see one of the mouse events.
For instance, when i added my onRelease part of the code, the only thing that would work was when i clicked the MC, not when i rolled over it.

Any ideas on how to solve this problem?

Code:

_root.maskMC.onRelease = function() {
   clicked = true;
}

_root.maskMC.onRollOver = function() {
   rolloverred = true;
}

_root.maskMC.onRollOut = function() {
   rolloverred = false;
}

if(rolloverred == true){
   _root.maskMC.onEnterFrame = function() {
      if (_root.maskMC._yscale < 600) {
         _root.maskMC._yscale += 8
      }
   }
}else{
      if(_root.maskMC._yscale > 500) {
         _root.maskMC._yscale -= 8
      }
}

_root.maskMC.onEnterFrame = function() {
   if(clicked == true) {
      if(_root.maskMC._xscale < 1000) {
         _root.maskMC._xscale += 12
      }
   }
}

View Replies !    View Related
Can You Detect Mouse Events On MC's?
Is there a function in flash which allows you to know if a particular MC was clicked? Or pressed? Or hovered over? Any way of detecting mouse events on MCs?

I am new to AS but I have been studying functions for 1 day and a half but I still cannot find a solution to my problem.

1)I have an MC (MC-X) with 4 specific labels

2)There are 4 other MC's(John,Tracy,Paul) on the main _root which correspond to 3 of the labels in MC-X

3)MC-X should play the correspondent of each one of the MC's everytime they are rolled over.

4)If none of the 3 mc's interact with the mouse, MC-X should stay put on its fourth default label

I believe that the switch function should be applied in this case, but how do I parse the John, Tracy and PAul?

I tried this code(updated version):





MovieClip.prototype.WhichLABEL = function (){
var SctnMC
switch(_root.SctnMC.onRollOver){
case "John":
this.gotoAndStop("johnLabel");
break;
case "Tracy":
this.gotoAndStop("TracyLabel");
break;
case "Paul":
this.gotoAndStop("PaulLabel");
break;
default:
this.gotoAndStop("defaultLabel");
}
}


Obviously it doesn't work, I feel like I am mixing everything up. I don't know it is is a synthax problem "_root.SctnMC" or if it is not the right way of calling a mouse event.

Thanx in advance!

View Replies !    View Related
Can I Detect Mouse Events On A Movie That Has Transparent Areas?
let me be more specific...I want to detect mouse events on areas of a movie clip that have no content, but other areas of the movie clip will have content. So it's not an empty movie clip, it just has empty areas. make sense? I want to detect events on those empty areas.

also, how do I get the movie clips that are nested in the previously mentioned movie clip to register w/o triggering the parent movie clip? thx in advance for replies!

View Replies !    View Related
OnEnterframe Events Within "for" Loops
Would anyone know a better way to do this? I'm using the attachMovie to generate a series of buttons the stage. When the enter the stage I would like the to perform an action. Such as move right. Would anyone know why the code below is not working? Is it a timing issue? Thanks.


for (i=0; i < 5; i++){
attachMovie("block_mc", "test_mc"+ i, i);
this["test_mc"+i]._x = 98+(i*100);
this["test_mc"+i]._y = 20;
this["test_mc"+i].onEnterFrame = function(){
this["test_mc"+i]._x += 5;
}
}

View Replies !    View Related
OnEnterFrame=null, OnEnterFrame=undefined & Delete OnEnterFrame....
onEnterFrame=null, onEnterFrame=undefined & delete onEnterFrame....


Which one to use??? What are the performance considerations. If all my movieclips on-stage are running a MovieClip.prototype.onEnterFrame = function() {run initial stuff before setting onEnterFrame=null/undefined... }, will there be performance hits? It's sad that delete onEnterFrame doesn't work unless I delete the prototype enterFrame as well, which would make the clips reinitailise itself again once you declare the enterFrame prototype again (i need to do this since there's more movieclips that end up appearing on-stage, and they need to automatically initialises themselves the moment they appear).

It seems that setting enterFrame to null or undefined is the safest way to go about it, since dealing with multiple .swfs would mean using the same MovieClip.prototype, which means I can't afford to flush out one zone of enterFrames (by deleting both null enterframes and MovieClip.prototype.onEnterFrame) if it means the other zones still needs to initialise their clips first...it's just too troublesome and buggy a mechanism to implement! Once MovieClip.prototype.onEnterframe is declared, it should stay. Will there be performance hits as a result of this?

Is there anyway to do this without tricking the engine to call the onLoad function for MCs by typing "//" into each movieclip actionscript box --- or by troublesomingly creating linkage-ids for every movieclip library item!? NO! That's not what i want...they'll only add to the fiile size! How do i execute a certain "constructor/initilisation" function to all Movieclips without linking them to a class in a library? Something to think about.....

View Replies !    View Related
What Difference Between Mc.onEnterFrame And Funtion OnEnterFrame()
Dear, All,
Could anybody tell me the difference about them, I am fresh......

thanks in advance

View Replies !    View Related
Problem With OnEnterFrame And Delete OnEnterFrame
Ok here is the nuts of the problem,

When I delete the onEnterFrame function programatically I can't reassign it later.

Here is what is happening:
I have a method that I call to build a box on the screen over time. I build it overtime using the onEnterFrame function.
When the application is done it delete the onEnterFrame just fine.

Everything works as expected until you try to assign the same method over again to say for instance make the box smaller. Once I try to call it again I can't assign the onEnterFrame again... I have no idea why it is totally strange.


Code:
//Create an interface
//mc:MovieClip, x:Number, y:Number, w:Number, h:Number
InterfaceBuilderClass.prototype.createInterface = function(mc,x,y,w,h)
{

mc.dy = (h/2)*-1
mc.dx = (w/2)*-1
mc.dy1 = h/2
mc.dx1 = w/2
mc.NFRAMES = 40;
mc.controller = this;
mc.t = 0;

mc.onEnterFrame = function()
{
if (this.t++ < this.NFRAMES) {
trace(this.t);
//DELETED DRAWING STUFF THAT IS NOT AFFECTING THE PROBLEM

}else
{
//redraw with rounded corner
//DELETED DRAWING STUFF THAT IS NOT AFFECTING THE PROBLEM

this.controller.executeCallBack()
delete this.onEnterFrame;
}
}
}

Try it for yourself and see if you can make it work.

If anyone else has run into this problem I'd love to know how you resolved it.

Thanks,
Mark

View Replies !    View Related
Re-initialising OnEnterFrame After Deleting OnEnterFrame
Hello to all the actionscript guru's!

I have this thing where when I click this other thing which is controlled by a different thing which gets deleted after I click the other thing and I would like to know if I can sort of undelete the different things thing????

Okay, now in English.

I have some movieclips that move using an onEnterFrame. When you click on a movieclip, I stop the movement by deleting the onEnterFrame. Is there a way to re-initialise the onEnterFrame to get the movieclips moving again?

A thanks in advance for everyone who reads this question

View Replies !    View Related
Delete OnEnterFrame; Start OnEnterFrame?
Hi, title says it all.... any consise methods to restart a deleted onEnterFrame that has been deleted?

Thanks!

View Replies !    View Related
Delete OnEnterFrame Re-establish OnEnterFrame
i'm trying to stop an onEnterFrame [via the delete onEnterFrame] but later re-establish it, or restart it. is this even possible?? anyone got suggestions if it ain't??

View Replies !    View Related
Register Classes - Mc Events Vs Button Events
I'm experimenting with register classes today, and wasn't careful typing the code with only button events for my custom movie clip class.
First I wrote

Code:
CustomClass.prototype.onMouseDown = function(){
this.gotoAndStop("blue");
}// end onMouseDown
Then all the mc-buttons in my movie went to the blue state. (.fla provided)
When I realised the error, I corrected it, and now it works.
I just don't understand what happened.
Do Movie Clip events turn out to be class methods (don't know what to call it in Java script, only used to Java), while button events stay instance events??
Hope somebody have the time - it's not about life and death, but it would be really nice to know how these things work.

View Replies !    View Related
[F8] OnEnterFrame Inside OnEnterFrame
this is a simplification of what I have:

function fadeOutBorder(thumbnail){
this.onEnterFrame = function() {
if(this["thumbnail"+thumbnail]._alpha>0) {
this["thumbnail"+thumbnail]._alpha-=5;
}else{
this["thumbnail"+thumbnail]._visible=false;
//delete _root.onEnterFrame;
}
};
}


function loadThumbnails(){
onEnterFrame{
//stuff here...
fadeOutBorder(5);
//when that^^ is called... it quits the rest of the script...
//more stuff here...
};
}


So what happens is when I call fadeOutBorder.. It just stops that onEnterFrame in the loadThumbnails function.

View Replies !    View Related
Respond To Mouse Events Inside A Movieclip That Has Mouse Events...
I have a main MC that has a couple of mouse events associated with it (onPress mainly). There are also MC's inside this main MC that have Mouse events associated to them (onPress, onMouseMove, onRelease). The child MCs don't seem to get the mouse events (which makes sense, the parent is taking over the event)...how can I make this work? I don't want to have to delete and recreate the event handlers like 900 times as its not efficient...there has to be a better way.

View Replies !    View Related
Can Events Trigger Other Events?
Hello brothers and sisters of the Nets most helpful community!

I am going insane in the membrane trying to get my custom cursor to work in my scene. I have successfully completed many tutorials about how to do this in AS3 (the danielmclaren.net solution was particularly helpful) and have scoured this forum a bit for info, and (gasp) also read through a bunch of stuff on live docs. But, alas, I cannot understand why I cannot get the custom mouse (cursor) to work in my file. It works like a charm until I try hammering it into my scene.

I believe that the problem has something to do with with too many events being fired off at the same time and (possibly) my not removing them at opportune times. Or, maybe my coding style is not so elegant? Anyway, the FLA (with easy-to-read structure and commenting) can be downloaded here since I am not certain which part of my code is causing the custom cursor not to work. With all the comments, it should not be too difficult (I hope) to see what it is I am trying to do.

Any feedback would, as always, be most appreciated.

Download_FLA

Regards,

-john

View Replies !    View Related
Mc.onEnterFrame = Foo() ?
I am trying to dynamically give MCs the onEnterFrame event handler. I have 4 MCs on stage each with the name: clip1, clip2, clip3, clip4. Each clip does the onLoad, but only the first clip rotates; furthermore, the trace in rotate only outputs the first clip...

Code in frame 1:

var clips = [clip1, clip2, clip3, clip4];

// Make each clip 50% alphaed onLoad
function init(s) {
s._alpha = 50;
}

// Rotate each clip 5 degs onEnterFrame
function rotate(s) {
trace(s);
s._rotation += 5;
}

for(i in clips) {
s = clips[i];
s.onLoad = init(s);
s.onEnterFrame = function() {
rotate(s);
}
}

Any thoughts?

tx!

View Replies !    View Related
Onenterframe
I using a bit of actionscrpt I found from your message boards which I then changed and began to understand. It was for making a menu come into the screen when pressing space. The problem I have is after it has loaded you have to click on the frame to make the menu come in when space is pressed. I believe it is something to do with the "onenterframe".

this is the code:

menu.onEnterFrame = function() {
if (Key.isDown(Key.SPACE)) {
if (menu._x<0) {
menu._x += 20;
}
} else {
if (menu._x>-80) {
menu._x -= 20;
}
}
};

have tried to change it to "onLoad" but that does not seem to be it. Would love any help as this has been driving me mad of days. my website www31.brinkster.com/anpond/ that is the old one. The one I am going to replace it with is www31.brinkster.com/anpond/movie/ Thanks for your help.

View Replies !    View Related
OnEnterFrame
Hey,

I'm jus' learning the onEnterFrame stuff...

And I've got a problem:
Why cant I use more then 1 onEnterFrame per MC?

The reasong I'm asking this is because I have different types of code, and to make the code better to look at, I want to store the code on different layers, so I would also need more then 1 onEnterFrame events... but I can't get it to work... is there a way to solve it or something?

View Replies !    View Related
Getting Out Of A OnEnterFrame()?
Hi all!

I am having problems getting out of an onEnterFrame(). What I want to do is making a movieClip invisible, but once the ._alpha is below 0 I need to break out of the onEnterFrame(). However, I cant seem to get it rigth!

Here is some code:
code:
instance.onEnterFrame = function(){
instance._alpha -= 20;
trace("alpha is"+instance._alpha);
if (instance._alpha < 0) {
return;
}
};


Hope there is any help out there!

Ciao ciao

View Replies !    View Related
OnEnterFrame
Hi

I use movieclip placed in first frame of scene:

onClipEvent(enterFrame){}

I want to know how to use button to execute this movieclip in place of using onClipEvent(enterFrame).

Thanks a lot

View Replies !    View Related
OnEnterFrame
I was just wondering how many onEnterFrames are kosher for a site. Does it matter? Or, does it just depend on the complexity of the code within?

View Replies !    View Related
Mc.onEnterFrame
why is this only being run once, not every frame?

mc.onEnterFrame = myFunctionName();

function myFunctionName() {
mc._x-=10;
};

View Replies !    View Related
OnEnterFrame Use
Hi There,

I've been using a tutorial from flash kit to help me learn a bit more about using sound, and have come across a bit of code that i've assumed works in the same way as an onClipEvent handler but is placed on a single stopped frame rather than on an MC.

I just needed to know if this is correct as I can't find any referance to it in any of my scripting books:

this.onEnterFrame=function() {
if (playing==true) {myText02="play"}
if (playing==false) {myText02="stop"}
}

Thanks for any help

Parish

View Replies !    View Related
[AS] OnEnterFrame
I can navigate forward and back allong my movie. I want this code to be triggered if I land somewhere in the second half.
this code sits in a keyframe that runs the length of the second half of my movie

Code:
moveLeft.onEnterFrame = function() {
if (_root.mainScreen01._x >= -55) {
_root.mainScreen01._x -= 10;
}
}
canvasMoveLeft = setInterval(moveLeft,20);
At the moment it only works if I just play the movie through from beginning to end.
any thoughts?
Thank you,
Tim.

View Replies !    View Related
For And OnEnterFrame
I have instanced 11 movice clips : bg1, bg2, etc...
No i have this on the main timeline
code:
for (j=1; j<=100; j++) {
_root["bg"+j].onEnterFrame = function() {
if (_root["bg"+j].areahit.hitTest(_root.trashplayer.hitarea) and _root.yspeed>0) {
_root.trashplayer._y = (_root["bg"+j]._y-(_root["bg"+j]._height/2))-2;
if (_root.yspeed<0) {
} else {
_root.jump = true;
_root.jumpback = true;
}
_root.yspeed = 0;
_root.trashplayer._y -= 1;
}
if (_root.doneonce != true) {
if (_root["bg"+j].areahit.hitTest(_root.trashplayer.hitarea)) {
_root.trashplayer._y = (_root["bg"+j]._y-(_root["bg"+j]._height/2));
_root.doneonce = true;
}
}
if (_root.ff) {
_root["bg"+j]._x -= _root.scrollspeed;
}
if (_root.rr) {
_root["bg"+j]._x += _root.scrollspeed;
}
if (_root.up) {
_root["bg"+j]._y -= _root.scrollspeedy;
}
if (_root.down) {
_root["bg"+j]._y += _root.scrollspeedy;
}
if (_root.shake) {
_root["bg"+j]._x += _root.shakex[_root.i];
_root["bg"+j]._y += _root.shakey[_root.i];
}
};
}

Why the F*ck do the mcs not move? I have put a trace action after
if (_root.down) { , and it got traced, so apparently the moving is having a problem.. putting this instead of _root["bg"+j] makes the entire time line move...help

View Replies !    View Related
HELP: OnEnterFrame
Hi,
I am trying to manipulate 200 different layers at once within a movieclip. (each layer represents a person and as the movie progresses they flow towards a common destination)
My problem is that I currently have all 200 layers being moved within one onEnterFrame() function which then contains a for loop - looping through each 200 people (on each layer) and updating their x/y co-ordinates).
This seems to be very slow and cause jerky movements - presumebly due to on every frame it has to loop through and update 200 layers!

Is there a better way of doing this?
Have tried calling 200 dif onEnterFrame functions at start within a for loop but this doesnt work.
Have also considered the onInterval function but has same problem?

Any advice? HELP!!

Cheers,
Brad.

View Replies !    View Related
OnEnterFrame?
Hi,
I am trying to manipulate 200 different layers at once within a movieclip. (each layer represents a person and as the movie progresses they flow towards a common destination)
My problem is that I currently have all 200 layers being moved within one onEnterFrame() function which then contains a for loop - looping through each 200 people (on each layer) and updating their x/y co-ordinates).
This seems to be very slow and cause jerky movements - presumebly due to on every frame it has to loop through and update 200 layers!

Is there a better way of doing this?
Have tried calling 200 dif onEnterFrame functions at start within a for loop but this doesnt work.
Have also considered the onInterval function but has same problem?

Any advice? HELP!!

Cheers,
Brad.

View Replies !    View Related
Please HELP - OnEnterFrame
Hi,
I am trying to manipulate 200 different layers at once within a movieclip. (each layer represents a person and as the movie progresses they flow towards a common destination)
My problem is that I currently have all 200 layers being moved within one onEnterFrame() function which then contains a for loop - looping through each 200 people (on each layer) and updating their x/y co-ordinates).
This seems to be very slow and cause jerky movements - presumebly due to on every frame it has to loop through and update 200 layers!

Is there a better way of doing this?
Have tried calling 200 dif onEnterFrame functions at start within a for loop but this doesnt work.
Have also considered the onInterval function but has same problem?

Any advice? HELP!!

Cheers,
Brad.

View Replies !    View Related
OnEnterFrame
I have this code on the first frame inside a mc.
------------------------------------------------------------------
reedstartX=reed._x;
reedstartY=reed._y;

function reedani() {
while (breakwhile == false) {
reed.onEnterFrame = function() {
reed._x = this._x+1.6*5*accel+1.6*(.5*-2*accel*accel);
reed._y = this._y+5*accel+1*(.5*-2*accel*accel);
accel = accel+.5;
trace(reed._x);
if (reed._x<reedstartX) {
reed._x = reedstartX;
reed._y = reedstartY;
breakwhile = true;
}
trace("reedanirunning");
};
--------------------------------------------------------------------

as of now when i call the reedani function, its an infinite loop so i can't even see if my logic is right. I'm not sure what (name).onEnterFrame=function(){ blah}; does. "reed" is an mc inside the same clip. Can onEnterFrame be used this way? If so, what am i doing wrong.

View Replies !    View Related
This.onEnterFrame
alright. I have this preloader which is preloading a movie. The only problem is that my code doesn't seem to be going. From what I can tell it works all up until the point I get to the line
code:
this.onEnterFrame = function () {

I will post the fla here so that you can see the preloader. And here is the code.
code:
loadText = "";
this.fill_in._visible = false;
this.fill_in._xscale = 0;
this.loading._visible = true;
this.graph._visible = true;
this.loadBar._visible = true;
this.createEmptyMovieClip("container", 5);
trace ("I got this far");
container.loadMovie("file:///C|/Kesler's File/Name_Movie.swf");
this.onEnterFrame = function() {
percent = Math.floor((this.container.getBytesLoaded()/this.container.getBytesTotal())*100);
trace (percent);
if(!isNan(percent)){
if(percent == 0) {
loadText = "";
} else {
loadText = percent + "% Loaded";
this.fill_in._xscale = percent;
}
this.loadBar._visible = true;
this.graph._visible = true;
this.loading._visible = true;
} else {
if (percent == 100) {
loadText = "";
this.loadBar._visible = false;
this.graph._visible = false;
this.loading._visible = false;
loadMovieNum("file:///C|/Kesler's File/Name_Movie.swf", 0);
}
}
};
stop();

View Replies !    View Related
OnEnterFrame _x _y / Help Me Please...
Hi all,

in this code:

this.onEnterFrame = function() {
_x = (_x + (X - _x) / 8);
if (_x >= (X - 1) && _x <= (X + 1)) {
_x = X;
_y = Y;
this.onEnterFrame = undefined;
}
};


I need exactly to define position of object. Example x = 400 y = 500.
Is someone gonna help me?

View Replies !    View Related
OnEnterFrame
Does anyone know how to attach onEnterFrame commands to movie clips and/or assign them an ID someway so that if you have multiple onEnterFrames running they're not all deleted when you run the delete onEnterFrame command?

View Replies !    View Related
OnEnterFrame Help
I am using the following code with my flv to attach some movieclips, but the movieclip open_close_mc, does not play. The coverPlate_mc gets moved, so I am assuming that the other movieclips are being attached.

Can a movie clip play from an onEnterFrame function?



Code:
_root.stop();
var netConn = new NetConnection();
netConn.connect(null);
var ns = new NetStream(netConn);
my_video.attachVideo(ns);
ns.setBufferTime(5);
ns.play("videos/g2_crush_raw.flv");
// adjust flv volume
this.createEmptyMovieClip("flv_mc", this.getNextHighestDepth());
flv_mc.attachAudio(ns);
var audio_sound8:Sound = new Sound(flv_mc);
audio_sound8.setVolume(audio_sound8.getVolume()+100);
updateVolume();
//
getTotalTime = function () {
ns.onMetaData = function(obj) {
_global.videoDuration = obj.duration;
trace(obj.duration);
};
};
onEnterFrame = function () {
getTotalTime();
totalPlayingTime = Math.round(_global.videoDuration);
currentPlayingTime = Math.round(ns.time);
trace(ns.time);
if (ns.time>=10) {
//move the cover plate
coverPlate_mc._x = -300;
//add the cover ring
attachMovie("ring_mc", "RC", 20);
RC._x = 4;
RC._y = 73;
//add the open-close sequence
attachMovie("open_close_mc", "MC", 10);
MC._xscale = 34;
MC._yscale = 34;
MC._x = -32.1;
MC._y = 65.3;
//add the gman
attachMovie("gman1_mc", "GMAN", 5);
GMAN._xscale = 30;
GMAN._yscale = 30;
GMAN._x = 37;
GMAN._y = 90;
}
if (totalPlayingTime == currentPlayingTime) {
// ns.seek(0);
// ns.pause();
ns.close();
gotoAndPlay("next10");
}
};

View Replies !    View Related
OnEnterFrame Help
I have an onEnterFrame function that I need to find a better way to handle becuase my code is getting increasingly complicated. What I am doing is using the onEnterFrame function to keep track of my FLV time. At certian intervals I need certian movie clips to play. So I have been working on away to clean up the code. Not to mention flash will not autoformat a function in a function.

Is there a way to stop the onEnterFrame function (or do this entirely in a different way), do something and then restart it. In the code below you can see I am running into mutiple "if" statments.


Code:
_root.stop();
var netConn = new NetConnection();
netConn.connect(null);
_global.ns = new NetStream(netConn);
my_video.attachVideo(_global.ns);
_global.ns.setBufferTime(5);
_global.ns.play("videos/g2_crush_raw.flv");
// adjust flv volume
this.createEmptyMovieClip("flv_mc", this.getNextHighestDepth());
flv_mc.attachAudio(_global.ns);
var audio_sound8:Sound = new Sound(flv_mc);
audio_sound8.setVolume(audio_sound8.getVolume()+100);
updateVolume();
//
getTotalTime = function () {
_global.ns.onMetaData = function(obj) {
_global.videoDuration = obj.duration;
// trace(obj.duration);
};
};
//
onEnterFrame = function () {
//
startTimer();
//
if (_global.ns.time>=10) {
trace("test");
delete onEnterFrame;
//
changeTitle("YOU'RE LOSING MONEY");
//
openGman();
//
// add the gman
_root.attachMovie("gman1_mc", "GMAN", 5);
_root.GMAN._xscale = 30;
_root.GMAN._yscale = 30;
_root.GMAN._x = 37;
_root.GMAN._y = 90;
//
onEnterFrame = function () {
startTimer();
// close stuff
if (_global.ns.time>=20) {
delete onEnterFrame;
//
closeGman();
//
onEnterFrame = function () {
startTimer();
}
}
}
}
};
//
//
//
// open gman
function openGman() {
// move the cover plate
_root.coverPlate_mc._x = -500;
// add the cover ring
_root.attachMovie("ring_mc", "RC", 20);
_root.RC._x = 4;
_root.RC._y = 73;
// add the open sequence
_root.attachMovie("open_mc", "MC", 10);
_root.MC._xscale = 34;
_root.MC._yscale = 34;
_root.MC._x = -32.1;
_root.MC._y = 65.3;
}
// close gman
function closeGman() {
_root.MC.removeMovieClip();
_root.attachMovie("close_mc", "AC", 10);
_root.AC._xscale = 34;
_root.AC._yscale = 34;
_root.AC._x = -32.1;
_root.AC._y = 65.3;
}
// change title
function changeTitle(title:String) {
// set chapter text
_root.chapter.chapter_w.autoSize = true;
_root.chapter.chapter_w.text = title;
_root.chapter.chapter_b.autoSize = true;
_root.chapter.chapter_b.text = title;
}
//
function startTimer() {
getTotalTime();
totalPlayingTime = Math.round(_global.videoDuration);
currentPlayingTime = Math.round(_global.ns.time);
flv_time.text = _global.ns.time;
}

View Replies !    View Related
OnEnterFrame?
Hi there,

Im trying to make this thing - that when this keyframe is arrived at, that the film has two options depending on whether a global variable is true or not. If that variable is true, it stops() at that keyframe. If it isnt true, it goes to and plays ("printos"). Only I dont have a clue of the correct syntax - my best bet would be the one below, but it doesnt work. What would be the correct way to write this please?


function.OnEnterFrame();
if(_global.printer == false){
gotoAndPlay("printos")
{
if(_global.printer == true){
stop();
}
}

View Replies !    View Related
Onenterframe
Please see the script below:

function moveSquare (whichSq, fade) {
whichSq.onEnterFrame = function(){
whichSq._alpha += (fade-whichSq._alpha)/3;
}
}

sq1.myButton.onPress = function(){
moveSquare(sq1, 100);
moveSquare(sq2, 0);
moveSquare(sq3, 0);
moveSquare(sq4, 0);
moveSquare(sq5, 100);
moveSquare(sq6, 100);
moveSquare(sq7, 100);
moveSquare(sq8, 100);
}

I have 8 squares on the page 4 start visible the other 4 are at alpha value 0. When the button is pushed the 4 visible change to 0 alpha and vice versa. The script works fine, but I want the 4 to fade in only when the first four have reached 0 alpha, at the moment they all change at the same time.

thanks for any help

View Replies !    View Related
OnEnterFrame
Hi everybody.

I am attempting to place an "onEnterFrame" script on an MC that I am loading ext. swfs into. Once something is loaded into the MC, I can not get it to work. Any hints?? Here is two versions of the script:
code:
//this traces once
holder_mc.onEnterFrame = function() {
trace("hi");
}
holder_mc.loadMovie(_root.myXML.vidList_0[0]);

//this does not trace at all
holder_mc.loadMovie(_root.myXML.vidList_0[0]);
holder_mc.onEnterFrame = function() {
trace("hi");
}

The only difference being the order... how can I get it to "stick" once the swf is loaded??

Thanks for any help,
1M.

View Replies !    View Related
End OnEnterFrame?
How do you get out of an onEnterFrame

I have a movie that makes something._alpha -= 20 untill the alpha <= 0. once i do that it removes the movie clip. But how do i exit the onEnterFrame loop, because once i do it again, since its still looping, it fades it out and takes the movieclip away.

So How do i exit an onEnterFrame function?


Code:
if (percentage == 100) {
onEnterFrame = function () {
loading._alpha -= 20;
if (loading._alpha<=0) {
percentage = 0;
loading._alpha = 100;
removeMovieClip(loading);
}
};
}

View Replies !    View Related
Help With OnEnterFrame Plz.
Hi, this code below, I use to make the car move and when it hits the Tree
the car explodes.
The problem is , I want to stop the car from moving as it hits the tree,
and so far struggling with it, any help would be very nice

on (release, keyPress "<Right>") {
car_mc.onEnterFrame = function() {
car_mc._x += 10;
if (car_mc._x>550) {
car_mc._x = 0;
}
if (_root.tree_mc.hitTest(car_mc) == true) {

_root.car_mc.gotoAndPlay("explode");

}
};
}

View Replies !    View Related
[F8] OnEnterFrame
This is my code:


Code:
this.onEnterFrame = function(){
if (_global.position == "start" && _global.door != "open" && _global.light != "on" ) {

_root.movie1_mc.gotoAndPlay ("start")
delete this.onEnterFrame;
}
}


This code seem to only work once! When the if statement all satisfy those conditions again, movie1 doesnt play. BUT when I did a 'trace a msg' the msg traced fine. So I dont understand whats going on?

View Replies !    View Related
[F8] OnEnterFrame And XML
Well I thought this was going to be easy but here I am on the board!

Simple timeline looking to load external images from an xml file into empty movieclip with the image switching when it reaches specific frames. I have the xml file loading and working okay and some dynamic text (also from the xml file) works fine but the image won't load. Here is the code I am using...

on the initial frame:

function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
}
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.onLoad = loadXML;
xmlData.load("content.xml");

this.onEnterFrame = function() {
picture._alpha = 100;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
}


Then on sequential frames where the image and text should switch...

this.onEnterFrame = function() {
picture._alpha = 100;
picture.loadMovie(image[1], 1);
desc_txt.text = description[1];
}

And so on with the array increasing when the next switch occurs. As I said Text works fine but no images... I can load an image in using a seperate function and hardcoding the url so I know the paths are right. HELP ME!

Thanks guys,
dptoot

View Replies !    View Related
How Much Is Too Much (to Do On An OnEnterFrame)
how much code do you need to be running on an onEnterFrame to get a significant performance issue? i currently have 21 lines and it seems ok, but am about to add more and am worried it'll start to chug. any thoughts?

View Replies !    View Related
[CS3] Would I Use A OnEnterFrame For This?
Hello,

I am using variables to control things, like this,

on (release) {

test = 4;

if (Number(test) == 4) {
home_btn_main.enabled = true;
about_btn_main.enabled = true;
gallery_btn_main.enabled = true;
contact_btn_main.enabled = false;
}

As you can see I define test = 4; with a on (release) action.

What I'm trying to do is put AS in a frame to make test = a number; when the timeline plays it. So, define test without a on () action, just define it when it plays it.

Would that be something like

onEnterFrame(){
test = a number;
}

I think I'm not understanding onEnterFrame though...

View Replies !    View Related
OnEnterFrame Within OnEnterFrame
OK . Code will loop within an onEnterFrame. And if another onEnterFrame is place within the first one, the code within that one will then loop instead. From here if I want to break out of the onEnterFrame, the delete function is used. My problem is that I only want to break out of the centre onEnterFrame and then resume looping the first one. Is this possible?
Seems the onEnterFrames could be side by side, so it exits out of oneand then enters into another, but I don't want to do it for this project.

Here is some simple code, in hope to get the answer some for my bigger project. Unfortunately this one breaks out of both onEnterFames - instead of onecode: loadMovie ("otherinfo2.jpg", myTitle);
onEnterFrame = function (small)
{
trace ("small");
this.onEnterFrame = function (big)
{
if (myTitle.getBytesTotal () == myTitle.getBytesLoaded () && myTitle._width != 0)
{
myTitle._height = 400 / (myTitle._width / myTitle._height);
myTitle._width = 400;
delete this.onEnterFrame;
}
};
};

View Replies !    View Related
How To Use OnEnterFrame?
Hi all,

I have attached a small alpha = 0 rectangle MC onto my mouse cursor. Like this:

onEnterFrame = function (){
attachMovie("dragger","dragger",10);
dragger._x = _xmouse;
dragger._y = _ymouse;
}

It works.

After which, i want to detect if there is a hitTest between the dragger MC and other MCs, with a mouse click, I want to drag the MCs, named 'meat'. Thus I did this:

dragger.onPress = function (){
onEnterFrame = function (){
if (dragger.hitTest(meat)){
meat.startDrag();
}
}
}

However, it doesn't respond. I gathered that it is the 'onEnterFrame' problem. When I take away the first portion of the coding, which is attaching dragger, meat MC can be dragged. After I added in, it can't.

Anyone knows what Im saying and can provide any solutions?

Thanks

Regards
Victor

View Replies !    View Related
How Do I Use OnEnterFrame?
Hi,

I'm fairly new to ActionScript. I was given an assignment in class. The assignment is to load five instances of a movieclip (_movieclip in library) using attachMovie, and have them placed vertically in a line, starting from (50,50). The clips are required to be in an array.

When a button on the stage is pressed, the first clip has to start playing, move horizontally to (550,50), and then stop playing, as well as its movement. Than, the second clip has to do the same horizontal movement. We were asked to use onEnterFrame in the example.

I tried a bit, and got the first clip to move. I have problems getting the others to move. Here's the code. Can anyone tell me how onEnterFrame really works?


PHP Code:



var mov_arr:Array=new Array();
var index:Number=0;
var ycoord:Number=50;

for(i=1;i<=5;i++) {
    var linkName:String="sample"+i+"_mc";
    _level0.attachMovie("_movieclip",linkName,getNextHighestDepth(),{_x:50,_y:ycoord,_width:50,_height:50});
    ycoord+=60;
}

mov_arr=[sample1_mc,sample2_mc,sample3_mc,sample4_mc,sample5_mc];

for(i=0;i<5;i++) {
        mov_arr[i].stop();
}
    
play_btn.onRelease=function() {
    for(i=0;i<5;i++) {
        mov_arr[index].onEnterFrame=function() {
            mov_arr[index].play();
            if(mov_arr[index]._x<550) mov_arr[index]._x+=10;
            else {
                index++;
                mov_arr[index-1].stop();
                mov_arr[index-1].onEnterFrame=null;
            }
        }
    }


View Replies !    View Related
I'm Going Mad OnEnterFrame
I can get so far then something stops me in my tracks.I'll be glad when I start a formal education for programming in August!Anyways I'm having this problem with an onEnterFrame event.My code is below;

ActionScript Code:
be.onLoad = function(){
currentPos = 0;
pos = [119,194,262,119,194,262,159,195];
currentx = 0;
posx = [55,55,55,45,45,45,40,35]
}

be.onEnterFrame = function(){
this._x = pos[currentPos];
this._y = posx[currentx];

if (currentPos>7) {
      currentPos = 0;
      currentx = 0;
    
}

}
I later tell a button.onPress function to do this

ActionScript Code:
currentPos++;
   currentx++;

Well that works fine for CurrentPos once i added currentx it killed my movie.the movie clip don't even show up on stage.I have got the trouble down to the onEnterFrame,by commenting out sections of my code.But i cant find tin that enterframe event what is causing the trouble.
Thank-you

View Replies !    View Related
OnEnterFrame
Hi guys. Im doing a menu that follows the menu, but i cant make it stop following the mouse. Heres the code i found at kirupa

onClipEvent (load) {
_x = 0;
_y = 0;
speed = 5;
}
onClipEvent (enterFrame) {
endX = _root._xmouse;
endY = _root._ymouse;
_x += (endX-_x)/speed;
_y += (endY-_y)/speed;
}

Works great but when i try to do the delete onEnterFrame(); it doesnt work. Can someone give me a hand please?

View Replies !    View Related
OnEnterFrame
I would like to fire the test1 function when my first XML file is loading, then, I would to delete it and fire test2 when my second XML file is loading. And I don't know how to do that

thanks


Code:
var my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success){
if (success){
delete test1.onEnterFrame
parseXML(my_xml);
}
}
my_xml.load("menu2.xml");


test1.onEnterFrame = function() {
Total = my_xml.getBytesTotal();
Lu = my_xml.getBytesLoaded();
rapport = Math.round((Lu)/(Total)*100);
_root.affichage.embedFonts = true;
_root.affichage.html = true ;
_root.affichage.htmlText = "<font face='DIN_Bold' size='24'>" + Math.round(rapport) + "</font>";
}

test2.onEnterFrame = function() {
Total = XMLContent.getBytesTotal();
Lu = XMLContent.getBytesLoaded();
rapport = Math.round((Lu)/(Total)*100);
_root.affichage.embedFonts = true;
_root.affichage.html = true ;
_root.affichage.htmlText = "<font face='DIN_Bold' size='24'>" + Math.round(rapport) + "</font>";
}

function parseXML(xml){
menuArray = new Array();
for(i=0;i<xml.firstChild.childNodes.length;i++){
langue = xml.firstChild.childNodes[i].attributes.langue;
menuArray[langue] = new Array();
for(a=0;a<xml.firstChild.childNodes[i].childNodes.length;a++){
//menuArray[langue][a] = xml.firstChild.childNodes[i].childNodes[a].attributes.label;
menuArray[langue][a] = new Array();
for(b=0;b<xml.firstChild.childNodes[i].childNodes[a].childNodes.length;b++){
//trace("menuArray[" + langue + "][" + a + "][" + b + "] = " + xml.firstChild.childNodes[i].childNodes[a].childNodes[b].firstChild.nodeValue);
menuArray[langue][a][b] = xml.firstChild.childNodes[i].childNodes[a].childNodes[b].firstChild.nodeValue;
}
}
}
var XMLContent = new XML();
XMLContent.ignoreWhite = true;
XMLContent.onLoad = function(success){
if (success){
parseXMLContent(XMLContent);
}
}
XMLContent.load("content.xml");
}

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved