Skip to main content
Known Participant
June 7, 2009
Answered

quick questions converting from AS2 to 3

  • June 7, 2009
  • 1 reply
  • 789 views

Is the following code correct AS3?  should "flash.display.loader" occur in the manner shown below?

Is "package" a generic name or should it be customized? 

Thanks for your help and suggestions--just getting back to Flash after a few years...sorry about the basic questions.

var message:Number = 0;

var requested_message:Number = 0;

package {

import flash.display.MovieClip;

import flash.ui.Mouse;

import flash.events.MouseEvent;

import flash.text.TextField;

MovieClip(root).stage_target_mc.internal_stage_target_mc.flash.display.loader("message_displayed"+message+".swf");

next_btn.addEventListener(MouseEvent.MOUSE_DOWN, next_message);

function next_message (event:MousEvent):void {

  message = ++message;

  MovieClip(root).stage_target_mc.internal_stage_target_mc.flash.display.loader("message_displayed"+message+".swf");

};

MovieClip(root).stop();

};

This topic has been closed for replies.
Correct answer kglad

"and you're correct, the url should be:  new URLRequest("message_"+message _displayed+".swf")"

wow thanks for the guessing game this was fun


you're welcome.

1 reply

kglad
Community Expert
Community Expert
June 7, 2009

package is a keyword and never changes.  you can add text after package to indicate a package name/location.

and no, your code doesn't look ok.  to start, all code should follow the brackets after package and variable declarations needed outside of functions should be after a class name and before the class constructor.

you should check some sample class files, if that's what you're trying to create.

Known Participant
June 7, 2009

Thanks for your help!  A few more specific questions:

When trying to update:

_root.stage_target_mc.internal_stage_target_mc.loadMovie("message_displayed"+message+".swf");

to AS3:

MovieClip(root).stage_target_mc.internal_stage_target_mc.flash.display.loader("message_displayed"+message+".swf");

should "flash.display.loader" be used in this manner?
and where can I find examples of sample class files?
Thank you very much once again...

kglad
Community Expert
Community Expert
June 7, 2009

no, it wouldn't.


to update:

_root.stage_target_mc.internal_stage_target_mc.loadMovie("message_displayed"+mes sage+".swf");

to AS3:

MovieClip(root).stage_target_mc.internal_loader.load("message_displayed"+message+".swf");