2

Good day. I am creating a library like flash file for our game. I am using adobe flash cs5 with as3 and adobe indesign. I am still very new at flash(a real newbie) and i am wondering if anyone could help me in my problem.

DESCRIPTION:

I have a movieclip file named "mainPage". mainPage contains 6 buttons (with a cyrstal design) but lets focus only on 1 button. The 1st button contains the name Art_btn which calls the movieclip artBook when the button is clicked (which is my problem) . I have another movieclip named "artBook". the contents in my artBook are separated or written on each frames that could be called when clicked next or prev.

here is my prob. i dont know what is the right code that would call for artBook when Art_btn is clicked. i tried inserting codes such as loadMovie, gotoAndPlay and addChild but when I test it, the mainPage contents doesnt show up and it produces errors.

I have two options in solving my problem:

  1. loading the swf file made from adobe indesign in the action tab in flash cs5

  2. loading/opening another movie clip on button click.


the purpose for my 1st option is to create at least a simple page flip effect for the book.I already have files created on adobe indesign that works when opened outside flash adobe cs5

my 2nd option is to call another movie clip when i press a specific button and it has no page flip animation and whatsoever.


here is the only codes in my flash which is located in the action panel of mainPage

stop();

import flash.events.MouseEvent;

Art_btn.addEventListener(MouseEvent.CLICK, ArtClick);

function ArtClick(event:MouseEvent){
 //what should be put here? :( here is where i put the codes i tried that causes the error

}

i hope someone could help me. :( I would really appreciate it if it could work. thanks in advance for those who would answer

MisaChan
  • 279
  • 1
  • 5
  • 15

1 Answers1

1

Here's how to accomplish option 1 (load external swf):

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleLoaded);
loader.load(new URLRequest("nameAndLocationOfSWFFile.swf"));

function handleLoaded(evt:Event):void {
   //evt.target.content is your reference to the swf that was loaded
   addChild(evt.target.content);
}

As for option 2, it depends on how you're trying to accomplish the task. I'm not sure based on your description what the exact intent or approach you're trying is, but you could either have your movieclip already added to the stage on a different frame, or you could create a new instance of the movieclip.

To use a different frame, simply place your movieclip on stage on a different frame and give the frame a label. From inside ArtClick(), you could then call gotoAndStop("myTargetFrameLabel").

To create a new instance of the movieclip, you would need to set up linkage to the movieclip. If you give your movieclip the linkage class name of ArtBook, you could use the following within ArtClick():

var myClip:MovieClip = new ArtBook();
addChild(myClip);

That will add a new instance of ArtBook to the stage.

HotN
  • 4,216
  • 3
  • 40
  • 51