How to load multiple swfs to my main flash file??

I am using the following code
In actions for Frame 1:
var myrequest:URLRequest=new URLRequest("A.swf");     
var myloader:Loader=new Loader();
myloader.load(myrequest);
img1.addEventListener(MouseEvent.CLICK, clickButton);
function clickButton(event:MouseEvent):void{               
    stage.addChild(myloader);
img1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_5);
function fl_ClickToGoToAndStopAtFrame_5(event:MouseEvent):void
     gotoAndStop(13);
In action for Frame 13:   (img2 is another button)
img2.addEventListener(MouseEvent.CLICK, unloadFunction);
function unloadFunction(event:Event):void{
     stage.removeChild(myloader);
This code works perfectly fine. My only problem is, How do I get multiple swf loaded. When I tried to copy and paste the same code for the other swf, but the following errors appear. I'm pretty sure theres a way to have multiple swfs (btw the multiple swfs will be linked from different frames).
Scene 1, Layer 'PAGES!', Frame 2, Line 7 1021: Duplicate function definition.
Scene 1, Layer 'PAGES!', Frame 2, Line 2 1151: A conflict exists with definition myloader in namespace internal.
Scene 1, Layer 'PAGES!', Frame 2, Line 1 1151: A conflict exists with definition myrequest in namespace internal.
Can someone please help me with this. Thanks

You define the same variable or function names more than once in a file.  But you can reuse them in other frames.  Try something more like the following in frame 2....
myrequest=new URLRequest("A.swf");     
myloader.load(myrequest);
leave all of the rest out for starters... the same function from frame 1 can be re-used without rewriting them.  I don't know what the deal is with img1, but if you need to change what it does, then add that back in.

Similar Messages

  • HELP! How to load multiple swfs using the following code?

    In actions for Frame 1:
    var myrequest:URLRequest=new URLRequest("A.swf");     
    var myloader:Loader=new Loader();
    myloader.load(myrequest);
    img1.addEventListener(MouseEvent.CLICK, clickButton);
    function clickButton(event:MouseEvent):void{               
        stage.addChild(myloader);
    img1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_5);
    function fl_ClickToGoToAndStopAtFrame_5(event:MouseEvent):void
         gotoAndStop(13);
    In action for Frame 13:   (img2 is another button)
    img2.addEventListener(MouseEvent.CLICK, unloadFunction);
    function unloadFunction(event:Event):void{
         stage.removeChild(myloader);

    do you want to load another swf (eg, B.swf) when you're in frame 13 and img2 is clicked?  if yes, and you don't want A.swf to continue to play, use:
    //In action for Frame 13:   (img2 is another button)
    img2.addEventListener(MouseEvent.CLICK, loadF2);
    function loadF2(event:Event):void{
        myloader.load(new URLRequest("B.swf"));

  • Remove / unload external swf file(s) from the main flash file and load a new swf file and garbage collection from memory.

    I can't seem to remove / unload the external swf files e.g when the carousel.swf (portfolio) is displayed and I press the about button the about content is overlapping the carousel (portfolio) . How can I remove / unload an external swf file from the main flash file and load a new swf file, while at the same time removing garbage collection from memory?
    This is the error message(s) I am receiving: "TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/removeChild()
    at index_fla::MainTimeline/Down3()"
    import nl.demonsters.debugger.MonsterDebugger;
    var d:MonsterDebugger=new MonsterDebugger(this);
    stage.scaleMode=StageScaleMode.NO_SCALE;
    stage.align=StageAlign.TOP_LEFT;
    stage.addEventListener(Event.RESIZE, resizeHandler);
    // loader is the loader for portfolio page swf
    var loader:Loader;
    var loader2:Loader;
    var loader3:Loader;
    var loader1:Loader;
    //  resize content
    function resizeHandler(event:Event):void {
        // resizes portfolio page to center
    loader.x = (stage.stageWidth - loader.width) * .5;
    loader.y = (stage.stageHeight - loader.height) * .5;
    // resizes about page to center
    loader3.x = (stage.stageWidth - 482) * .5 - 260;
    loader3.y = (stage.stageHeight - 492) * .5 - 140;
    /*loader2.x = (stage.stageWidth - 658.65) * .5;
    loader2.y = (stage.stageHeight - 551.45) * .5;*/
    addEventListener(Event.ENTER_FRAME, onEnterFrame,false, 0, true);
    function onEnterFrame(ev:Event):void {
    var requesterb:URLRequest=new URLRequest("carouselLoader.swf");
    loader = null;
    loader = new Loader();
    loader.name ="carousel1"
    //adds gallery.swf to stage at begining of movie
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader.load(requesterb);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader);
    loader.x = (stage.stageWidth - 739) * .5;
    loader.y = (stage.stageHeight - 500) * .5;
    // stop gallery.swf from duplication over and over again on enter frame
    removeEventListener(Event.ENTER_FRAME, onEnterFrame);
    //PORTFOLIO BUTTON
    //adds eventlistner so that gallery.swf can be loaded
    MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    function Down(event:MouseEvent):void {
    // re adds listener for contact.swf and about.swf
    MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
    MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    //unloads gallery.swf from enter frame if users presses portfolio button in nav
    var requester:URLRequest=new URLRequest("carouselLoader.swf");
        loader = null;
    loader = new Loader();
    loader.name ="carousel"
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader.load(requester);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader);
    loader.x = (stage.stageWidth - 739) * .5;
    loader.y = (stage.stageHeight - 500) * .5;
    removeChild( getChildByName("about") );
    removeChild( getChildByName("carousel1") );
    // remove eventlistner and prevents duplication of gallery.swf
    MovieClip(root).nav.portfolio.removeEventListener(MouseEvent.MOUSE_DOWN, Down);
    //INFORMATION BUTTON
    //adds eventlistner so that info.swf can be loaded
    MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
    function Down1(event:MouseEvent):void {
    //this re-adds the EventListener for portfolio so that end user can view again if they wish.
    MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    var requester:URLRequest=new URLRequest("contactLoader.swf");
    loader2 = null;
    loader2 = new Loader();
    loader2.name ="contact"
    loader2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader2.load(requester);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader2);
    loader2.x = (stage.stageWidth - 658.65) * .5;
    loader2.y = (stage.stageHeight - 551.45) * .5;
    // remove eventlistner and prevents duplication of info.swf
    MovieClip(root).nav.info.removeEventListener(MouseEvent.MOUSE_DOWN, Down1);
    //ABOUT BUTTON
    //adds eventlistner so that info.swf can be loaded
    MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    function Down3(event:MouseEvent):void {
    //this re-adds the EventListener for portfolio so that end user can view again if they wish.
    MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
    var requester:URLRequest=new URLRequest("aboutLoader.swf");
    loader3 = null;
    loader3 = new Loader();
    loader3.name ="about"
    loader3.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader3.load(requester);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader3);
    loader3.x = (stage.stageWidth - 482) * .5 - 260;
    loader3.y = (stage.stageHeight - 492) * .5 - 140;
    removeChild( getChildByName("carousel") );
    removeChild( getChildByName("carousel1") );
    // remove eventlistner and prevents duplication of info.swf
    MovieClip(root).nav.about.removeEventListener(MouseEvent.MOUSE_DOWN, Down3);
    stop();

    Andrei1,
    Thank you for the helpful advice. I made the changes as you suggested but I am receiving a #1009 error message even though my site is working the way I wan it to work. I would still like to fix the errors so that my site runs and error free. This is the error I am receiving:
    "TypeError: Error #1009: Cannot access a property or method of a null object reference."
    I'm sure this is not the best method to unload loaders and I am guessing this is why I am receiving the following error message.
         loader.unload();
         loader2.unload();
         loader3.unload();
    I also tried creating a function to unload the loader but received the same error message and my portfolio swf was not showing at all.
         function killLoad():void{
         try { loader.close(); loader2.close; loader3.close;} catch (e:*) {}
         loader.unload(); loader2.unload(); loader3.unload();
    I have a question regarding suggestion you made to set Mouse Event to "null". What does this do setting the MouseEvent do exactly?  Also, since I've set the MouseEvent to null do I also have to set the loader to null? e.g.
    ---- Here is my updated code ----
    // variable for external loaders
    var loader:Loader;
    var loader1:Loader;
    var loader2:Loader;
    var loader3:Loader;
    // makes borders resize with browser size
    function resizeHandler(event:Event):void {
    // resizes portfolio page to center
         loader.x = (stage.stageWidth - loader.width) * .5;
         loader.y = (stage.stageHeight - loader.height) * .5;
    // resizes about page to center
         loader3.x = (stage.stageWidth - 482) * .5 - 260;
         loader3.y = (stage.stageHeight - 492) * .5 - 140;
    //adds gallery.swf to stage at begining of moviie
         Down();
    //PORTFOLIO BUTTON
    //adds eventlistner so that gallery.swf can be loaded
         MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    function Down(event:MouseEvent = null):void {
    // re adds listener for contact.swf and about.swf
         MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
         MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    //unloads gallery.swf from enter frame if users presses portfolio button in nav
         var requester:URLRequest=new URLRequest("carouselLoader.swf");
         loader = new Loader();
         loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
         function ioError(event:IOErrorEvent):void {
         trace(event);
         try {
         loader.load(requester);
         } catch (error:SecurityError) {
         trace(error);
         this.addChild(loader);
         loader.x = (stage.stageWidth - 739) * .5;
         loader.y = (stage.stageHeight - 500) * .5;
    // sure this is not the best way to do this - but it is unload external swfs
         loader.unload();
         loader2.unload();
         loader3.unload();
    // remove eventlistner and prevents duplication of gallery.swf
         MovieClip(root).nav.portfolio.removeEventListener(MouseEvent.MOUSE_DOWN, Down);
    //INFORMATION BUTTON
         //adds eventlistner so that info.swf can be loaded
         MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
         function Down1(event:MouseEvent = null):void {
         //this re-adds the EventListener for portfolio so that end user can view again if they wish.
         MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
         MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
         var requester:URLRequest=new URLRequest("contactLoader.swf");
         loader2 = null;
         loader2 = new Loader();
         loader2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);    
         function ioError(event:IOErrorEvent):void {
         trace(event);
         try {
         loader2.load(requester);
    }      catch (error:SecurityError) {
         trace(error);
         addChild(loader2);
         loader2.x = (stage.stageWidth - 658.65) * .5;
         loader2.y = (stage.stageHeight - 551.45) * .5;
    loader.unload();
    loader2.unload();
    loader3.unload();
         // remove eventlistner and prevents duplication of info.swf
         MovieClip(root).nav.info.removeEventListener(MouseEvent.MOUSE_DOWN, Down1);
    //ABOUT BUTTON
         //adds eventlistner so that info.swf can be loaded
         MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
         function Down3(event:MouseEvent = null):void {
         //this re-adds the EventListener for portfolio so that end user can view again if they wish.
         MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
         MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
         var requester:URLRequest=new URLRequest("aboutLoader.swf");
         loader3 = null;
         loader3 = new Loader();
         loader3.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
         function ioError(event:IOErrorEvent):void {
         trace(event);
         try {
         loader3.load(requester);
    }      catch (error:SecurityError) {
         trace(error);
         addChild(loader3);
         loader3.x = (stage.stageWidth - 482) * .5 - 260;
         loader3.y = (stage.stageHeight - 492) * .5 - 140;
         loader.unload();
         loader2.unload();
         loader3.unload();
         // remove eventlistner and prevents duplication of info.swf
         MovieClip(root).nav.about.removeEventListener(MouseEvent.MOUSE_DOWN, Down3);
         stop();

  • Flash player 10.3.181.14 broke my site, loading multiple swfs into an array

    I load multiple swfs into an array, I add and remove the objects on the stage, this is for a rotating carousel.
    All the items locations are established in xml. If I only have one item loaded into the array it works fine, if I have more then one it will not a) play the swf, or b) show the swf.
    The swfs themselves contain code that fire events in the main container. Which cause other items to play or load.
    Is anyone else having this issue?

    Hi howet,
    EDIT:
    I've opened a flash bug in their bug system as I found I could reproduce the issue: https://bugs.adobe.com/jira/browse/FP-7071
    There are some workarounds I found on there.
    ORIGINAL MESSAGE:
    I was having a similar issue using a loading component which i've been using for several years with no issues. As with you the issue arose when loading multiple swfs (or even one swf and then a jpg) on 10.3 and above. It works fine on 10.2 and below still.
    I found a workaround whilst I look for a proper answer and that is to delay subsequent loads using a hacky setTimeout.
    For example:
    protected function manageLoaded (p_event : Event) : void {
    setTimeout(loadNext, 1);
    // following line breaks the gotoAndStop of loaded swfs.
    // loadNext();
    I hope this helps you too, let me know.
    Cheers,
    Dan.
    Message was edited by: Dan Wilkinson, 01/06/2011 11:37am BST (GMT + 1)

  • Load multiple swf play one by one when required

    Dear Friends,
    i want to Load multiple swf play one by one when required, i mean, i want to reduce the loading time, so i cut my swf in to 2 portion, load both same time or load 2nd while 1st one playing and how can i show the 2nd one when first one finished?
    Thanks in advance,
    Regards,
    Syed Abdul Rahim

    see i write code for you may be it will helps you
    var vidno:int=1
    var totalvideos:int=10
    var ld:loader
    function loadvideo(str:String)
    addChild(ld)
    loader.load(urlrequest(str))
    loader.contentLoaderInfo.addEventListener(Event.Complete,loadnext)
    function loadnext(event:Event):void{
    removeChild(ld)
    if(vidno<totalvideos){
        vidno++
         loadvideo('vid'+vidno+'.swf')
    loadvideo(vid1.swf)
    try it..

  • Loading multiple swfs using air 3.6 for ios

    Adobe, can you please provide us with the code to load multiple swf files for ios. Please provide examples. The code below loads multiple swfs, but the swfs stall, so this does not seem to be a solution.
    Code description: A flash file made up of 4 frames with forward and back buttons that navigate from frame to frame. The code loads three different swf files in frames 2, 3 and 4.
    Frame 1:
    var myLoader:Loader;
    var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
    if(myLoader == null){myLoader = new Loader(); addChild(myLoader); }
    else {myLoader.unload();}
    Frame 2:
    myLoader.unload();
    myLoader.load(new URLRequest("file1.swf"),loaderContext);
    Frame 3:
    myLoader.unload();
    myLoader.load(new URLRequest("file2.swf"),loaderContext);
    Frame 4:
    myLoader.unload();
    myLoader.load(new URLRequest("file3.swf"),loaderContext);

    I've just tried loading, unloading and then loading again same SWF with 2 library objects linked for AS3 export. It worked both on simulator and on device in debug mode. When I look inside swf it does contain AS3 code.
    So is my swf a pure asset SWF? Or Intellij Idea 12 that I'm using does stripping automatically?
    And then I've read your comment at http://forums.adobe.com/message/5217325#5217325 and run 'swfdump' utility on my .swf file. Looks like there's no ABC2 code, that's why app was able to load, unload and load again the same swf.
    public dynamic class net.games.bg extends flash.display.MovieClip
      native public function bg():*;
      native public var one:flash.display.MovieClip;
      native public var three:flash.display.MovieClip;
      native public var two:flash.display.MovieClip;
    public dynamic class net.games.z1 extends flash.display.MovieClip
      native public function z1():*;
    I can access objects as instances through root  or as objects through getDefinition.
    private var aLoader : Loader;
    private function init():void
                load1();
            private function load1():void
                aLoader   = new Loader();
                var url:URLRequest = new URLRequest("levels/expirementlevel1.swf");
                var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
                aLoader.load(url, loaderContext); // load the SWF file
                aLoader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, handleSWFLoadComplete1, false, 0, true);
            private function handleSWFLoadComplete1(e:flash.events.Event):void {
                var levelObjectsMC:flash.display.MovieClip = e.target.loader.content;
                for (var i:uint = 0; i < levelObjectsMC.numChildren; i++){
                    trace ('\t|\t ' +i+'.\t name:' + levelObjectsMC.getChildAt(i).name + '\t type:' + typeof (levelObjectsMC.getChildAt(i))+ '\t' + levelObjectsMC.getChildAt(i).x);
                var LibraryClass:Class = e.target.applicationDomain.getDefinition("net.games.z1") as Class;
                var myLibraryObject:flash.display.MovieClip = new LibraryClass as flash.display.MovieClip;
                trace(' load 1 ' + myLibraryObject);
                aLoader.unload();
                load2();
                //addChild(levelObjectsMC);
            private function load2():void
                aLoader   = new Loader();
                var url:URLRequest = new URLRequest("levels/expirementlevel1.swf");
                var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
                aLoader.load(url, loaderContext); // load the SWF file
                aLoader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, handleSWFLoadComplete2, false, 0, true);
            private function handleSWFLoadComplete2(e:flash.events.Event):void {
                var levelObjectsMC:flash.display.MovieClip = e.target.loader.content;
                for (var i:uint = 0; i < levelObjectsMC.numChildren; i++){
                    trace ('\t|\t ' +i+'.\t name:' + levelObjectsMC.getChildAt(i).name + '\t type:' + typeof (levelObjectsMC.getChildAt(i))+ '\t' + levelObjectsMC.getChildAt(i).x);
                var LibraryClass:Class = e.target.applicationDomain.getDefinition("net.games.z1") as Class;
                var myLibraryObject:flash.display.MovieClip = new LibraryClass as flash.display.MovieClip;
                trace('load 2 x ' + myLibraryObject.x);
                aLoader.unload();

  • About loading multiple swfs

    Hello folks...
    I have some serious problem with loading multiple swfs in a
    swfLoader whithin an application...
    The problem is that... every time I load another swf in a
    swfloader,
    the memory that the Internet Explorer uses justs keeps going
    up and up
    and one time (maybe after 15 - 20 minutes) it just crashes...
    To be more specific, my application loads a new swf in a
    regular basis (every 30 seconds)
    to make it like a slideshow...
    and it also has fonts embedded in it
    yet to minimize the total memory used by this application,
    I've did somthing like this...
    var sys:SystemManager = contentLoader.content as
    SystemManager;
    if (sys && sys.numChildren>0) {
    sys.removeChildAt(0);
    contentLoader.content.loaderInfo.loader.unload();
    contentLoader.source= DisplayManager.convertToAppSWFName (
    subAppID );
    and every application has an removedEventHandler which
    listens to removed Event,
    and removes all listeners registered to it when it is removed
    from this display list..
    So I'm very curious why the memory usages just keeps
    rising...
    If you have any hints, they'd be greatly appreciated...
    Thanks in advance!!!!

    Loading external swf containing code (even a single stop() !) is not allowed on iOS...

  • Loading multiple swf's in runtime and playing them one after other

    Hi,
    I am looking for help in loading multiple swf's as a playlist and playing them one after other on top of the other, so here even we have to play with display list for the visiblity.
    Tried to load single files but not getting for multiple files, what will be the event with which the dynamically loaded swf switch to other.These file names will be mentioned in XML file.
    Please let me know your thoughts and will be greatfull if anybody can help with the script or any kind of tutorials.

    Hi,
    First of all am thanking you for showing your kind intrest towards this thread, and appreciate for spending time to work out this issue.
    I will explain you in deatil the issue what am facing,I am working on a project where basically dealing with flv player and videos, am trying to play multiple flv videos of a 3d human character who is speaking out a number like 3550.
    Here we are using multiple video files and joining them like videos where character says 3 then 1000 then  5 then 50.
    The issue here is after every video there is a fraction of second where the character is disappearing from the stage which we can't afford because all the numbers have to be played at once to show it as one single digit.
    So thought of trying swf's instead of flv so that we can omit the gap between the numbers, but even in this swf's also having same issue for a fraction of second the character is missing from the stage.
    I am looking for a solution to this, either the way can work out as flv or swf.For flv am trying to edit some player where we can remove the delay between the clips.
    I am attaching new swf where the character is speaking 3 numbers like 3,1000,40.You can notice there is a flicker between the swf's.
    Can we use Display list with which we can omit that gap.
    Looking for your thoughts and help.
    Thank you

  • How to load color table in a indexed mode file??

    How to load color table in a indexed mode file??
    Actually, if i opened a indexed file and want to edit color table by loading another color table from desktop (or any other location), any way to do this through java scripting??

    continuing...
    I wrote a script to read a color table from a GIF file and save to an ACT color table file. I think it might be useful for someone.
    It goes a little more deeper than the code I posted before, as it now identifies the table size. It is important because it tells how much data to read.
    Some gif files, even if they are saved with a reduced palette (less than 256), they have all the bytes for the full color palette filled inside the file (sometimes with 0x000000). But, some gif files exported in PS via "save for web" for example, have the color table reduced to optimize file size.
    The script store all colors into an array, allowing some kind of sorting, or processing at will.
    It uses the xlib/Stream.js in xtools from Xbytor
    Here is the code:
    // reads the color table from a GIF image
    // saves to an ACT color table file format
    #include "xtools/xlib/Stream.js"
    // read the 0xA byte in hex format from the gif file
    // this byte has the color table size info at it's 3 last bits
    Stream.readByteHex = function(s) {
      function hexDigit(d) {
        if (d < 10) return d.toString();
        d -= 10;
        return String.fromCharCode('A'.charCodeAt(0) + d);
      var str = '';
      s = s.toString();
         var ch = s.charCodeAt(0xA);
        str += hexDigit(ch >> 4) + hexDigit(ch & 0xF);
      return str;
    // hex to bin conversion
    Math.base = function(n, to, from) {
         return parseInt(n, from || 10).toString(to);
    //load test image
    var img = Stream.readFromFile("~/file.gif");
    hex = Stream.readByteHex(img);      // hex string of the 0xA byte
    bin = Math.base(hex,2,16);          // binary string of the 0xA byte
    tableSize = bin.slice(5,8)          // Get the 3 bit info that defines size of the ct
    switch(tableSize)
    case '000': // 6 bytes table
      tablSize = 2
      break;
    case '001': // 12 bytes table
      tablSize = 4
      break;
    case '010': // 24 bytes table
      tablSize = 8
      break;
    case '011': // 48 bytes table
      tablSize = 16
      break;
    case '100': // 96 bytes table
      tablSize = 32
      break;
    case '101': // 192 bytes table
      tablSize = 64
      break;
    case '110': // 384 bytes table
      tablSize = 128
      break;
    case '111': // 768 bytes table
      tablSize = 256
      break;
    //========================================================
    // read a color (triplet) from the color lookup table
    // of a GIF image file | return 3 Bytes Hex String
    Stream.getTbColor = function(s, color) {
      function hexDigit(d) {
        if (d < 10) return d.toString();
        d -= 10;
        return String.fromCharCode('A'.charCodeAt(0) + d);
      var tbStart = 0xD; // Start of the color table byte location
      var colStrSz = 3; // Constant -> RGB
      var str = '';
      s = s.toString();
         for (var i = tbStart+(colStrSz*color); i < tbStart+(colStrSz*color)+colStrSz; i++) {
              var ch = s.charCodeAt(i);
              str += hexDigit(ch >> 4) + hexDigit(ch & 0xF);
          return str;
    var colorHex = [];
    importColors = function (){
         for (i=0; i< tablSize; i++){ // number of colors
              colorHex[i] = Stream.getTbColor(img, i);
    importColors();
    // remove redundant colors
    // important to determine exact color number
    function unique(arrayName){
         var newArray=new Array();
         label:for(var i=0; i<arrayName.length;i++ ){ 
              for(var j=0; j<newArray.length;j++ ){
                   if(newArray[j]==arrayName[i])
                        continue label;
              newArray[newArray.length] = arrayName[i];
         return newArray;
    colorHex = unique(colorHex);
    // we have now an array with all colors from the table in hex format
    // it can be sorted if you want to have some ordering to the exported file
    // in case, add code here.
    var colorStr = colorHex.join('');
    //=================================================================
    // Output to ACT => color triplets in hex format until 256 (Adr. dec 767)
    // if palette has less than 256 colors, is necessary to add the
    // number of colors info in decimal format to the the byte 768.
    ColorNum = colorStr.length/6;
    lstclr = colorStr.slice(-6); // get last color
    if (ColorNum < 10){
    ColorNum = '0'+ ColorNum;
    cConv = function (s){
         var opt = '';
         var str = '';
         for (i=0; i < s.length ; i++){
              for (j=0; j<2 ; j++){
                   var ch = s.charAt(i+j);
                   str += ch;
                   i ++;
              opt += String.fromCharCode(parseInt(str,16));
              str = '';
         return opt
    output = cConv(colorStr);
    // add ending file info for tables with less than 256 colors
    if (ColorNum < 256){
         emptyColors = ((768-(colorStr.length/2))/3);
         lstclr = cConv(lstclr);
         for (i=0; i < emptyColors ; i++){
              output += lstclr; // fill 256 colors
    output += String.fromCharCode(ColorNum) +'\xFF\xFF'; // add ending bytes
    Stream.writeToFile("~/file.act", output);
    PeterGun

  • How to load and display the external flv video files in dynamicly and the how to control the flv fil

    How to load and display the external flv video files in dynamicly using AS 3.0
    and  How to control the flv file  add the play paus button and add seekbar.
    I have using to load the flv file following code
    var flvPlaceHolder1:MovieClip = new MovieClip();
    var vid1:Video = new Video(734, 408);
    flvPlaceHolder1.addChild(vid1);
    addChild(flvPlaceHolder1);
    flvPlaceHolder1.x = 1059;
    flvPlaceHolder1.y = 152;
    var nc1:NetConnection = new NetConnection();
    nc1.connect(null);
    var ns1:NetStream = new NetStream(nc1);
    vid1.attachNetStream(ns1);
    var listener1:Object = new Object();
    listener1.onMetaData = function(evt:Object):void {};
    ns1.client = listener1;
    ns1.play("GV-1600 TURNING.flv");
    ns1.addEventListener(NetStatusEvent.NET_STATUS, statusChanged1);
    function statusChanged1(ns1:NetStatusEvent):void
             trace(ns1.info.code);
            if (ns1.info.code == 'NetStream.Buffer.Empty')
                 trace('the video has ended');
                 removeChild(flvPlaceHolder1);
                 //trace('removeChild');
                gotoAndPlay(1786);
    then how to add the play,paus ,full screen button    and   seekbar,volumebar.

    I have to Create the flash presentation for our company product
    In this presentation the left  side the text animation are displayed then right side the our product video is displayed.
    In this presentation i need the following option :
    1, The first product video and animation is finished then the next product is played
    2, then the video displayed  (size width and height 400x300) , I click this video to increase the size(ex:1000x700)
    3, then the playing video i control  it play, stop, paus button and volume bar, seek bar.
    4, then this presentation is displayed on 42 inches LCD TV so this full presentation is run full screen.
    I have finished first two steps 1 and 2
    the following are the screen short and code:-
    code :-
    var count=0;
    var flvPlaceHolder2:MovieClip = new MovieClip();   
    var vid2:Video = new Video(734, 408);
    flvPlaceHolder2.addChild(vid2);
    addChild(flvPlaceHolder2);
    flvPlaceHolder2.x = 1059;
    flvPlaceHolder2.y = 152;
    var nc2:NetConnection = new NetConnection();
    nc2.connect(null);
    var ns2:NetStream = new NetStream(nc2);
    vid2.attachNetStream(ns2);
    var listener2:Object = new Object();
    listener2.onMetaData = function(evt:Object):void {};
    ns2.client = listener2;
    ns2.play("GS-4000.flv");
    this.addEventListener(Event.ENTER_FRAME, BtnFadeIn2);
    function BtnFadeIn2(event:Event):void
        if (this.currentFrame == 387)
            /*flvPlaceHolder2.x = 30;
            flvPlaceHolder2.y = 140;
            vid2.width=1800;
            vid2.height=800;
            trace('Screen size is changed');*/
            if(count==0)
            flvPlaceHolder2.x = 30;
            flvPlaceHolder2.y = 140;
            vid2.width=1800;
            vid2.height=800;
            count++;
    ns2.addEventListener(NetStatusEvent.NET_STATUS, statusChanged2);
    function statusChanged2(ns2:NetStatusEvent):void
        trace(ns2.info.code);
        if (ns2.info.code == 'NetStream.Buffer.Empty')
                trace('the video has ended');
                 removeChild(flvPlaceHolder2);
                 //trace('removeChild');
                gotoAndPlay(433);
    flvPlaceHolder2.buttonMode=true;
    flvPlaceHolder2.addEventListener(MouseEvent.CLICK,home2);
    function home2(e:MouseEvent):void
        if(vid2.width==734 && vid2.height==408)
            flvPlaceHolder2.x = 30;
            flvPlaceHolder2.y = 140;
            vid2.width=1800;
            vid2.height=800;
        else
            flvPlaceHolder2.x = 1059;
            flvPlaceHolder2.y = 152;
            vid2.width=734;
            vid2.height=408;

  • Load different xml structure in single flash file

    Hi to all,
    How can i call different xml structures in single file..
    actually i am looking for 2 different menu galleries in single
    file.. first menu contains.. some 4 to 5 buttons.. done with this..
    in other flash file..having some of 4-5 buttons.. and these
    buttons.. to show in main flash file.. can i load 2 different swf
    files in single main file and with different xml structure please
    help me on this.. thanks in advance.
    Best Regards
    Satish Kumar Rajula

    yes, you can use one xml instance with an if-statement, but
    it's easier and cleaner to use different xml instances and
    different parsing code for each xml file loaded that has different
    structure.

  • Loading multiple SWFs and storing them (code not working under Firefox 23 and Chrome)

    Hey guys,
    Anyone has any idea why this code suddenly don't work anymore? (It works under internet explorer but not firefox and chrome
    The code under is placed on my main swf to preload all my external swfs and store them for not having to wait too long to access them.
    Thx guys.
    I took the code from here btw: http://www.beautifycode.com/the-finer-art-of-loading-2-handling-multiple-swfs#snippet
    I'm running flash player 11.8.800.94... It used to work under Firefox and Chrome
    var _swfLoader:Loader;
    var _swfRequest:URLRequest;
    var _swfPathArr:Array = new Array("00.swf", "01.swf", "02.swf");
    var _swfClipsArr:Array = new Array();
    var _swfTempClip:MovieClip;
    var _loadedSWFs:int;
    startLoading(_swfPathArr);
    function startLoading(pathArr:Array):void {
    _swfLoader = new Loader();
    _swfRequest = new URLRequest();
    loadSWF(pathArr[1]);
    function loadSWF(path:String):void {
    setupListeners(_swfLoader.contentLoaderInfo);
    _swfRequest.url = path;
    _swfLoader.load(_swfRequest);
    function setupListeners(dispatcher:IEventDispatcher):void {
    dispatcher.addEventListener(Event.COMPLETE, onSwfComplete);
    function onSwfComplete(event:Event):void {
    event.target.removeEventListener(Event.COMPLETE, onSwfComplete);
    _swfTempClip = event.target.content;
    _swfTempClip.customID = _loadedSWFs;
    _swfClipsArr.push(_swfTempClip);
    if(_loadedSWFs <_swfPathArr.length - 1) {
    _loadedSWFs++;
    loadSWF(_swfPathArr[_loadedSWFs]);
    } else {

    Hi kglad,
    The problem was coming from my server.
    I recently played with some settings  from a "cache control tool" offered by my hosting but i thought i had it back at default. Turns out i must've missed something. Now i have the .html caching on and everything works good on all browser.
    I have another question tho...
    I'd like to know if there's a way to cache an html file without having to ask my hoster to cache all of my htmls...
    I'm using this code now but maybe there's a way to add something that will cache this page specifically?
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>title</title>
    <script language="javascript">AC_FL_RunContent = 0;</script>
    <script src="fluid_site.js" language="javascript"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    <link href="style.css" rel="stylesheet" type="text/css" media="screen"/>
    </head>
    <!--url's used in the movie-->
    <!--text used in the movie-->
    <!-- saved from url=(0013)about:internet -->
    <script>
        if (AC_FL_RunContent == 0) {
            alert("This page requires fluid_site.js.");
        } else {
            AC_FL_RunContent(
                'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
                'width', '100%',
                'height', '100%',
                'src', 'index',
                'quality', 'medium',
                'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
                'align', 'middle',
                'play', 'true',
                'loop', 'true',
                'scale', 'showall',
                'devicefont', 'false',
                'wmode', 'window',
                'id', 'index',
                'name', 'index',
                'menu', 'false',
                'allowFullScreen', 'false',
                'allowScriptAccess','sameDomain',
                'movie', 'index',
                'salign', ''
                ); //end AC code
    </script>
    <body>
    <noscript>
        <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="100%" height="100%" id="index" align="middle">
        <param name="allowScriptAccess" value="sameDomain" />
        <param name="allowFullScreen" value="false" />
        <param name="MENU" value="false">
        <param name=wmode value=window>
        <param name="movie" value="index.swf" /><param name="quality" value="medium" /><embed src="index.swf" quality="medium" width="100%" height="100%" wmode="direct" name="fluid_site" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
        </object>
    </noscript>
    </body>
    </html>
    Thanks

  • How to load multiple .wrl (VRML) files?

    Hi all,
    I need to load four components of a coffee table into the virtual universe, the four components are top, base, left leg and right leg. I use four parts not one whole single object because in this way when I change the size of this furniture, I can make the thickness of the edges fixed, which is a must. The four parts consist a table correctly in the design software TopSolid, but when I load the four .wrl ojbect files seperately in the application, they cannot compose a table correctly. I guess the reason is the four components have been resized and translated automatically in the VRML loader. I have reviewed the source code of the VRML loader and some related source code but not be able to find where the auto resize code is.
    I have used four Wavefront .obj files instead to do another technical demonstration, if I disable the ObjectFile.RESIZE flag, and just scale the four parts by myself using the same scale factor, I can get a perfect coffee table, with every part in correct location. But my supervisor insist on using VRML .wrl files in our project.
    I hope someone can give me some kind instructions or advises on how to do it in VRML97 loader (https://j3d-vrml97.dev.java.net/).
    Any help will be highly appreciated.

    Answered here : http://www.java.net/forum/topic/javadesktop/java-desktop-technologies/java-3d/trying-load-multiple-wrl-vrml-files-same

  • How to Load a SWF in Dynamically Loaded HTML

    Hello,
    I have a Flash movie with a multi-line text field that loads
    HTML text. As per the below Macromedia documentation I have swfs as
    images inside my HTML text.
    I'm trying to find a way to pre-load these swfs - if I do
    loadmovie to load the swf, when the html file is loaded will it
    need to reload the swf from scratch or will it take my loaded
    version? I'd love to show a "loading" message in the text as the
    swf was loading but am unsure how to do this now that I have the
    swf reference embedded in the html text.
    Any ideas?
    Thanks!
    Julia
    From the Macromedia documentation:
    Image tag (<img>
    The <img> tag lets you embed external JPEG files, SWF
    files, and movie clips inside text fields. The <img> tag has
    one required attribute, src, which specifies the path to a JPEG
    file, a SWF file, or the linkage identifier of a movie clip symbol.

    Thanks - your answer is exactly what I was looking for.
    I'm noticing that every swf I load via dynamic HTML is
    distorted - is there a way to prevent this? I can set the width and
    height of each swf in the HTML, which works ok, but then I run into
    a problem when I try and have a component item (like an accordion)
    included in the dynamic text field. It works properly, and the
    framing is sized correctly, but the guts are still skewed. I
    haven't been able to figure out why the swfs are being distorted in
    the first place.
    Any ideas?
    Thanks,
    Julia

  • How to load multiple HTML5 canvas on the same page (the proper method)

    Hi,
    I've been struggling to load multiple canvas animations on the same page. At the beggining I thought that exporting the movies with different namespaces and reloading the libraries in a sequential flow might work, but it doesn't. It always loads just the last animation loaded. More info here: Coding challenge: what am I doing wrong?
    Here is a sample of what I'm doing:
    1st: Publish two flash movies with custom namespaces for "lib" set in the "publish settings": "libFirst" and "libSecond".
    2nd: Edit the canvas tags in the HTML page. One called "firstCanvas" and the other one called "secondCanvas"
    3rd: Edit the javascript like this:
            <script>
                // change the default namespace for the CreateJS libraries:
                var createjsFirst = createjsFirst||{};
                var createjs = createjsFirst;
            </script>
            <script src="//code.createjs.com/easeljs-0.7.1.min.js"></script>
            <script src="//code.createjs.com/tweenjs-0.5.1.min.js"></script>
            <script src="//code.createjs.com/movieclip-0.7.1.min.js"></script>
            <script src="{{assets}}/js/first.js"></script>
            <script>
                function initFirstAnimation() {
                    var canvas, stage, exportRoot;
                    canvas = document.getElementById("firstCanvas");
                    exportRoot = new libFirst.first();
                    stage = new createjsFirst.Stage(canvas);
                    stage.addChild(exportRoot);
                    stage.update();
                    createjsFirst.Ticker.setFPS(libFirst.properties.fps);
                    createjsFirst.Ticker.addEventListener("tick", stage);
            </script>
            <script>
                // change the default namespace for the CreateJS libraries:
                var createjsSecond = createjsSecond||{};
                var createjs = createjsSecond;
            </script>
            <script src="//code.createjs.com/easeljs-0.7.1.min.js"></script>
            <script src="//code.createjs.com/tweenjs-0.5.1.min.js"></script>
            <script src="//code.createjs.com/movieclip-0.7.1.min.js"></script>
            <script src="{{assets}}/js/second.js"></script>
            <script>
                function initSecondAnimation() {
                    var canvas, stage, exportRoot;
                    canvas = document.getElementById("secondCanvas");
                    exportRoot = new libSecond.second();
                    stage = new createjsSecond.Stage(canvas);
                    stage.addChild(exportRoot);
                    stage.update();
                    createjsSecond.Ticker.setFPS(libSecond.properties.fps);
                    createjsSecond.Ticker.addEventListener("tick", stage);
            </script>
    <body onload="initFirstAnimation(); initSecondAnimation();">
    Could someone please reply with the best practice on how to do this? If possible, without the need to reload all the libraries...
    If I only need to show one flash movie at a time, would it be more efficient to cut & paste the canvas tag using jQuery in the DOM and reloading a different lib on it?
    Many thanks!
    #flash #reborn

    I was able to fix it. At the end, it was easier than I thought. Just have to publish using a different "lib" namespace for each movie, load all the scripts at the end of the <body> and then add the following to the onload or ready events:
    $(document).ready(function () {
            var canvas, stage, exportRoot;
            // First movie
            canvas = document.getElementById("firstCanvas");
            exportRoot = new libFirst.first();
            stage = new createjs.Stage(canvas);
            stage.addChild(exportRoot);
            stage.update();
            createjs.Ticker.setFPS(libFirst.properties.fps);
            createjs.Ticker.addEventListener("tick", stage);
            // Second movie
            canvas = document.getElementById("secondCanvas");
            exportRoot = new libSecond.second();
            stage = new createjs.Stage(canvas);
            stage.addChild(exportRoot);
            stage.update();
            createjs.Ticker.setFPS(libSecond.properties.fps);
            createjs.Ticker.addEventListener("tick", stage);
            // Third movie
            canvas = dument.getElementById("thirdCanvas");
            exportRoot = new libThird.third();
            stage = new createjs.Stage(canvas);
            stage.addChild(exportRoot);
            stage.update();
            createjs.Ticker.setFPS(libThird.properties.fps);
            createjs.Ticker.addEventListener("tick", stage);

Maybe you are looking for

  • Early 2008 MBP powers on for ~5 secs then locks

    I'm hoping someone can give advice as to what may be the matter with my MBP (other than it being toast). It's an early 2008 model. 2.5 Ghz Penryn + 512 MB GPU. Here's the story. A small amount of tomato juice was spilt over the computer. It mainly go

  • Songs are light grey-Wont transfer to devices

    I have numerous songs in my library that have their titles as light gray instead of dark black. These songs will play in itunes on my Mac but will not transfer to any devices. Anybody know a solution? Thanks.

  • Returning the material from shop/production to vendor

    Dera friends, Material rejection from shop/production to vendor directly ,is there any movement type. or through--MIGO-Return delivery --262  ; and then 122 to vendor. Please suggest, Canand

  • Multiple MiniSAP systems on one machine, with remote access

    Hi, I'd like to ask if it is possible to install multiple versions of MiniSAP (6.10, 6.20, 2004, 2004s) on the same machine? An important requirement would be to be able to access all these systems remotely. Maybe the best option would be to install

  • FI/FM - Earmarked funds - Consumption History (and cash journal)

    Hello, I create accounting document (payment) in FBCJ and in FB01 transactions - Accounting document contains tax positions (Tax code + Calculate tax) - Accounting document contains a refer to Earmarked funds When I create accounting document in FBCJ