OnEnterFrame

I have a basic question about the onEnterFrame event handler.
I understand how this code will continually repeat the output trace
text:
onEnterFrame = function () {
trace ("onEnterFrame called");
but why does this only output the trace text once and stop:
onEnterFrame = RepeatFN()
function RepeatFN() {
trace ("onEnterFrame called");
}

What I think you want is this:
function myFunc(){
trace("hello world");
onEnterFrame=myFunc;
Notice there are no parens at the end of the onEnterFrame
assignment. With the parens it is saying, "Call this
function/method once and assign its return to the
onEnterFrame." So if your function returned a function you
would use the parens, thusly:
function myFunc():Function{
var myNewFunction=function(){
trace("Crazy man.");
return myNewFunction;
onEnterFrame=myFunc();
Does that make sense?

Similar Messages

  • Fade effect: how to do with "onEnterFrame"?

    Hi,
    I have a map with each city represented as a dot (MC). When
    you mouse over the dot, another MC with more city details/text
    quickly fades in, and fades out when you roll out. But I can't get
    the full fade effect working. Need your advice...
    In the dot MC, I put:
    on (rollOver) {
    _root.showCity();
    on (rollOut) {
    _root.hideCity();
    In the root, showCity() and hideCity() are functions to fade
    in and out the city details MC (city_sanfrancisco). I figured they
    should be at the root level so they can be used by other city dots
    (city_sandiego, city_boston, etc.) as well:
    //this lets me change the speed for fading in and another
    speed for fading out
    var speedIn;
    speedIn = 20;
    var speedOut;
    speedOut = 20;
    //hard-coded city for now; set city to invisible when movie
    starts
    var city = city_sanfrancisco;
    city._alpha = 0;
    //this shows the city details by fading in
    function showCity(){
    city._alpha += _root.speedIn;
    if (city._alpha > 100){
    city._alpha = 100;
    function hideCity(){
    city._alpha -= _root.speedOut;
    if (city._alpha < 0){
    city._alpha = 0;
    What this doesn't do is the full fade effect, because the
    function only executes once, so city._alpha doesn't reach 100 when
    it fades in. I've seen in other fade effect scripts, that they use
    the enterFrame event, but I don't now how to use it here... or what
    is the right syntax to make the city details MC fade in to 100% on
    rollOver, and fade out to 0 on rollOut... and still be able to
    apply a speed setting.
    Any help would be appreciated.

    you could try something like this:
    on(rollOver){
    onEnterFrame = showCity;
    then modify your showCity function slightly:
    function showCity(){
    city._alpha += _root.speedIn;
    if (city._alpha > 100){
    city._alpha = 100;
    delete onEnterFrame;
    .. with similar adjustments to you on rollOut code.
    Hope this helps,
    Sinead.

  • OnEnterFrame inside a class

    I don't have a problem as much as just a lack of
    understanding:
    Question: Will I run into any problems using onEnterFrame
    inside a class? I know that onEnterFrame events can overwrite each
    other if they are written dynamically, but I'm not sure how this
    effects classes...
    Also, onEnterFrame is an event of the movie clip class right?
    ...does that even matter...? What happens if I declare an
    onEnterFrame event inside a method inside my class: will it even
    work? will it effect the movie clip from which the class.method is
    being called?
    Sigh... Hopefully you get the idea of what I'm having trouble
    grasping. Please explain any concepts you think I appear to be
    missing. I'm new to classes - thanks for your help.

    >>Question: Will I run into any problems using
    onEnterFrame inside a class?
    No.
    >>Also, onEnterFrame is an event of the movie clip
    class right? ...does that even matter...?
    No. Here is a brief explanation how it works.
    First of all, a class is a custom object. Don't think of a
    class as a bunch of code, it's a custom object with its own
    properties and methods. So when you say: "What happens if I declare
    an onEnterFrame event inside a method inside my class: will it even
    work?" you are thinking: "there is no timeline". Yes, there is.
    When you declare:
    private var my_mc:MovieClip;
    you are saving the functionality of the MovieClip Class in
    my_mc. Therefore, my_mc will have a timeline and all other
    properties and methods of the MovieClip Class. (By comparison:
    usually you don't need all the functionality of the MovieClip
    Class, so AS3 offers us the Sprite Class which is a basic
    implementation of a movieclip and that saves overhead).
    In a method you can use:
    private function mover(target:MovieClip):Void{
    target.onEnterFrame=function():Void{
    this._x+=2;
    passing the my_mc to function mover as a parameter. If at
    some time you want to stop the onEnterFrame you delete it just as
    you would using it in code on the timeline.
    Again. The most important thing to understand is that a class
    is not a bunch of code, it's a (custom) object with its own
    properties and methods.

  • Movieclip.onEnterFrame is not longer triggered in flash player 11.5.502.110

    Hi,
    When I upgraded to Flash Player 11.5.502.110 today I found that none of my onEnterFrame event handler functions get triggered.  Reverting to 11.4 I find that all is ok.  Has anyone else experienced this?
    Thanks
    Andy

    check out the following url -
    http://macarbon.com/wheel_config/conf.php
    The wheel parts in left large image are appeared as faded effect. using onEnterframe method.
    This animated effect was working fine a couple of days back.. but for 3,4 days.. its only initialising and stops..
    I loaded it src file in Adobe Flash that worked fine.. but when I loaded as offline version in google chrome that was bugged.. then I loaded in internet explere and firefox.. there it was working fine.. then i realise the issue.. the Flash player was updated..
    Flash CS3 -As2

  • Function call from inside an onEnterFrame action

    I have a class file called MonsterGame. Inside of it, one of
    the methods called "queueAnim" creates an onEnterFrame function to
    wait till the current movie is done playing before making the next
    one visible.
    That works just fine, but I have certain conditions set up so
    that the function Main() will get called just after a certain movie
    gets played (called "eatMovie"). Everything works except the call
    to Main();
    I think it's some issue with referencing the wrong place, but
    I don't know why.
    The trace for "this should be the name of root" returns
    "MonsterGame", which is the name of the class where the Main()
    method is found. So if this._name returns MonsterGame, and
    MonsterGame has Main() in it, why wont Main() or this.Main() run
    the function???
    PS: It's NOT because I delete the onEnterFrame before calling
    Main(), at least I'm pretty sure it isn't because I have put a
    trace there, and it runs just fine, proving that lines after the
    delete are still executed.
    PM me if you want the link to the source code and the swf
    file

    Thank you very much LuigiL!
    I don't think I would have ever thought of that. I tried all
    sorts of complicated things to get around this problem (including
    using the .watch() method) but none of them worked.
    This was the final puzzle piece to making my program run
    properly. Yet I have no idea WHY it works. Does "this" refer to
    something else when used inside of an onEnterFrame? I even tried
    _root, and that didn't work either.

  • I'm stuck after I delete onEnterFrame

    I've made a lot of progress on this file thanks to some help
    from the forum. I've reached a point I can't figure out. In my
    released() function, I need to call a delete onEnterFrame so that
    the scripted tweens can run. But how do I "reinstate" the
    onEnterFrame when the unreleased() function is called so that the
    original motion can run.
    import mx.utils.Delegate
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    var numClouds:Number = 35;
    var fl:Number = 250;
    var gravity:Number = .5;
    var vx:Number = 0;
    var vy:Number = 0;
    var vz:Number = 0;
    var friction:Number = .97;
    var vpX:Number = Stage.width / 2;
    var vpY:Number = Stage.height / 2;
    var vpY:Number = 400;
    var home:MovieClip = this;
    var dreamarray:Array = new Array();
    dreamarray[0] = "dreamone";
    dreamarray[1] = "dreamtwo";
    dreamarray[2] = "dreamthree";
    dreamarray[3] = "dreamfour";
    dreamarray[4] = "dreamfive";
    var dreamarrayX:Array = new Array();
    dreamarrayX[0] = 0
    dreamarrayX[1] = -1800;
    dreamarrayX[2] = 2000;
    dreamarrayX[3] = 100;
    dreamarrayX[4] = -1700;
    var dreamarrayZ:Array = new Array();
    dreamarrayZ[0] = 0;
    dreamarrayZ[1] = 500;
    dreamarrayZ[2] = 1000;
    dreamarrayZ[3] = 1500;
    dreamarrayZ[4] = 2000;
    function init() {
    for (var i:Number = 0; i<dreamarray.length; i++) {
    var dream:MovieClip = home.attachMovie(dreamarray
    , "dreamarray" + i, i);
    dream.x = dreamarrayX;
    dream.y = 50;
    dream.z = dreamarrayZ
    dream.onRelease = released;
    function inittwo() {
    //set Number to more than number of dreams
    for (var j:Number = 20; j<numClouds; j++) {
    var cloud:MovieClip = attachMovie("cloud", "cloud" + j, j);
    cloud.x = Math.random() * 2000 - 800;
    cloud.y = 50;
    cloud.z = 0 + cloudoffset;
    //cloud.onEnterFrame = mover;
    cloudoffset += 600;
    function released() {
    for (var i=0;i<dreamarray.length;i++){
    var t:MovieClip = home["dreamarray"+i];
    t.xPos = t._x;
    t.yPos = t._y;
    t.theScale = t._xscale;
    //delete dream.onRelease;
    delete onEnterFrame;
    if (t != this)
    //trace(this);
    var tw:Tween = new
    Tween(t,"_xscale",Strong.easeOut,t._xscale,0,1,true);
    var tw2:Tween = new
    Tween(t,"_yscale",Strong.easeOut,t._yscale,0,1,true);
    var tw3:Tween = new
    Tween(t,"_alpha",Strong.easeOut,100,0,1,true);
    //trace(t);
    //trace(t.xPos);
    //trace(t.yPos);
    else
    var tw:Tween = new
    Tween(t,"_xscale",Strong.easeOut,t._xscale,55,1,true);
    var tw2:Tween = new
    Tween(t,"_yscale",Strong.easeOut,t._yscale,55,1,true);
    var tw3:Tween = new
    Tween(t,"_x",Strong.easeOut,t._x,200,1,true);
    var tw4:Tween = new
    Tween(t,"_y",Strong.easeOut,t._y,100,1,true);
    var tw5:Tween = new
    Tween(theText,"_alpha",Strong.easeOut,0,100,1,true);
    var s:Object = this;
    tw.onMotionStopped = function()
    s.onRelease = unReleased;
    function unReleased(){
    //delete this.onRelease;
    for(var i=0;i<dreamarray.length;i++)
    var t:MovieClip = home["dreamarray"+i];
    if(t != this)
    var tw:Tween = new
    Tween(t,"_xscale",Strong.easeOut,0,t.theScale,1,true);
    var tw2:Tween = new
    Tween(t,"_yscale",Strong.easeOut,0,t.theScale,1,true);
    var tw3:Tween = new
    Tween(t,"_alpha",Strong.easeOut,0,100,1,true);
    else
    var tw:Tween = new
    Tween(t,"_xscale",Strong.easeOut,100,t.theScale,1,true);
    var tw2:Tween = new
    Tween(t,"_yscale",Strong.easeOut,100,t.theScale,1,true);
    var tw3:Tween = new
    Tween(t,"_x",Strong.easeOut,t._x,t.xPos,1,true);
    var tw4:Tween = new
    Tween(t,"_y",Strong.easeOut,t._y,t.yPos,1,true);
    tw.onMotionStopped = function()
    for(var i=0;i<dreamarray.length;i++)
    var t:MovieClip = home["dreamarray"+i];
    t.onRelease = Delegate.create(t,released);
    //t.onEnterFrame = mover;
    function onEnterFrame():Void {
    //if (dreamarray4.z >= 500 &&
    Key.isDown(Key.UP)){
    if (zdepth < 55 && Key.isDown(Key.UP)){
    vz -= 1;
    zdepth += 1;
    //if(dreamarray4.z >=2000 &&
    Key.isDown(Key.DOWN))
    if(zdepth > 0 && Key.isDown(Key.DOWN))
    vz += 1;
    zdepth -= 1;
    vy -= gravity;
    vx *= friction;
    vy *= friction;
    vz *= friction;
    for (var i:Number=0;i<dreamarray.length;i++) {
    var dream:MovieClip = home["dreamarray" +i];
    dream.x += vx;
    dream.y += vy;
    dream.z += vz;
    if(dream.y < 50)
    dream.y = 50;
    vy = 0;
    if (dream.z <= -fl) {
    //delete dream.z
    dream.z._visible = false;
    else
    dream.z._visible = true;
    var scale:Number = fl / (fl + dream.z);
    dream._xscale = dream._yscale = scale*100;
    dream._x = vpX + dream.x * scale/2;
    dream._y = vpY + dream.y * scale/2;
    //dream._x = dream.x * scale/2;
    //dream._alpha = scale * 60 + 40;
    dream.swapDepths(-dream.z);
    for (var j:Number=0;j<numClouds;j++) {
    var cloud:MovieClip = this["cloud" + j];
    cloud.x += vx;
    cloud.y += vy;
    cloud.z += vz;
    if(cloud.y < 50)
    cloud.y = 50;
    vy = 0;
    if (cloud.z <= -fl) {
    cloud.z += 5000;
    else if(cloud.z > 5000 - fl)
    cloud.z -= 5000;
    var scale:Number = fl / (fl + cloud.z);
    cloud._xscale = cloud._yscale=scale*200;
    cloud._x = vpX + cloud.x * scale;
    cloud._y = vpY + cloud.y * scale;
    cloud._alpha = scale * 60 + 40;
    cloud.swapDepths(-cloud.z);
    /*//trying to create the mover function
    function mover():Void {
    //if (dreamarray4.z >= 500 &&
    Key.isDown(Key.UP)){
    if (zdepth < 55 && Key.isDown(Key.UP)){
    vz -= 1;
    zdepth += 1;
    //if(dreamarray4.z >=2000 &&
    Key.isDown(Key.DOWN))
    if(zdepth > 0 && Key.isDown(Key.DOWN))
    vz += 1;
    zdepth -= 1;
    vy -= gravity;
    vx *= friction;
    vy *= friction;
    vz *= friction;
    for (var i:Number=0;i<dreamarray.length;i++) {
    var dream:MovieClip = home["dreamarray" +i];
    dream.x += vx;
    dream.y += vy;
    dream.z += vz;
    if(dream.y < 50)
    dream.y = 50;
    vy = 0;
    if (dream.z <= -fl) {
    //delete dream.z
    dream.z._visible = false;
    else
    dream.z._visible = true;
    var scale:Number = fl / (fl + dream.z);
    dream._xscale = dream._yscale = scale*100;
    dream._x = vpX + dream.x * scale/2;
    dream._y = vpY + dream.y * scale/2;
    //dream._x = dream.x * scale/2;
    //dream._alpha = scale * 60 + 40;
    dream.swapDepths(-dream.z);
    for (var j:Number=0;j<numClouds;j++) {
    var cloud:MovieClip = this["cloud" + j];
    cloud.x += vx;
    cloud.y += vy;
    cloud.z += vz;
    if(cloud.y < 50)
    cloud.y = 50;
    vy = 0;
    if (cloud.z <= -fl) {
    cloud.z += 5000;
    else if(cloud.z > 5000 - fl)
    cloud.z -= 5000;
    var scale:Number = fl / (fl + cloud.z);
    cloud._xscale = cloud._yscale=scale*200;
    cloud._x = vpX + cloud.x * scale;
    cloud._y = vpY + cloud.y * scale;
    cloud._alpha = scale * 60 + 40;
    cloud.swapDepths(-cloud.z);
    init();
    inittwo();
    stop();

    I changed my script to create dream.onEnterFrame = mover;
    The dream MovieClips attach correctly and move as they are
    supposed to....but now my clouds just get attached in the upperleft
    corner.
    I tried creating cloud.onEnterFrame = mover; since the clouds
    movement is controlled in the same function as the "dreams"
    Do I need to create a seperate mover function for the clouds?
    And rename all of my variables to go with the new function?
    import mx.utils.Delegate
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    var numClouds:Number = 35;
    var fl:Number = 250;
    var gravity:Number = .5;
    var vx:Number = 0;
    var vy:Number = 0;
    var vz:Number = 0;
    var friction:Number = .97;
    var vpX:Number = Stage.width / 2;
    var vpY:Number = Stage.height / 2;
    var vpY:Number = 400;
    var home:MovieClip = this;
    var dreamarray:Array = new Array();
    dreamarray[0] = "dreamone";
    dreamarray[1] = "dreamtwo";
    dreamarray[2] = "dreamthree";
    dreamarray[3] = "dreamfour";
    dreamarray[4] = "dreamfive";
    var dreamarrayX:Array = new Array();
    dreamarrayX[0] = 0
    dreamarrayX[1] = -1800;
    dreamarrayX[2] = 2000;
    dreamarrayX[3] = 100;
    dreamarrayX[4] = -1700;
    var dreamarrayZ:Array = new Array();
    dreamarrayZ[0] = 0;
    dreamarrayZ[1] = 500;
    dreamarrayZ[2] = 1000;
    dreamarrayZ[3] = 1500;
    dreamarrayZ[4] = 2000;
    function init() {
    for (var i:Number = 0; i<dreamarray.length; i++) {
    var dream:MovieClip = home.attachMovie(dreamarray
    , "dreamarray" + i, i);
    dream.x = dreamarrayX;
    dream.y = 50;
    dream.z = dreamarrayZ
    dream.onRelease = released;
    dream.onEnterFrame = mover;
    function inittwo() {
    //set Number to more than number of dreams
    for (var j:Number = 20; j<numClouds; j++) {
    var cloud:MovieClip = attachMovie("cloud", "cloud" + j, j);
    cloud.x = Math.random() * 2000 - 800;
    cloud.y = 50;
    cloud.z = 0 + cloudoffset;
    //cloud.onEnterFrame = mover;
    cloudoffset += 600;
    function released() {
    for (var i=0;i<dreamarray.length;i++){
    var t:MovieClip = home["dreamarray"+i];
    t.xPos = t._x;
    t.yPos = t._y;
    t.theScale = t._xscale;
    //delete dream.onRelease;
    t.onEnterFrame = null;
    if (t != this)
    var tw:Tween = new
    Tween(t,"_xscale",Strong.easeOut,t._xscale,0,1,true);
    var tw2:Tween = new
    Tween(t,"_yscale",Strong.easeOut,t._yscale,0,1,true);
    var tw3:Tween = new
    Tween(t,"_alpha",Strong.easeOut,100,0,1,true);
    else
    var tw:Tween = new
    Tween(t,"_xscale",Strong.easeOut,t._xscale,55,1,true);
    var tw2:Tween = new
    Tween(t,"_yscale",Strong.easeOut,t._yscale,55,1,true);
    var tw3:Tween = new
    Tween(t,"_x",Strong.easeOut,t._x,200,1,true);
    var tw4:Tween = new
    Tween(t,"_y",Strong.easeOut,t._y,100,1,true);
    var tw5:Tween = new
    Tween(theText,"_alpha",Strong.easeOut,0,100,1,true);
    var s:Object = this;
    tw.onMotionStopped = function()
    s.onRelease = unReleased;
    function unReleased(){
    for(var i=0;i<dreamarray.length;i++)
    var t:MovieClip = home["dreamarray"+i];
    if(t != this)
    var tw:Tween = new
    Tween(t,"_xscale",Strong.easeOut,0,t.theScale,1,true);
    var tw2:Tween = new
    Tween(t,"_yscale",Strong.easeOut,0,t.theScale,1,true);
    var tw3:Tween = new
    Tween(t,"_alpha",Strong.easeOut,0,100,1,true);
    else
    var tw:Tween = new
    Tween(t,"_xscale",Strong.easeOut,100,t.theScale,1,true);
    var tw2:Tween = new
    Tween(t,"_yscale",Strong.easeOut,100,t.theScale,1,true);
    var tw3:Tween = new
    Tween(t,"_x",Strong.easeOut,t._x,t.xPos,1,true);
    var tw4:Tween = new
    Tween(t,"_y",Strong.easeOut,t._y,t.yPos,1,true);
    tw.onMotionStopped = function()
    for(var i=0;i<dreamarray.length;i++)
    var t:MovieClip = home["dreamarray"+i];
    t.onRelease = Delegate.create(t,released);
    t.onEnterFrame = mover;
    //trying to create the mover function
    function mover():Void {
    if (zdepth < 55 && Key.isDown(Key.UP)){
    vz -= 1;
    zdepth += 1;
    if(zdepth > 0 && Key.isDown(Key.DOWN))
    vz += 1;
    zdepth -= 1;
    vy -= gravity;
    vx *= friction;
    vy *= friction;
    vz *= friction;
    for (var i:Number=0;i<dreamarray.length;i++) {
    var dream:MovieClip = home["dreamarray" +i];
    dream.x += vx;
    dream.y += vy;
    dream.z += vz;
    if(dream.y < 50)
    dream.y = 50;
    vy = 0;
    if (dream.z <= -fl) {
    dream.z._visible = false;
    else
    dream.z._visible = true;
    var scale:Number = fl / (fl + dream.z);
    dream._xscale = dream._yscale = scale*100;
    dream._x = vpX + dream.x * scale/2;
    dream._y = vpY + dream.y * scale/2;
    //dream._x = dream.x * scale/2;
    //dream._alpha = scale * 60 + 40;
    dream.swapDepths(-dream.z);
    for (var j:Number=0;j<numClouds;j++) {
    var cloud:MovieClip = this["cloud" + j];
    cloud.x += vx;
    cloud.y += vy;
    cloud.z += vz;
    if(cloud.y < 50)
    cloud.y = 50;
    vy = 0;
    if (cloud.z <= -fl) {
    cloud.z += 5000;
    else if(cloud.z > 5000 - fl)
    cloud.z -= 5000;
    var scale:Number = fl / (fl + cloud.z);
    cloud._xscale = cloud._yscale=scale*200;
    cloud._x = vpX + cloud.x * scale;
    cloud._y = vpY + cloud.y * scale;
    cloud._alpha = scale * 60 + 40;
    cloud.swapDepths(-cloud.z);
    init();
    inittwo();
    stop();

  • Do NOT use text.autoSize onEnterFrame or any other loops!!

    do NOT use test.autoSize = true - with onEnterFrame or any
    other loops!! - it kills the processor i just found out the other
    day why my movieclip scrollers and dynamic menus have been laggin
    so much sins the dawn of time -- its all because of text.autoSize =
    true -
    i turn it off as soon as i has the final text length and
    everything runs smooth

    Hi Swetha,
    Maintain traslations for your text in Tcode: se63
    Regards,
    kalandar

  • Adobe air 2.6 iPhone animation tween class vs onEnterframe

    Hi,  Does anyone knows what's better to create alpha or slide animations on iPhone applications, using a tween class like Tweener or use the classic onEnterframe.  What's the better choice, who's the better performance .  Thanks,  Nuno

    Use Tween Class,
    http://www.greensock.com/tweenlite/

  • Convert onEnterFrame Event Handler  AS2 code into AS3

    My code of AS2 is given below. I do not know what event handler type is used and which event handler is used in AS3.
    onEnterFrame = function(){

    this.addEventListener(Event.ENTER_FRAME,onEf);
    // "this" references the movie itself, you can also use "stage" or the instance name of an object on the stage
    // look up addEventListener in the online help. This method takes two arguments, the event that you want to "listen" for and the name of the function to execute when the event occurs.
    // the function that will be called when the event occurs. It takes one argument that corresponds with the first argument of the addEventListener method.
    function onEf(event:Event):void {

  • Problems with sound in onEnterFrame....

    how do i get a sound to play just once when its in an
    onEnterFrame function.
    i have nameOfSound.start(0,1);
    but when its played, its over and over and over....
    whtats the correct way to do it?

    onEnterFrame means exactly what you are seeing (hearing). It
    means to do something repeatedly at the movie's frame rate. So:
    this.onEnterFrame=function(){
    nameOfSound.start(0,1)
    Means, start this sound 20, 30, or whatever, times per
    second.
    If you just want to start the sound once:
    nameOfSound.start(0,1)
    means, start the sound and then be on your merry way with
    whatever else you need to do.

  • Dynamically build onEnterframe function

    Hi
    I was wondering how to build dynamically onEnterframe
    functions.
    I want that my first onEnterframe() uses the values of the
    first time the for loop runs, the second onEnterframe uses the
    values build in the second time the for loop runs, the third time,
    What my script does now is that is all my items eventualy
    uses the last values that where build the last time the for loop
    has ran?
    I hope all this is clear enough for you guys.
    Here's my scrip tI use:
    function setNewImagePosition(){
    for(i=0; i<_root.myArray12Length; i++){
    speed = 4;
    whichNumber = _root.myArray12
    whichNumber = whichNumber.substr(1,1);
    var p:Number = whichNumber;
    trace("whichNumber: " + p);
    myWidth = this["ImageMenuItem"+(p-1)]._width;
    var E:Number = (80+myWidth+(i*20));
    this["ImageMenuItem"+(p-1)].onEnterFrame = function(){
    this._x += (E-this._x)/speed;

    Maybe one last question about all this.
    How do I know if the last and only the last onEnterframe has
    reached his goal?
    Beacaus only then there' may take another action place.
    Tx
    Tom

  • ComboBox onEnterFrame Issue

    Hi,
    I have created an email form in one swf that is called into
    another swf. In this form there is a comboBox that will populate a
    text field when something is selected in it. Everything works fine
    with the comboBox in it's own swf but when it's called into another
    swf the comboBox is inactive. I'm not sure but I think it may have
    to do with the onEnterFrame.... here is the code from the swf that
    contains the comboBox and email information.
    import mx.remoting.Service;
    import mx.services.Log;
    import mx.rpc.RelayResponder;
    import mx.rpc.FaultEvent;
    import mx.rpc.ResultEvent;
    import mx.remoting.PendingCall;
    import mx.remoting.RecordSet;
    import mx.remoting.DataGlue;
    onEnterFrame = function(){
    area_ta.text = area_cb.value;
    submit_btn.onRelease = function() {
    if (question1_txt.text == "") {
    gotoAndStop ("error");
    }else{
    var pc:PendingCall = myService.mailSuggestion
    (question1_txt.text, area_cb.value);
    pc.responder = new RelayResponder (this,
    "mailSuggestion_Result","mailSuggestion_Fault");
    gotoAndStop ("correct");
    var myService : Service = new Service("
    http://******flashservices/gateway",
    new Log (Log.DEBUG),
    "tap.*******.emailfunction",
    null,
    null);
    stop();

    Thanks for helping me with this by the way...
    Ok I added the listener and that worked in it's own swf, but
    same issue when I pull from the main swf. I'll try putting it in
    the main swf but I would like to keep it in the one its in.
    Picture a website and when you click on Ask The Trainer
    button that calls a swf and in this swf there will be a combobox to
    select what area you are from and a text box that you will fill in
    your question in and then click submit. That sends an email
    containing the info from the combobox and the text field. So I
    would need them all in the same swf, wouldn't I?

  • LoadVariables onEnterFrame

    so i have a simple php script below that gets the time of the
    server hosting the script. my flash file has a simple
    loadVariables, loading the variables from the php script
    onEnterFrame. the problem is that the value of the variables is not
    getting refreshed. the output of the trace below just repeats the
    same value for CSTseconds over and over again. how do i get it to
    change to the refreshed/current value?

    You're calling it every onEnterFrame? Is that necessary. It
    seems unusual to do that. I don't know if the response would be
    received before the next request was sent (and I don't know what
    might happen under those circumstances).
    It may also be being cached.
    You could try adding a random unique code to the test.php to
    try to avoid that.
    e.g.
    loadVariables("test.php?cachebuster="+getTimer(), "");

  • Need to stop instance of mc onEnterFrame

    (running CS3 and doing this in AS2)
    i have a looping animation of a ball rotating, that i need to stop rotating once it reaches a particular frame (we'll say frame 60).
    i tried putting:
    ball_mc.onEnterFrame = function() {
        ball_mc.stop();
    (ball_mc is the instance name of a particular movie clip.  i do not want to reference the actual mc as i have about 10 instances of it on the timeline)
    everything is taking place on the main stage at the root level, but i can't seem to get the animation to stop.
    any help would be greatly appreciated.
    j

    Oh. So many things aren't making sense here.
    First what does this mean "...i do not want to reference the actual mc as i have about 10 instances of it on the timeline..."?
    The only way to tell a movieclip to stop is to tell it to stop, so you will have to reference it. There are many ways to do such a thing, but without knowing exactly what you are trying to accomplish (with the whole project) it is hard to give exact advice.
    The next thing is that I don't think onEnterFrame is what you are thinking it is. It means to repeat the code at the frame rate, it doesn't mean, "Do this when this frame is reached." If you just want to do something when you reach a frame you put a keyframe and add code like:
    ball.stop();
    All code on that frame will execute before the screen is redrawn. So I think that is what you are after.
    Finally, there are a couple of reasons that the code above might not stop a given movieclip.
    The first and most common reason would be that you have a scope problem. That that ball isn't a child of the current timeline. So if ball was actually inside another movie clip you might need to do something like
    theOrbs.ball.stop();
    Or perhaps you have mistyped or misnamed the instance. So if the instance name is Ball and you say ball.stop() it won't work because capitazliation and spelling matter.
    Another popular way that stop() wouldn't work is if the animation of the clip is being done by code. stop() only stops the playhead on the specified timeline. So if there is some code making the ball move stopping its timeline won't stop the code.
    And a similar issue to the scope and code issue is that if the animation that makes the ball move is actually provided by a movieclip nested inside of ball then ball.stop() will stop the ball's timeline, but not the independent timelines of its children.
    So we need to know more about how you have designed your project.

  • Can't get onEnterFrame working on MC in a class

    Hi,
    Can anyone take a look at this class file that's in the
    works, and help me understand why the onEnterFrame that's created
    in the startRewind() method is not working?
    Much thanks!

    >>You have to pass the class a target clip
    Not neccesarily. You could just as easily use:
    rewinder_mc =
    _level0.createEmptyMovieClip("rewinder_mc",_level0.getNextHighestDepth());
    But passing a target makes the class more flexible: you can
    pass any movieclip as a target.
    >>because otherwise there's nothing to create a
    movieClip upon?
    createEmptyMovieClip is a method of the MovieClip Class. So
    it needs an instance of a movieclip (which has the properties and
    methods of the MovieClip Class), otherwise the method is
    unavailable.
    >>Why can't you just create the instance of the class
    as a MovieClip and then call createEmptyMovieClip() on itself?
    That's the case when you extend the MovieClip Class and I've
    explained that (or at least tried to...) in my first reply.
    Extending the MovieClip Class requires two things: the custom class
    you write and a movieclip in your fla. With the 'linkage' option
    (Library) you assign the custom class to the movieclip (and you
    can't setup a Linkage identifier for the _root). It's a one-to-one
    relationship so you can't link other classes to the same movieclip.
    If that's the setup you want you need to put your button controls
    in a movieclip (other than the _root) and link the class to the
    movieclip. But, as I said, composition is in almost all cases a
    better setup. Only extend the MovieClip Class if you need all or
    most of the functionality of the MovieClip Class.

Maybe you are looking for