Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm writing this code in Flash builder and I tested the file in flash, but nothing appears in the swf file. (no text in the screen show , i don't know why) Is there any missing property in the code? Also, when I create text or movie clip with flash tools on the stage and give it an instance name, flash builder doesn't seem to recognize it in the action script code.

package
{
    import flash.display.MovieClip;
    import flash.text.TextField;

    public class mark extends MovieClip
    {

        public function mark()
        {

            super();
            public var d:TextField=new TextField();

            d.text="Hello world";
            d.x=250;
            d.y=300;
            addChild(d);


        }
    }
share|improve this question
    
That looks right. Are you sure you are calling the code? put a trace statement before the text and see if that is being called. Also you should make sure that mark has been added to the stage as well. –  AttackingHobo Aug 27 '12 at 21:04
    
can you tell me why if you create movieClip in Flash ,Flash builder does not recognize it. –  XNA Aug 27 '12 at 21:15
    
It does if you do it right. I don't see any of your code and really that is a separate question. –  AttackingHobo Aug 27 '12 at 21:23
3  
Where is "mark" instantiated? Is mark added to the stage? Is this your main file? How is flash builder connected to flash-cs5? Make sure your project settings are correct. You aren't giving us much insight. Also the reason I think flash builder doesn't recognize your stage objects is because when you use the the instance name in your object it's expecting to be a local variable or a member. At compile time at least. But i'm not 100% sure. –  Sidar Aug 27 '12 at 21:51
add comment

1 Answer 1

The first thing I recommend you is to always start class names with a capital letter. That way you can immediately see whether something is a class or a variable.

But that is style and shouldn't ruin your code. What actually is wrong as far as I know is the public keyword before var d:TextField. You declare that variable inside a function, and variables declared inside functions can only be accessed by code that can access the scope of that function. Declaring it as public doesn't make sense (and probably doesn't work) because the outside world doesn't even know that variable exists (and can't access it).

You'll probably solve the problem by either removing the public keyword or moving the variable declaration out of the mark( ) method.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.