-
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);
-
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!
-
display current frame help
 Originally Posted by tdemetri
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!
-
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.
-
I got it!
textBox.addEventListener(Event.ENTER_FRAME, frameNumberText);
function frameNumberText(evt:Event):void {
var frames:Number;
frames=currentFrame;
textBox.text = (String(frames));
}
awesome
-
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!!
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|