[help] OnEnterFrame Looping Problem.
Hey guys,
I am attempting to fade in images loaded via an XML file programatically.
The following is my code:
ActionScript Code:
stop();
thumbXML = new XML;
thumbXML.onLoad = startThumbs;
thumbXML.load("secOne.xml");
thumbXML.ignoreWhite = true;
myThumbArr = new Array();
function startThumbs(success) {
if (success) {
rootNode = this.firstChild.childNodes;
totalThumbs = rootNode.length;
updateThumbs();
}
}
function updateThumbs() {
for (var i = 0; i<totalThumbs; i++) {
myThumbArr.push(rootNode[i].attributes.jpgURL);
iThumb = _root.tHolder_mc.attachMovie("Cont_mc", "thumb"+i, i);
iThumb.loadMovie(myThumbArr[i]);
iThumb.onEnterFrame = fadeIn;
//fadeIn(iThumb, 10);
placeThumb(i);
}
}
function placeThumb(j) {
iThumb._x = 110*j;
}
function fadeIn() {
var step = 100/d;
this._alpha = 0;
this.onEnterFrame = function() {
this._alpha += step;
if (this._alpha>=100) {
delete this.onEnterFrame;
}
};
};
All the beginning code loads the XML, and finally in the end I call the fadeIn function and attempt to fade in the image via it's alpha.
However my problem is that it only runs through the enterFrame loop once for each image loaded. meaning that the alpha of the image is 0. If I were to change the alpha to a higher number than 0 the image will appear, but at that alpha.
Does this make sense? I can try and clarify more if needed. I just want it to be able to increment the alpha until it is 100%. Is there a better way or is there something I am missing in the code?
Thanks in advance.
Ultrashock Forums > Flash > ActionScript
Posted on: 2005-03-28
View Complete Forum Thread with Replies
Sponsored Links:
How To Stop OnEnterFrame From Looping Forever...
hi,
i've got an mc with 2 sets of actionscript:
onClipEvent(load){
this._visible=0;
this.onPress = function(){
_root[this.ModelName].startDrag("");
}
this.onRelease = function(){
stopDrag();
}
this.onReleaseOutside = function(){
stopDrag();
}
}
then an onClipEvent(enterFrame) part resizes and positions some elements within the clip.
the problem is, the enterFrame continues to do this over and over again which eventually starts chewing up processing power.
I can't put the enterFrame actionscript in with the load part, because it needs to resize and reposition after an image is loaded...
any suggestions?
Cheers,
Ben
View Replies !
View Related
For Looping Dynamic Movieclips GetChildByName() OnEnterFrame HELP PLEASE
Hey All. Thanks for reading..
I built something some time ago in AS2 and now I'm trying to convert it into AS3, but I can't get a
hold of the dynamic movieclips; I keep on getting errors. Here is the original script in AS2:
Code:
this.onEnterFrame = function() {
for (var i = 0; i<10; i++) {
var xxm:Number = this["mc"+i]._xmouse;
}
}
And I've been trying it a number of different ways in AS3, but can't get it - either wrong or errors..
I've tried things like:
Code:
this.addEventListener(Event.ENTER_FRAME, test);
function test(event:Event):void {
for (var i:uint = 0; i<10; i++) {
var xxm:Number = MovieClip(this.getChildByName("mc"+i)).mouseX;
}
}
But like I said... not working out...
Please help - how do I do this?
Thanks.
View Replies !
View Related
AttachMovie Via Looping And Assigning OnEnterFrame Methods To The New Clips
I´m trying to attach movies from the library and also giving them an enterFrame function. It works well - BUT- the problem is that the function is working only for the last attached movie. I guess it has to do with the "i" variable. I want the onEnterFrame function to stick with the object itself. Have tried different solutions but I just can´t get my head around this. Any hints?
And the code.
ActionScript Code:
for(i=0;i<10;i++){
attachMovie("linkage_id", "linkage_id"+i, 100+i);
with(eval("linkage_id"+i)){
_x = 10*i;
_y = 10*i;
reversed = false;
onEnterFrame = function(){
if(!reversed){
nextFrame();
}else{
prevFrame();
}
}
}
}
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
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
[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
Looping Sound And Looping Animation Sync
I'm working on a navagation interface for a new site, and I'm running into a few issues.
1) when you click on a button, it activiates an MC. within that MC, the first frame is the initial "off" state, and clicking on a button triggers the rest of the clip to play, from frame 2. I have a sound that starts in frame 2, and I set up an animation of a VU meter that is supposed to be synced very closely to the music. In the last frame of the MC is an action, gotoandplay, that sends it back to frame 2. The idea here is that once the button is pressed, the music loops and the animation loops with it.
When I test the movie, do a publish preview, or view the swf file in the flash player, the animation seems to be synced to the music for the first few times it loops, but then the animation drifts ahead of the music, getting progressively further out of sync with each loop. The other real problem here, is that when viewing the swf in any web browser, the animation is immediately behind the music, and seems to be running much slower than it should.
you can see the swf here:
http://www.lsrdigital.com/flash/index.html
Does anyone have any ideas about how to get this to work the way I am trying to get it to?
the .fla file is here if you want to look at it as well:
http://www.lsrdigital.com/flash/LSR.fla
2) The other problem I'm having is that the stage is set to be 680 pixels wide, and the graphic that fills the background is 680 pixels wide, BUT Flash MX publishes the movie at only 679 pixels wide! You can see the line of white pixels on the right side of the movie here:
http://www.lsrdigital.com/flash/index.html
I've double checked the html file and the table cell holding the movie element is 680 pixels wide. You can also tell that Flash is cutting off the last column of pixels because the background image is visibly just missing the edge to the right of the screws.
Any ideas on that one?
View Replies !
View Related
Looping External Mp3 Not Looping Perfectly
Hi there
I have a looping external mp3 file playing in the background of my flash (Flash MX 2004) movie.
Unfortunately it does not loop perfectly even though I know the mp3 file loops perfectly in sound editing programs.
There seems to be a slight delay.
Here is my code
function Play_Background_Audio() {
myMusic.loadSound(audioFile,true);
myMusic.onSoundComplete = function() {
myMusic.loadSound(audioFile,true);
};
};
audioFile = "home.mp3";
myMusic = new Sound(myMusicMc);
Play_Background_Audio();
Any help would be much appreciated.
Thanks
Paul
View Replies !
View Related
Looping & Non-looping Components In Same Movie
I'm new to using Flash MX, and would be grateful if someone could give me some advice for this animation I'm trying to do.
I'm making a banner for a website that is being designed by someone else. The background consists of four photos that fade in and out continuously (I think "looping" is the correct term) as soon as the animation (movie?) opens up. That part wasn't too hard!
However, the client wants a name (in white text) to gradually fade in on top of the looping background, and stay visible and static for as long as the looping animation plays. As well, after the white name fades in and becomes static, she needs another name (in gold text) to gradually appear and start fading in and out below it.
So the sequence is:
- Looping background begins to play.
- The name (in white text) gradually fades in (say at around frame 50) and stays visible (alpha at 100%) while the background is looping.
- Around frame 100 a second name (in gold text) fades in and then starts fading in and out continuously in synch with the looping background.
I can't figure out how to do this. Do I need multiple time lines? Or triggers in various frames? Or different scenes?
I have a sinking feeling that I'm going to have to use Actionscript for this, and although I'm perfectly willing to learn, I haven't a clue where to start. Could anyone help, please?
View Replies !
View Related
Music Looping And Looping And.....
Hi all, thanks for taking a look at this.
I have made an Audio off/on button which I have added to the main scene, it has 2 frames, first one with the stop(); script and the second frame with
stop();
stopAllSounds();
but when i am navagating through the main scene the music loops onto itself till u end up with a god awful noise.
Help?!!
btw, I am using flash MX
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 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
[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
NaN And OnEnterFrame
This is probably really simple, but i'm stumped. I have the following code on the first frame of a MovieClip object:
Code:
var vy:Number;
var hit:Boolean
onEnterFrame = function()
{
trace(vy);
if(hit)
{
dis = this._y - 300;
vy = ((2*dis)/30);
}
}
"hit" is based on an external event, and i think not important in the problem. But after vy is updated from this event, the trace statement returns NaN.
Any ideas?
Cheers,
dannyW
View Replies !
View Related
When To Use OnEnterFrame?
I'm working on this flash piece where I'm inside a movie clip in the second frame of the main timeline and basically I want to tell flash that when you enter this frame, you need to go to the first frame of the main timeline without any action required by the user. The code I am using is:
Box1_mc.onEnterFrame = function () {
_root.wait_mc.gotoAndPlay(1);
};
While it seems this would work to me, it just takes me back to the first frame of that movie clip and it keeps repeating itself. Does anyone have any ideas?
Thanks in advanced.
Shanna
View Replies !
View Related
OnEnterFrame
Hello,
I've created a button and added an event listener to it. -- Works great.
Now I want what happens on the mouse event to happen when on the enterFrame, but I'm getting an Argument Error
ActionScript Code:
scrollButton.addEventListener(MouseEvent.CLICK, _scroll);
this.addEventListener(Event.ENTER_FRAME, _onEnterFrame);
function _scroll(evt:MouseEvent):void {
this.addEventListener(Event.ENTER_FRAME, _onEnterFrame);
}
What can I do to "trigger" this mouse event to start onEnterFrame?
Thanks
Tara
View Replies !
View Related
|