A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: HELP! nested swf targeting issue , I think.

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    1

    Exclamation HELP! nested swf targeting issue , I think.

    Hello,

    Here goes, this is my first time posting on a forum. First off, I am working in Flash CS5, AS3.

    I am having a problem with actionscript being ignored within a nested SWF. Let me describe my project.

    I have created a choose your own adventure learning module.(there are good, better and best answers) I am using arrays to load scenario swfs into a main swf that controls the decision wheel, populate the decision wheeltext as well as the frame lables to jump to within the SWF to play the associated animations. Each click is associated with a switch statement that tells the decision wheel what arrays to display and animations to play and adds points. This all works fine.

    The logic is..If you choose all the "bad" answers you do not get the sale. If you choose all the "good" answers
    you get the sale. This is all based on added numbers associated with each of the clicks. If you are inbetween you get the option of an "objection" that is loaded. This is where my problem is. Within the main swf I have loaded a child swf which is the scenario swf. The "objection" is a grandchild swf loaded within the scenario child swf. My calls to the Main swf to display the decision wheel works fine, the text in the arrays work fine. So my trageting is correct. Once you choose the button to take you to the animation you choose the grandchild swf does not go to the frame lable of the animation that is chosen based on the lables array. All of my traces see the text arrays and frame lables for the grandchild swf. It just dosent go to the frame to play the animation that is in the array, even tho my trace tells me it knows what frame to jump to. The decision wheel goes away but the animation wont play. I have attached the code for the main swf as well as the code for the objection swf. The majority of the code resides in the Main swf (the shell).


    The switch statement is called gameLogic and the scene Part variable "objections" where the problem is resides at the bottom. Everything else is working fine.
    I commented out the math code in the objections so I could try and isolate the problem and just have the SWF jump to the tag within the SWF the array speicifed. It just
    freezes, not playing the animation chosen.

    Any help is greatly appreciated!

    Aleeshanee

    PS I have had to delete quite a bit of the code to be able to post this thread due to length.


    the objection swf code that calls to the Main swf:

    MovieClip(this.parent.parent.parent).ButtonBar();

    then there are frames called:
    OA
    OB
    OC
    these are the animations associated with the button choice chosen.

    The main swf code:

    //variables----------------------------------------------------------------------------------
    var objectionSwfArray:Array = ["Objection0.swf","Objection1.swf","Objection2.swf" ,"Objection3.swf","Objection4.swf"];
    var objectionQuestionArray:Array = ["O0Q:Always get the customer to say no twice before letting the sale go. What should GC Jane/Guy say next?","O1Q:Always get the customer to say no twice before letting the sale go. What should GC Jane/Guy say next?","O2Q:Always get the customer to say no twice before letting the sale go. What should GC Jane/Guy say next?","O3Q:Always get the customer to say no twice before letting the sale go. What should GC Jane/Guy say next?","O4Q:Always get the customer to say no twice before letting the sale go. What should GC Jane/Guy say next?"];
    var objectionOptionArray:Array = ["O0-A1(good): ","O0-A2(better","O0-A3(best): "]

    var objectionLablesArray:Array = ["OA","OB","OC"]


    //Loading the swfs--Start Module--------------------------------------------------------------------------
    function LoadSWF():void {
    //swf loader------------------------------------------------------------------------------
    intro_Btn.visible = false;
    curtain.AmpyCount.visible = true;
    loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.CO MPLETE,onMovieComplete);
    //rndSwfNum = Math.floor(Math.random() * 3);
    rndSwfNum=0;
    if (correctCount == swfArray.length){
    loader.load(new URLRequest("Conclusion.swf"));
    curtain.SWFtitle.scenarioTitle.text = "Congratulations! You sold them all Pro Coverage!";
    curtain.AmpyCount.AmpyHead.AmpyHand.AmpyMotion.Amp ySign.AmpyNumber.text = "You have sold " + correctCount + " of 3";
    }
    else{
    if(swfArray[rndSwfNum] == "x"){
    LoadSWF();
    }
    else{
    loader.load(new URLRequest(swfArray[rndSwfNum]));
    curtain.SWFtitle.scenarioTitle.text = scenarioTitleArray[rndSwfNum];
    curtain.AmpyCount.AmpyHead.AmpyHand.AmpyMotion.Amp ySign.AmpyNumber.text = "You have sold " + correctCount + " of 3";
    }
    }
    removeChild(holder);
    trace("remove child holder");
    }




    //random num generator---randomize options in button bar--------------------------------------------
    function randonNumGenerator():void{
    randomNum = Math.floor(Math.random() * 3);
    }
    // Question Button bar function---------------------------------------------------------------------
    function ButtonBar():void{
    Front_MC.visible = true;
    Front_MC.x = 310;
    Front_MC.y = 148;
    }

    //decision wheel bar buttons------------------------------------------------------------------------------------------
    Front_MC.option1_button.buttonMode = true;
    Front_MC.option1_button.addEventListener(MouseEven t.MOUSE_OVER, option1Over);
    Front_MC.option1_button.addEventListener(MouseEven t.MOUSE_OUT, option1Out);
    Front_MC.option1_button.addEventListener(MouseEven t.MOUSE_DOWN, option1Down);
    Front_MC.option1_button.addEventListener(MouseEven t.CLICK, option1Click);
    function option1Over(event:MouseEvent):void{
    Front_MC.option1_button.gotoAndStop("over");
    }
    function option1Out(event:MouseEvent):void{
    Front_MC.option1_button.gotoAndStop("out");
    }
    function option1Down(event:MouseEvent):void{
    Front_MC.option1_button.gotoAndStop("click");
    }
    function option1Click(event:MouseEvent):void{
    //holder.gotoAndPlay("correct");
    Front_MC.visible = false;

    if(randomNum == 0){
    sp = sp + 1;
    }
    if(randomNum == 1){
    sp = sp + 3;
    }
    if(randomNum == 2){
    sp = sp + 2;
    }

    partNum ++;
    gameLogic();
    }
    Front_MC.option2_button.buttonMode = true;
    Front_MC.option2_button.addEventListener(MouseEven t.MOUSE_OVER, option2Over);
    Front_MC.option2_button.addEventListener(MouseEven t.MOUSE_OUT, option2Out);
    Front_MC.option2_button.addEventListener(MouseEven t.MOUSE_DOWN, option2Down);
    Front_MC.option2_button.addEventListener(MouseEven t.CLICK, option2Click);

    function option2Over(event:MouseEvent):void{
    Front_MC.option2_button.gotoAndStop("over");
    }
    function option2Out(event:MouseEvent):void{
    Front_MC.option2_button.gotoAndStop("out");
    }
    function option2Down(event:MouseEvent):void{
    Front_MC.option2_button.gotoAndStop("click");
    }
    function option2Click(event:MouseEvent):void{
    //holder.gotoAndPlay("incorrect");
    Front_MC.visible = false;
    //answerResult = "no";
    if(randomNum == 0){
    sp = sp + 2;
    }
    if(randomNum == 1){
    sp = sp + 1;
    }
    if(randomNum == 2){
    sp = sp + 3;
    }

    partNum ++;
    gameLogic();
    }
    Front_MC.option3_button.buttonMode = true;
    Front_MC.option3_button.addEventListener(MouseEven t.MOUSE_OVER, option3Over);
    Front_MC.option3_button.addEventListener(MouseEven t.MOUSE_OUT, option3Out);
    Front_MC.option3_button.addEventListener(MouseEven t.MOUSE_DOWN, option3Down);
    Front_MC.option3_button.addEventListener(MouseEven t.CLICK, option3Click);

    function option3Over(event:MouseEvent):void{
    Front_MC.option3_button.gotoAndStop("over");
    }
    function option3Out(event:MouseEvent):void{
    Front_MC.option3_button.gotoAndStop("out");
    }
    function option3Down(event:MouseEvent):void{
    Front_MC.option3_button.gotoAndStop("click");
    }
    function option3Click(event:MouseEvent):void{
    //holder.gotoAndPlay("incorrect");
    Front_MC.visible = false;
    //answerResult = "no";
    if(randomNum == 0){
    sp = sp + 3;
    }
    if(randomNum == 1){
    sp = sp + 2;
    }
    if(randomNum == 2){
    sp = sp + 1;
    }

    partNum ++;
    gameLogic();
    }


    // game logic

    function gameLogic():void{

    switch(scenePart[partNum]){

    case "start":
    randonNumGenerator();
    Front_MC.questionText.text = introQuestionArray[rndSwfNum];
    if(randomNum == 0){
    Front_MC.option1_button.option_text.text = introOptionArray[rndSwfNum][0];
    Front_MC.option2_button.option_text.text = introOptionArray[rndSwfNum][1];
    Front_MC.option3_button.option_text.text = introOptionArray[rndSwfNum][2];
    }
    if(randomNum == 1){
    Front_MC.option1_button.option_text.text = introOptionArray[rndSwfNum][2];
    Front_MC.option2_button.option_text.text = introOptionArray[rndSwfNum][0];
    Front_MC.option3_button.option_text.text = introOptionArray[rndSwfNum][1];
    }
    if(randomNum == 2){
    Front_MC.option1_button.option_text.text = introOptionArray[rndSwfNum][1];
    Front_MC.option2_button.option_text.text = introOptionArray[rndSwfNum][2];
    Front_MC.option3_button.option_text.text = introOptionArray[rndSwfNum][0];
    }
    break;

    case "intro":

    if(sp == 1){
    spNum = 0;
    holder.gotoAndPlay(introLablesArray[rndSwfNum][spNum]);
    }
    if(sp == 2){
    spNum = 1;
    holder.gotoAndPlay(introLablesArray[rndSwfNum][spNum]);
    }
    if(sp == 3){
    spNum = 2;
    holder.gotoAndPlay(introLablesArray[rndSwfNum][spNum]);
    }

    Front_MC.questionText.text = pitchQuestionArray[rndSwfNum];
    randonNumGenerator();
    if(randomNum == 0){
    Front_MC.option1_button.option_text.text = pitchOptionArray[rndSwfNum][spNum][0];
    Front_MC.option2_button.option_text.text = pitchOptionArray[rndSwfNum][spNum][1];
    Front_MC.option3_button.option_text.text = pitchOptionArray[rndSwfNum][spNum][2];
    }
    if(randomNum == 1){
    Front_MC.option1_button.option_text.text = pitchOptionArray[rndSwfNum][spNum][2];
    Front_MC.option2_button.option_text.text = pitchOptionArray[rndSwfNum][spNum][0];
    Front_MC.option3_button.option_text.text = pitchOptionArray[rndSwfNum][spNum][1];
    }
    if(randomNum== 2){
    Front_MC.option1_button.option_text.text = pitchOptionArray[rndSwfNum][spNum][1];
    Front_MC.option2_button.option_text.text = pitchOptionArray[rndSwfNum][spNum][2];
    Front_MC.option3_button.option_text.text = pitchOptionArray[rndSwfNum][spNum][0];
    }


    break;
    case "pitch":
    Front_MC.questionText.text = registerQuestionArray[rndSwfNum];
    randonNumGenerator();

    if(sp == 2){
    spNum = 0;
    holder.gotoAndPlay(pitchLablesArray[rndSwfNum][spNum][spNum]);
    }
    if((sp > 2) && (sp < 6)){
    spNum = 1;
    holder.gotoAndPlay(pitchLablesArray[rndSwfNum][spNum][spNum]);
    }
    if(sp == 6){
    spNum = 2;


    holder.gotoAndPlay(pitchLablesArray[rndSwfNum][spNum][spNum]);
    }
    if(randomNum == 0){
    Front_MC.option1_button.option_text.text = registerOptionArray[rndSwfNum][spNum][0];
    Front_MC.option2_button.option_text.text = registerOptionArray[rndSwfNum][spNum][1];
    Front_MC.option3_button.option_text.text = registerOptionArray[rndSwfNum][spNum][2];
    }
    if(randomNum == 1){
    Front_MC.option1_button.option_text.text = registerOptionArray[rndSwfNum][spNum][2];
    Front_MC.option2_button.option_text.text = registerOptionArray[rndSwfNum][spNum][0];
    Front_MC.option3_button.option_text.text = registerOptionArray[rndSwfNum][spNum][1];
    }
    if(randomNum == 2){
    Front_MC.option1_button.option_text.text = registerOptionArray[rndSwfNum][spNum][1];
    Front_MC.option2_button.option_text.text = registerOptionArray[rndSwfNum][spNum][2];
    Front_MC.option3_button.option_text.text = registerOptionArray[rndSwfNum][spNum][0];
    }

    break;

    case "register":
    if(sp == 3){
    spNum = 0;
    holder.gotoAndPlay(registerLablesArray[rndSwfNum][spNum][spNum]);
    }
    if((sp > 3) && (sp < 9)){
    spNum = 1;
    holder.gotoAndPlay(registerLablesArray[rndSwfNum][spNum][spNum]);
    }
    if(sp == 9){
    spNum = 2;
    holder.gotoAndPlay(registerLablesArray[rndSwfNum][spNum][spNum]);
    }
    break;
    case "regCont":


    finalSPNum = sp + 3;


    if(sp == 3){
    holder.gotoAndPlay("NoSale");
    }
    if((sp > 3) && (sp < 9)){
    trace("I OBJECT!")
    holder.gotoAndPlay("Objection");
    objLoader = new Loader();
    //objNum = Math.floor(Math.random() * 5);
    objNum = 0;
    objLoader.load(new URLRequest(objectionSwfArray[objNum]));
    objectionHolder.addChild(objLoader);


    Front_MC.questionText.text = objectionQuestionArray[objNum];

    if(randomNum == 0){
    Front_MC.option1_button.option_text.text = objectionOptionArray[objNum][0];
    Front_MC.option2_button.option_text.text = objectionOptionArray[objNum][1];
    Front_MC.option3_button.option_text.text = objectionOptionArray[objNum][2];
    }
    if(randomNum == 1){
    Front_MC.option1_button.option_text.text = objectionOptionArray[objNum][2];
    Front_MC.option2_button.option_text.text = objectionOptionArray[objNum][0];
    Front_MC.option3_button.option_text.text = objectionOptionArray[objNum][1];
    }
    if(randomNum == 2){
    Front_MC.option1_button.option_text.text = objectionOptionArray[objNum][1];
    Front_MC.option2_button.option_text.text = objectionOptionArray[objNum][2];
    Front_MC.option3_button.option_text.text = objectionOptionArray[objNum][0];
    }

    }
    if(sp == 9){
    holder.gotoAndPlay("Sale");
    }

    break;
    case "objections":
    trace(objectionOptionArray[objNum]);
    holder.objectionHolder.gotoAndPlay(objectionLables Array[randomNum][objNum]);
    trace(objectionLablesArray[randomNum][objNum]);
    trace(holder.objectionHolder.currentFrame + " = obj current frame label");

    /*
    if (finalSPNum == sp){
    trace("GOT HERE!");
    chanceRnd = (sp - 3) * 10;
    trace("chance Random = " + chanceRnd);
    diceRoll = Math.floor(Math.random() * 100);
    trace(diceRoll + " = diceroll");
    }
    if (diceRoll < chanceRnd){
    objectionHolder.removeChild(objLoader);
    //trace("obj loader removed SALE");
    //holder.objectionHolder.gotoAndPlay(objectionLables Array[randomNum][objNum]);
    holder.gotoAndPlay("Sale");

    }
    else{
    objectionHolder.removeChild(objLoader);
    //trace("obj loader removed NO SALE");
    holder.gotoAndPlay("NoSale");
    //holder.objectionHolder.gotoAndPlay(objectionLables Array[randomNum][objNum]);
    }
    */
    break;

    }

    }

  2. #2
    Dignitary rynoe's Avatar
    Join Date
    Jan 2003
    Location
    Earth
    Posts
    760
    Never nest AS3 code, always on main timeline or better yet in class file and I think you need to rap a lot of that into functions, otherwise it will only run when instanciated.
    [SIGPIC][/SIGPIC]

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