Solved

Code dosen't work when Textbox is created at runtime

Posted on 2008-06-18
3
366 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
3 Comments
 
LVL 39

Expert Comment

by:blue-genie
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
fantastic.

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

Thank you
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now