display current frame number [AS3]
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: display current frame number [AS3]

  1. #1
    Junior Member
    Join Date
    Jul 2004
    Posts
    15

    display current frame number [AS3]

    I feel like such an idiot but after trying endlessly I still haven't managed to come up with a way to display the current frame number of nested movie clip ("ecke1") (in a dynamically created text field).
    The problem really is that I don't know how to have flash keep updating the variable.

    Here's my latest attempt:
    Code:
    var frame:int = 0;
    	addEventListener(Event.ENTER_FRAME,updateframe,false,0,true);
    	function updateframe(e:Event):void{
    		if (frame < ecke1.currentFrame)
    			frame += 1;
    		} 
    	
    		var txt2:String = String(frame);
    		 var textfeld:TextField = new TextField();
    		textfeld.text = txt2;
    		addChild(textfeld);

  2. #2
    Junior Member
    Join Date
    Jun 2009
    Posts
    2

    display current frame number [AS3]

    i know this is late, but i just saw this post.

    here is code i use to put the frame number of a movieclip (instance name "box2" ) which is nested inside another movieclip (instance name "box1") into a dynamic text box ( instance name "textBox" )

    Code:
    textBox.addEventListener(Event.ENTER_FRAME, frameNumberText);
    function frameNumberText(evt:Event):void
    { textBox.text=box1.box2.currentFrame; }
    that should help, or at least give you new ideas!

  3. #3
    Junior Member
    Join Date
    Aug 2009
    Posts
    5

    display current frame help

    Quote Originally Posted by tdemetri View Post
    i know this is late, but i just saw this post.

    Code:
    textBox.addEventListener(Event.ENTER_FRAME, frameNumberText);
    function frameNumberText(evt:Event):void
    { textBox.text=box1.box2.currentFrame; }
    You seem to be the only person out there that has done what I am trying to do. I have this code:

    Code:
    textBox.addEventListener(Event.ENTER_FRAME, frameNumberText);
    function frameNumberText(evt:Event):void { 
    	textBox.text = this.currentFrame; 
    }
    But I get this error:
    Line 1067: Implicit coercion of a value of type into to an unrelated type String

    Could you have me any help?

    Thanks in advance!

  4. #4
    Junior Member
    Join Date
    Jun 2009
    Posts
    2
    why are you using 'this' ? what are you trying to reference with it ?
    and where is the code placed ?

    if this code is placed on the main timeline, in frame 1 ( as it should be, if you are not using document classes) then on frame 1 ( this is a 1 frame main-timeline) you should have dynamic text box called " textBox", then you also have on the main timeline a movieclip symbol claled "box1" , inside of 'box1' is another movie clip symbol named "box2" which has a timeline. i thnk/thought that THAT was the timeline you are trying to show the frame #.

    let me know if that is the case, or if i am misunderstanding you, or what exactly you are trying to accomplish.

  5. #5
    Junior Member
    Join Date
    Aug 2009
    Posts
    5
    I got it!

    textBox.addEventListener(Event.ENTER_FRAME, frameNumberText);
    function frameNumberText(evt:Event):void {
    var frames:Number;
    frames=currentFrame;
    textBox.text = (String(frames));
    }

    awesome

  6. #6
    Junior Member
    Join Date
    Mar 2013
    Posts
    5

    display current frame with other textboxes

    I see that the latest reply was in 2009 but i give it a go.
    After searching much without results I found this topic and I got it to work. I have a button going to a random frame and a dynamic textbox showing the current frame, like below

    stop();

    import flash.events.MouseEvent;

    function onClick(event:MouseEvent):void
    {
    // generate a random number from 1 to 3
    var nRandom = 1 + Math.floor(Math.random() * 65);
    // tell timeline to goto and play the random number 'nRandom'
    gotoAndStop(nRandom);

    }
    proceed.addEventListener(MouseEvent.CLICK, onClick);

    function frameNumberText(event:Event):void
    {
    var frames:Number;
    frames=currentFrame;
    textBox.text = (String(frames));
    }
    textBox.addEventListener(Event.ENTER_FRAME, frameNumberText);

    My problem is: If I add another textbox to my scene, the textbox, here called textBox, showing the current frame,
    dissappeares/doesn't show. I can add object as rectangels or ovals or convert the textbox to a bitmap with decreased quality. But I can't convert it to a symbol, maintaining the quality.

    How can I solve this? I'm a novice at flash and have been using it for a couple of days, googeling the actions above.
    Know some flash from my youth.

    Thanks for all help!!

  7. #7
    Junior Member
    Join Date
    Mar 2013
    Posts
    5

    Solved it...

    I accidentally solved it.... by turning properties of the textbox from classic text to TLF text.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com