EasyCFM.COM ColdFusion Forums / Flex Development / card layout

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: card layout

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

stinasius
04-15-2008 @ 10:43 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 109
Joined: Jan 2007

Hi i bumped on a cardlayout example on the net. it meant to layout staff like panels so that if there are more than one panel on stage one can click through the panels to view info. when i try to run the example i get this error. TypeError: Error #1009: Cannot access a property or method of a null object reference.
     at components::services/::bringToFront()
     at components::services/__commerce_click()
here is my code.

import mx.containers.Panel;
          private var order:Array;
          
          private function initStuff():void{
               order = new Array();
               order.push(html);
               order.push(flash);
               order.push(commerce);
               trace(order.length);
          }
          private function bringToFront(toFront:Panel):void{
               if(toFront != order[2]){
                    switch(toFront){
                         case commerce:
                              mov1.target = commerce; mov1.xTo = order[2].x; mov1.yTo = order[2].y;
                              mov2.target = order[2]; mov2.xTo = order[1].x; mov2.yTo = order[1].y;
                              mov3.target = order[0]; mov3.xTo = order[0].x; mov3.yTo = order[0].y;
                              if(commerce != order[1]){
                                   mov3.target = order[1]; mov3.xTo = order[0].x; mov3.yTo = order[0].y;     
                                   order[0] = order[1];                                   
                              }
                              
                              order[1] = order[2]; order[2] = commerce;
                              break;     
                              
                         case flash:
                              mov1.target = flash; mov1.xTo = order[2].x; mov1.yTo = order[2].y;
                              mov2.target = order[2]; mov2.xTo = order[1].x; mov2.yTo = order[1].y;
                              mov3.target = order[0]; mov3.xTo = order[0].x; mov3.yTo = order[0].y;
                              if(flash != order[1]){
                                   mov3.target = order[1]; mov3.xTo = order[0].x; mov3.yTo = order[0].y;     
                                   order[0] = order[1]; order[1] = order[2]; order[2] = flash;                                   
                              }
                              else{
                                   order[1] = order[2]; order[2] = flash;
                              }     
                              break;
                                        
                         case html:
                              mov1.target = html; mov1.xTo = order[2].x; mov1.yTo = order[2].y;
                              mov2.target = order[2]; mov2.xTo = order[1].x; mov2.yTo = order[1].y;
                              mov3.target = order[0]; mov3.xTo = order[0].x; mov3.yTo = order[0].y;
                              if(html != order[1]){
                                   mov3.target = order[1]; mov3.xTo = order[0].x; mov3.yTo = order[0].y;     
                                   order[0] = order[1];order[1] = order[2]; order[2] = html;                                   
                              }
                              else{
                                   order[1] = order[2]; order[2] = html;
                              }     
                              break;                    
                    }
                    parallelEff.play();          
               }
          
          }
          
          private function loadHandler():void{
               switch(order[2]){
                    case commerce  :
                                   img.visible = true;
                                   swf.visible = false;
                                   vd.stop(); vd.visible = false;
                                   break;
                    case flash  :     
                                   swf.visible = true;
                                   swf.load();
                                   img.visible = false;
                                   vd.stop(); vd.visible = false;
                                   break;
                    case html:
                                   vd.visible = true;
                                   vd.stop(); vd.play();
                                   swf.visible = false;
                                   img.visible = false;
                                   break;
               }
               //application.setChildIndex(order[0],0);
               //application.setChildIndex(order[1],1);
               //application.setChildIndex(order[2],2);
          }
and

click="bringToFront(commerce)"


kicker
04-15-2008 @ 5:47 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 717
Joined: Oct 2004

First and foremost if you are using string values then put quotes around them. No where in your script do you initialize a value of html, flash, or commerce. This I believe you mean them as strings. So quote them out.

you have:

private function initStuff():void{
               order = new Array();
               order.push(html);
               order.push(flash);
               order.push(commerce);
               trace(order.length);
          }

it should be:

private function initStuff():void{
               order = new Array();
               order.push("html");
               order.push("flash");
               order.push("commerce");
               trace(order.length);
          }



same with your case statements quote them out. The null value is happening because you haven't declare any of the string values as a variable. Hense instead of looking at html as a string it is looking at it as a variable. Make sense?


Craig

stinasius
04-16-2008 @ 9:14 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 109
Joined: Jan 2007

hi am sorry, i found that it was a very small mistake. i had forgotten to call creationcomplete. i guess i was tired. anyhow thanks alot.


Website Designed and Developed by Pablo Varando.