0
votes

I am trying to embed a movieClip with flashDevelop but apparently its not working because its not recognizing the movieclips that are within it. here is my code

package com.objects{

    import flash.display.MovieClip
    import flash.text.TextField;
    import flash.events.*;
    import flash.text.TextFormat;

    [Embed(source='../../../lib/fighter.swf', symbol='InfoBox')] 
    public class InfoBox extends gameObject {

        protected var textf:TextField;
        protected var s:String;
        public var type:Boolean = false;
        private var letter:Number = 0;
        private var string:Array;
        private var line:Number = 0;
        private var portNum:Array;


        public function InfoBox():void
        {
            portNum = new Array();
            portrait.stop();
            x = 400;
            y = 550;

            string = new Array();
            var format = new TextFormat();
            format.size = 18;
            textf = new TextField();
            textf.width = 550;
            textf.height = 85;
            textf.x = -220;
            textf.y = -60;
            textf.wordWrap = true;
            textf.defaultTextFormat = format;
            addChild(textf);
            contButton.addEventListener(MouseEvent.MOUSE_DOWN, StoryNext);
        }

        private function StoryNext(e:MouseEvent):void
        {
            if(string.length > 1)
            {
                portNum.splice(0,1);
                string.splice(0,1);
                trace(string.length);
                letter = 0;
            }
            else
            {
                contButton.removeEventListener(MouseEvent.MOUSE_DOWN, StoryNext);
                dispatchEvent(new Event("StoryContinue"));
            }
        }

        public function textInfo(msg:String,num:Number = 1):void
        {
            string.push(msg);
            portNum.push(num);
        }

        override public function updateObject():void
        {
            TypeWords();

        }// End UpdateObject

        public function TypeWords():void
        {
            if(type)
            {
                portrait.gotoAndStop(portNum[0]);
                var s:String = string[0];               
                if(letter <= s.length)
                {
                    textf.text = s.substring(0,letter);
                }               
                letter++
            }
        }
    }
}

and I am getting this error

C:\Users\numerical25\Documents\RealGames\FighterPilot\beta1FlashDev\src\com\objects\InfoBox.as(23): col: 4 Error: Access of undefined property portrait.

portrait is a movie clip that I have inside of the info box movie clip. it is already on the stage and i gave it a instance name of portrait. It worked in flash, but now its not in flashDevelop

4

4 Answers

2
votes

Try accessing the childs by name. It should work.

(getChildByName("portrait") as MovieClip).gotoAndStop(portNum[0]);
1
votes

You need to define the corresponding properties on your class. In this case you can add:

public var portrait:MovieClip;

If it's some other type, for instance a Sprite you can change the definition to that.

EDIT: If you're having trouble setting up Flash Develop, I wrote some tutorials on that

1
votes

[Embed(source='../../../lib/fighter.swf', symbol='InfoBox')]

I'd say use SWCs not SWFs, it will make it a ****load easier.

SWCs keep all the stuff in place, whereas the swf can remove assets that are not used to save room.

Also in your flash develop panel you will see the swc (like the swf) and see all the classes that are included. Just right-click on it and add it to library. You won't have to use the [embed] code.

give that a try first, unless you absolutely need an swf.

To create an swc, use the flash tab under publish settings.

0
votes

you can add linkage name for your MovieClip and export it as SWC, suppose named "mymc" then copy SWC file to you FD project. in your code, just addChild(new mymc());