A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: add an MC?

  1. #1
    Senior Member
    Join Date
    Feb 2008
    Posts
    126

    add an MC?

    How can I add an MC from the library on to teh stage? (my AS is also in the time line)

    Thanks

  2. #2
    Member
    Join Date
    Jun 2008
    Location
    Ludhiana,Punjab
    Posts
    90
    Hi,

    I think you are new to AS3. It is very simple to add MC on the stage. First I create object of MC in the library. "Fwd_mc" is the name of the MC in the linkage. "addChild" is used to addChild. After adding you can access this MC by writing "mc".

    PHP Code:

    var mc:Fwd_mc=new Fwd_mc
    addChild
    (mc
    MannPohir
    <span style="font-family: Verdana">m...ail.com</span>

  3. #3
    Member
    Join Date
    Dec 2008
    Posts
    31
    Hello. I am having this problem as well so I thought I'd join in! Only difference is I'm trying to use all .as files Instead of the main timeline.

    I've managed to get my head around how to set up the Document Class file and others, so am trying to add everything through them (I'm needing to make an enemy multiply through hitTest/ events) .

    Here is the error it gives me (all of my characters are named by their Classes):

    5000: The class 'BeanClass' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type.

  4. #4
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Daves - you need your subclasses to line up...so in your library, pull up the linkage info for your object and make sure it's set to package.BeanClass and a subclass of flash.display.MovieClip...then in your package/BeanClass.as file you need to extend MC in your definition line:

    public class BeanClass extends MovieClip{

  5. #5
    Member
    Join Date
    Dec 2008
    Posts
    31
    Thanks neznein9 - thats cleared up the error for me now!

    One other thing...
    I've made a function inside the package.PureBeanClass that should add an instance of 'bean' to the stage.

    What I'd like it to do is add the 'bean' to the stage as soon as the swf loads.

    PHP Code:
    package bean {
        
    import flash.display.MovieClip;
        
        
        public class 
    PureBeanClass extends MovieClip {
        
        public function 
    addPureBean() {
        
        var 
    beanrun:Number 20;
        var 
    beanInstance:MovieClip = new PureBeanClass();
        
    addChild(beanInstance);
        
    beanInstance.+= beanrun;
        
    beanInstance.300.5;
        
        }
        }    

    That is okay I think..

    The problem I have however is figuring out how to use my DocumentClass (named DocumentClass) to use this function after importing the PureBeanClass package.

    PHP Code:
    package {
        
    import flash.events.Event;
        
    import flash.events.MouseEvent;
        
    import flash.display.MovieClip;
        
    import bean.PureBeanClass;
        
        public class 
    DocumentClass extends MovieClip {

                    
        public function 
    DocumentClass() {
        
        
    root.onLoad = function { (PureBeanClass.addPureBean()); }

        }
            

    I imported the bean.PureBeanClass and I've tried to use this code (in my DocumentClass), but being new to the language I can't figure out how to make it run the 'addPureBean' function when the swf first loads.

    What event could be available in as3 to run the addPureBean function?

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