Skip to main content
June 12, 2008
Question

How do I add a image into specific frame using AS3?

  • June 12, 2008
  • 2 replies
  • 702 views

How do I add a image into specific frame using AS3?
so that I can dynamically load images into frame, and play a movie ...
thank in advance.
This topic has been closed for replies.

2 replies

Inspiring
June 13, 2008
As I sad, you can addEventListener (in main application, or whatever you call it :) ) to check if specific frame is hited, and than execute code (also from main application).

I did not understand 'Document class' - is this main class for application (extended from Sprite or MovieClip?). If yes, than just use same technique: addEventListener + check on which frame you are, and execute code.

Best.
Inspiring
June 12, 2008
Answer hardly depend on your frame structure.

If you need just to execute some code (loading image) on some frame (when player executes it) it is easy just to put actionscript into that frame.

If this is not possible (for whatever wild reason it is) you can listen for Event.ENTER_FRAME on stage, and when specified number of frames is passed, just execute some code:

// first frame on stage
addEventListener(Event.ENTER_FRAME, enterFrameCount);
var frameCount : int = 1;
function enterFrameCount(e:Event) {
if (frameCount == 3) {
trace("We are on frame 3");
}
frameCount++;
}

Also, you can check frame name with currentScene.labels property of MovieClip to remove frameCount logic.

Best,
Zaharije Pasalic

June 12, 2008
Thank you for your reply, those are great ideas.
Is there a way do it in Document Class? like no code in the frame.
Thank you