# Preload+classes

**URL:** <https://forum.kirupa.com/t/preload-classes/254856>\
**Category:** flash\
**Created:** [March 16, 2008, 11:33am UTC](https://forum.kirupa.com/t/preload-classes/254856 "2008-03-16T11:33:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![carnophager](https://avatars.discourse-cdn.com/v4/letter/c/dfb087/32.png) [@carnophager](https://forum.kirupa.com/u/carnophager)\
**Post date:** [March 16, 2008, 11:33am UTC](https://forum.kirupa.com/t/preload-classes/254856/1 "2008-03-16T11:33:31Z")

</div>

Hello I have a problem with something pretty simple I can’t understand…  
I have a fla file where I set the export classes frame to be different than 1 (the frame is 3 in this case) and on the fifth frame I have a stop(); action and a movie clip that’s instance of a class that’s linked to it from the library. And when the movie clip has no instance name everything is ok but when I give it one this error appears:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@2d14821 to Roller.

I have no clue how to fix it, please help.

Here’s an exemplary file:

> **[kirupaForum](http://forum.kirupa.com/)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!

---

<div class="post-metadata">

**Author:** ![Alex\_Lexcuk](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@Alex\_Lexcuk](https://forum.kirupa.com/u/Alex_Lexcuk)\
**Post date:** [August 23, 2008, 7:21pm UTC](https://forum.kirupa.com/t/preload-classes/254856/2 "2008-08-23T19:21:10Z")

</div>

Ok.  
I has lincage MovieClip class

```auto

package {
     import flash.display.*; 
     import flash.text.*; 
     import flash.geom.*;
 
 
    public class Central_all_loading_prog extends MovieClip {
    public var my_txt:TextField;
 
 
        public function Central_all_loading_prog() {
              var txt:TextField = new TextField();
              txt.text = "I am loading for 2 frame";
              txt.autoSize = TextFieldAutoSize.LEFT;            
              txt.scaleX=txt.scaleY=3;
              addChild(txt);//
              my_txt = txt;
 
        }
    }
}
 

```

and Documen Class export in 2 frame? if I want new Central\_all\_loading\_prog  
in Document Class mast loading class Central\_all\_loading\_prog

```auto

var Load_Central_all_loading_prog:Class = 
loaderInfo.applicationDomain.getDefinition("Central_all_loading_prog") as Class;

```

Document class all coding

```auto

package {
    import flash.display.*;
    import flash.text.*;
    import flash.events.*;
     import flash.filters.*;    
 
    public class My_doc_class extends MovieClip {
 
 
 
        public function My_doc_class() {
            //super();
            stop();
            preload_mc.scaleX = 0;
            loaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
            loaderInfo.addEventListener(Event.COMPLETE, completeHandler);
        }
 
        private function progressHandler(event:ProgressEvent):void {
            var loaded:uint = event.bytesLoaded;
            var total:uint = event.bytesTotal;
            var procent:uint = int(loaded/total*100);
            preload_mc.scaleX = loaded/total;
            preload_txt.text = "Progress
"+int(loaded/total*100);
            preload_txt.filters= new Array(new GlowFilter (0xffff00, procent, procent, procent,procent, 3, false, false));
        }
 
        private function completeHandler(event:Event):void {
            gotoAndStop(2);
            main();//after all loading
            //}
        }
 
        private function main():void {
            stop();
            var Load_Central_all_loading_prog:Class = 
            loaderInfo.applicationDomain.getDefinition("Central_all_loading_prog") as Class;
            var ex_mc = new Load_Central_all_loading_prog();//loading_class
            addChild(ex_mc);//this MovieClip has Class and his in 2 frame (SHOW HIM)
            ex_mc.y = 300;
            with (ex_mc.my_txt){border = true; background = true; y = -50;backgroundColor = 0xff0000;
            selectable = false; htmlText = "<a href=\"event:track1.mp3\">Press me</a>";}
            ex_mc.my_txt.addEventListener(TextEvent.LINK, goto_next);
            function goto_next(TextEvent)
            {
                nextFrame();
                stop();
                removeChild(ex_mc);
                var txt = new TextField();txt.scaleX=txt.scaleY=4;
                txt.htmlText = "<a href='http://www.dnadillo.dn.ua/fla/Prelod_2_frame.zip'>Zip</a>";
                addChild(txt);
            }
 
            /* // Logic, but not working code:
            var program:Central_all_loading_prog = new Central_all_loading_prog();
            addChild(program);
            */
        }
    }
}

```

example  
[http://www.dnadillo.dn.ua/fla/Preload-second-fram.html](http://www.dnadillo.dn.ua/fla/Preload-second-fram.html)
