Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0

Reply
 
Thread Tools Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
Old 11-23-2006, 08:12 AM   #1
Morg
1st party software!
 
Morg's Avatar
 
Join Date: Nov 2003
Location: South Africa
Posts: 916
Question BitmapData, Textfield and CSS

Hola people!

Here is my dillema. I need to present articles in Flash. It needs to show pullquotes as "div" inserts... So, the text would wrap around the block of text so that it looks like the magazines do.

See sample here

Those pullquotes are images. I don't want them to be (More work in terms of PHP to create those thumbnails)...
I was thinking - Is it possible to use the BitmapData class and add text to it dynamically, and then put that into the textfield? something like... <img src="myBitmap">?

Can anone shed some light on this for me? Am I wasting my time? ANy direction would be greatly appreciated.

Thanks in advance.
Morg is offline   Reply With Quote
Old 11-23-2006, 12:45 PM   #2
pixelwit
village halfwit
 
pixelwit's Avatar
 
Join Date: Jul 2001
Location: USA, PA
Posts: 3,330
Default

The Help files say you can use any clip in the library with a linkage identifier as a source image in an HTML textfield so you don't really need the BitmapData class.

If you're not loading dynamic text, you can just create your pull-quote as a clip in the library and attach it to your HTML textfield.

If you are using dynamic text you can attach a blank clip from the library to the inside of your HTML textfield then create a textfield inside that and fill it with your dynamically generated pull-quote text using script. The real trick is identifying the name of the blank clip after it's been inserted into the textfield. After a little testing, it appears as if the first "image" clip is named "instance1" and can be accessed with "MyTextField.Instance1".

Hope that gets you headed in the right direction.

-PiXELWiT
http://www.pixelwit.com
__________________
There are no answers, only choices.
pixelwit is offline   Reply With Quote
Old 11-23-2006, 12:54 PM   #3
Morg
1st party software!
 
Morg's Avatar
 
Join Date: Nov 2003
Location: South Africa
Posts: 916
Default

Hey!

Thanks for replying!

Yeah, I did this litlle test to create me some BitmapData:
Code:
import flash.display.BitmapData;
depth = 10;
// Create the movieCLip >>
var myBitmapData:BitmapData = new BitmapData(100, 100, false, 0x00CCCCCC);

this.createEmptyMovieClip("pullQuote",depth++);
pullQuote.createTextField("title",10,0,0,100,100);
pullQuote.title.text = "\"Hello world!\"";

myBitmapData.draw(pullQuote);

this.createEmptyMovieClip("pullQuoteFinal",depth++);
pullQuoteFinal.attachBitmap(myBitmapData, 2, "auto", true);

pullQuote.removeMovieClip();
I am receiving the pullquote dunamically, so I will have to try and go that route... How exactly do you attach a blank movieCLip to your textfield? createEmptyMovie?
Morg is offline   Reply With Quote
Old 11-23-2006, 01:19 PM   #4
pixelwit
village halfwit
 
pixelwit's Avatar
 
Join Date: Jul 2001
Location: USA, PA
Posts: 3,330
Default

Just specify the clip's LinkageID as the "src" property for the "img" tag.

-PiXELWiT
http://www.pixelwit.com
__________________
There are no answers, only choices.
pixelwit is offline   Reply With Quote
Old 11-23-2006, 01:22 PM   #5
Morg
1st party software!
 
Morg's Avatar
 
Join Date: Nov 2003
Location: South Africa
Posts: 916
Default

I have tried the following:
Code:
this.createTextField("myTxt",10,0,0,1000,100);
myTxt.html = true;
trace(myTxt)
myTxt.htmlText = "<img src='blank'> --"
But to no avail... I just get an undefined in the output window.. I also tried attachMovie... that does not work.

Pixelwit - what did you search under? I have trawled the help file...

Last edited by Morg; 11-23-2006 at 01:25 PM.
Morg is offline   Reply With Quote
Old 11-23-2006, 01:37 PM   #6
pixelwit
village halfwit
 
pixelwit's Avatar
 
Join Date: Jul 2001
Location: USA, PA
Posts: 3,330
Default

Open the help panel in Flash.
Search "All Books" for "CSS image".
Select "About Supported HTML tags".
Check out the listing for "Image Tag".

