Skip navigation
Currently Being Moderated

Working with classes and accessing from the timeline...

Jul 10, 2012 10:40 AM

Hi,

 

I am trying to externalize a class and am having problems getting my class to work. On the flash timeline, I have this function call:

 

CreateText(lessonTitle, "Headline_1", textWidth, textX, textY - 5, 0xFCAF17, 54, 1, true, 0);

 

 

Which calls out to an external class:

 

package {

    import flash.display.*;
    import flash.text.*;

    public class CreateTextBlock extends MovieClip 
    {

        public function CreateTextBlock()
        {
                  // init           
        }

        public function CreateText(textString:String, 
                                                  textName:String, 
                                                  textWidth:Number, 
                                                  textX:Number, 
                                                  textY:Number, 
                                                  textColor:int, 
                                                  textSize:int, 
                                                  fontStyle:int, 
                                                  textWordWrap:Boolean, 
                                                  myLeading:int):void              
        {            
               trace(textString);
               trace(textName);
               trace(textWidth);
               trace(textX);
               trace(textY);
               trace(textColor);
               trace(textSize);
               trace(fontStyle);
               trace(textWordWrap);
               trace(myLeading);
        }        
     }
}

 

My function call does not recognize CreateText(), but recognizes CreateTextBlock, however, if rename my CreateText function to ChangeTextBlock, I continually receive the error message:

 



1137: Incorrect number of arguments.  Expected no more than 1.

 

Can anyone help me refactor this to a working class?, or point out my flaw?, hopefully it's platently obvious.

 

Thanks so much,

Chipleh

 
Replies
  • Currently Being Moderated
    Jul 10, 2012 12:24 PM   in reply to Chipleh

    Do you create an instance of the CreateTextBlock class?  If so, you should be targeting that instance to call upon its CreateText method.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 10, 2012 1:11 PM   in reply to Chipleh

    Unfortunately I am anything but adept in class matters. 

     

    If you used: 

     

         addChild(TextCreator); 

     

    to add the object, and that is the object you want to remove, then using:

     

        removeChild(TextCreator); 

     

    should be all you need to do, and just after that assign it to be null to remove all traces of it and make it available for GC:

     

        TextCreator = null;

    
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 10, 2012 5:50 PM   in reply to Chipleh

    You're welcome

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points