Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Code dosen't work when Textbox is created at runtime

Posted on 2008-06-18
3
Medium Priority
?
384 Views
Last Modified: 2013-11-12
I'm going to be putting loaded images within the htmlText of a textfield.

getImageReference fails when Textfield is created at runtime (returns null)

how do i get it to work?

var Holder:Blank = new Blank;
 
//this works
//myText created at design time
myTxt.htmlText = "<html><img src='Blank' id='Blank1' />hello</html>";
Holder =Blank( myTxt.getImageReference("Blank1"))
Holder.addChild(new test) //any Symbol from library
 
 
 
//this fails
var txt:TextField =new TextField(); 
addChild(txt);
txt.width=500;
txt.height=300;
txt.border = true;
txt.htmlText = "<html><img src='Blank' id='Blank1' />hello</html>";
txt.multiline = true;
Holder =Blank( txt.getImageReference("Blank1"))
Holder.addChild(new test) //any Symbol from library
 
//Blank.as
 
package {
        import flash.display.Sprite;
 
        public class Blank extends Sprite {
                public function Blank() {
                }
        }
}

Open in new window

html-image.fla.txt
Blank.as.txt
0
Comment
Question by:smash_pants
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 39

Expert Comment

by:blue-genie
ID: 21820466
hi, not sure if this would make a difference, but you're adding the child before you've specified the htmlText property.
0
 
LVL 4

Accepted Solution

by:
emphaticDigital earned 2000 total points
ID: 21822359
Hello,

You just need to set 'wordWrap' to true before you can use the image tag at run-time. In the design-time created textField, wordWrap is set to true automatically be choosing a multiline textField type. At run-time you have to set it explicitly using the following code:

txt.wordWrap = true;

Also, set both 'wordWrap' and 'multiline' BEFORE setting the htmlText property.

I tested it and it works.

Hope this helps.
0
 
LVL 3

Author Closing Comment

by:smash_pants
ID: 31468610
fantastic.

setting both 'wordWrap' and 'multiline' BEFORE setting the htmlText property worked.

Thank you
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question