As long as you have a clip in the library with a linkageID of "blank" the following code should work:
ActionScript Code:
// // this.createTextField("myTxt",10,0,0,1000,100); myTxt.wordWrap = true; myTxt.multiline = true; myTxt.html = true; myTxt.htmlText = "<img src='blank'> --" trace(myTxt.instance1._width); // //
-PiXELWiT
http://www.pixelwit.com
__________________
There are no answers, only choices.
pixelwit is offline   Reply With Quote
Old 11-23-2006, 01:53 PM   #7
Morg
1st party software!
 
Morg's Avatar
 
Join Date: Nov 2003
Location: South Africa
Posts: 916
Default

YES! it works!! Wonderful!!

But now... little problem. I have put a textfield INSIDE that clip that I am attaching... I cannot write anything into it though...
Code:
this.createTextField("textField_txt", 10, 0, 0, 300, 200);
textField_txt.html = true;
textField_txt.multiline = true;
textField_txt.wordWrap = true;
textField_txt.htmlText = "<img src='img_id' id='pullquote' align='left'><p>Here's a movie clip symbol";
textField_txt.pullquote.titleTxt.text = "hallo there"
trace(textField_txt.pullquote.titleTxt.text)
The trace gives me the value, but I cannot see it... If I can get this to work, my problem is solved..
Morg is offline   Reply With Quote
Old 11-23-2006, 02:07 PM   #8
Morg
1st party software!
 
Morg's Avatar
 
Join Date: Nov 2003
Location: South Africa
Posts: 916
Default

E U R E K A!!

Ok, so you can access the properties, but you cant actually do anything inside the clip in terms of text...

SO!

Code:
// Create bitmap data that contains text >>

import flash.display.BitmapData;
depth = 10;
// Create the movieCLip >>
var myBitmapData:BitmapData = new BitmapData(100, 100, true, 0x00CCCCCC);

this.createEmptyMovieClip("pullQuote",depth++);
pullQuote.createTextField("title",10,0,0,100,100);
pullQuote.title.text = "\"Hello world!\"";

myBitmapData.draw(pullQuote);

this.createEmptyMovieClip("pullQuoteFinal",depth++);
pullQuoteFinal.attachBitmap(myBitmapData, 2, "auto", true);
//myTxt.attachBitmap(myBitmapData, 2, "auto", true);
pullQuote.removeMovieClip();

this.createTextField("textField_txt", 10, 0, 0, 300, 200);
textField_txt.html = true;
textField_txt.multiline = true;
textField_txt.wordWrap = true;
textField_txt.htmlText = "<img src='img_id' id='pullquote' align='left'><p>Here's a movie clip symbol";
// Create dynamically >>

textField_txt.pullquote.attachBitmap(myBitmapData, 2, "auto", true);
pullQuoteFinal.removeMovieClip();
And that is that Thanks for all your guidance Pixelwit! Much obliged.
Morg is offline   Reply With Quote
Old 11-23-2006, 02:08 PM   #9
pixelwit
village halfwit
 
pixelwit's Avatar
 
Join Date: Jul 2001
Location: USA, PA
Posts: 3,330
Default

The following code works for me:
ActionScript Code:
this.createTextField("myTxt",10,0,0,1000,100); myTxt.wordWrap = true; myTxt.multiline = true; myTxt.html = true; myTxt.htmlText = "<img src='blank'> --" myTxt.instance1.createTextField("Fred", 10, 0, 0, 100, 50); myTxt.instance1.Fred.text = "Cows!";

The main problem I see right now is that the blank clip needs a width and height when it's first placed in the textfield so the text can flow around the image. You can get around this by placing a clear rectangle the size of your pull-quote in the blank clip. But then you'll need different sized "blank" clips for different sized quotes.

-PiXELWiT
http://www.pixelwit.com
__________________
There are no answers, only choices.
pixelwit is offline   Reply With Quote
Old 11-23-2006, 02:34 PM   #10
Morg
1st party software!
 
Morg's Avatar
 
Join Date: Nov 2003
Location: South Africa
Posts: 916
Default



thats not fair... I tried doing that, and mine just would not respond. I got a big fat zero... FTW???

Now mine is a mega workaround

(Nice one though!!!! )
Morg is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:15 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.