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 6627327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:00:00+00:00 2026-05-25T22:00:00+00:00

I embed a text file into my Flex project and read its contents using

  • 0

I embed a text file into my Flex project and read its contents using code like this:

[Embed(source = "../../data/abc.txt", mimeType = "application/octet-stream")]
private var r_Abc:Class;

…

var xx:ByteArray = new r_Abc();
var abc:String = xx.toString();

The contents of the file is abc. The problem is that the string loaded from the file is not comparable to other strings even though when printed or viewed in the debugger (in FlashDevelop) it seems to be perfectly fine.

trace(abc);  // abc
trace("abc" == abc);   // false

How do I convert it into a proper string? I tried to use the string methods such as substring to create a copy, but that does not seem to be the solution.

  • 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-25T22:00:00+00:00Added an answer on May 25, 2026 at 10:00 pm

    Here’s my sample:

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application minWidth="955" minHeight="600"
                   creationComplete="creationCompleteHandler(event)"
                   xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/mx">
    
        <fx:Script>
            <![CDATA[
                import mx.core.ByteArrayAsset;
                import mx.events.FlexEvent;
    
                // my file is "ABC "
                // strangely enough if I remove the space at the end the string in code is empty
                [Embed(source="data/abc.txt", mimeType="application/octet-stream")]
                private var abcFile:Class;
    
                protected function creationCompleteHandler(event:FlexEvent):void
                {
                    var abcByteArray:ByteArrayAsset = ByteArrayAsset(new abcFile());
                    var abc:String = abcByteArray.readUTFBytes(abcByteArray.length);
    
                    trace(abc); // ABC (has a space at the end)
                    trace(abc == "ABC "); // true, but notice the space at the end
                }
            ]]>
        </fx:Script>
    </s:Application>
    

    My suggestion is to check for trailing spaces, new lines. Also try to place some sort of an EOF character at the end of the file.

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

Sidebar

Related Questions

I would like to embed a text file in an assembly so that I
I'd like to embed some files (text files, maybe graphics) in a C++/CLI project
I have a text file that I'd like to embed within a resource in
We would like to embed some code in each ASP.NET page that queries its
I embed text in textfield, but sometimes it does not render using htmltext. if
Like the youtube embed text fields. How do you make a text field selectable
I'm trying to embed a IPTC data onto a JPEG image using iptcembed() but
Why are flat text files the state of the art for representing source code?
I have a SWF file and I am trying to embed it into an
I'm attempting to place some embed code into a Premium WordPress Theme. NOTE: I'm

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.