Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 457597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:35:14+00:00 2026-05-12T22:35:14+00:00

I’m loading an swf file into my main application using URLLoader, I want to

  • 0

I’m loading an swf file into my main application using URLLoader, I want to get the background color of the loaded swf file. ( I heard that one solution wold be reading the byte code of the loaded swf )

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T22:35:14+00:00Added an answer on May 12, 2026 at 10:35 pm

    Yes, You need to look into binary swf data. Here is brief description of swf format. And this is a little detail about different kind of tags. Your requirement is to find out SetBackgroundColor tag(tag type = 9), which commonly is either first or second tag of the swf.
    Bytes in swf file follows little endian order, so you need to be careful while reading the data. And mostly they will be compressed(first three bytes will be “CWS”) so from 9th bytes onwards (including 9th), all data needs to be decompressed (ByteArray.decompress) before processing.
    SomeExample code 🙂

    package {
      import flash.display.*;
      import flash.events.*;
      import flash.net.*;
      import flash.utils.*;
      public class Test1 extends Sprite{
        private var stream:URLStream;
        public function Test1():void {
          stream = new URLStream();
          stream.load(new URLRequest("some.swf"));
          stream.addEventListener(Event.COMPLETE, onComplete);
        }
        private function onComplete(e:Event):void {
          var bytes:ByteArray = new ByteArray();
          bytes.endian = Endian.LITTLE_ENDIAN;
          stream.readBytes(bytes, 0, 8);
          var sig:String = bytes.readUTFBytes(3);
          trace("SIG = " + sig);
          trace("ver = " + bytes.readByte());
          trace("size = " + bytes.readUnsignedInt());
          var compBytes:ByteArray = new ByteArray();
          compBytes.endian = Endian.LITTLE_ENDIAN;
          stream.readBytes(compBytes);
          if (sig == "CWS") {
            compBytes.uncompress();
          }
          var fbyte = compBytes.readUnsignedByte();
          var rect_bitlength = fbyte >> 3;
          var total_bits = rect_bitlength * 4;
          var next_bytes =  Math.ceil((total_bits - 3)/ 8);
          for(var i=0; i<next_bytes; i++) {
            compBytes.readUnsignedByte();
          }
          trace("frameRate = " + compBytes.readUnsignedShort());
          trace("frameCount = " + compBytes.readUnsignedShort());

      while(true) {
        var tagcodelen:Number = compBytes.readUnsignedShort();
        var tagcode:Number = tagcodelen >> 6;
        var taglen:Number = tagcodelen & 0x3F;
        trace("tag code = " + tagcode + "\tlen = " + taglen);
        if (taglen >=63) {
          taglen = compBytes.readUnsignedInt();
        }
        if(tagcode == 9) {
          trace("found background color");
          trace("color is: RED=" + compBytes.readUnsignedByte() +", GREEN = " + compBytes.readUnsignedByte() + ", BLUE = " + compBytes.readUnsignedByte());
          break;
        }
        compBytes.readBytes(new ByteArray(), 0, taglen);
        //break;
      }
    }
    

    }
    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.