views:

3041

answers:

3

I have a flash as3 file, and I'm importing an HTML file that contains this link:

<a href="purchase.php?lang=0&"><img src="https://www.paypal.com/en_GB/i/btn/btn_buynowCC_LG.gif" id="paypal_button"></a>

and I cannot for the life of me figure it out, I've looked everywhere.

There were a couple of forums that suggested:

function onTicketLoad():void {
if(paypal != null && this.contains(paypal)) {
 removeChild(paypal);
}
var imgLoader:DisplayObject = content_text.getImageReference("paypal_button");
//imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,onHtmlImageLoaded);
paypal.addChild(imgLoader.content);

}

function onHtmlImageLoaded(e:Event):void { e.target.removeEventListener(Event.COMPLETE, onHtmlImageLoaded);

paypal.addChild(e.target.content);
paypal.buttonMode = true;
paypal.useHandCursor = true;
addChild(paypal);

}

(that example is fragmented as all hell, I just included it to illustrate what I'm trying to do)

Basically I think I need to load the image into the getImageReference method... but I'm so lost... any help would be appreciated!

A: 

I donnu what is the question, but i tried this:

test.htmlText = 'Your Html';

And the button loaded, so what is the problem?

the image button loads, but its not clickable, only the boarder is :(
Ryan Rohrer
A: 

If you are going to use the < img > tag in an htmlText box, "you must set the text field to be multiline and to wrap text"

I tried it, and it works fine for me. It loaded the image and the link worked too. Here is my code:

import flash.text.TextField;

var labelText:String = '<a href="purchase.php?lang=0&"><img src="https://www.paypal.com/en_GB/i/btn/btn_buynowCC_LG.gif" id="paypal_button"></a>';
var label:TextField = new TextField();
label.border = true;
label.multiline = true;
label.wordWrap = true;
label.width = 200;
label.height = 100;
addChild(label);
label.htmlText = labelText;

My example uses pure AS3, but it should be exactly the same as selecting "multiline" and "wordwrap" from your textfields properties panel.

TandemAdam
Its the only image in a really large text-block, I already have wordwrap and multiline set to true, thats just higher up in the code than I pasted in place
Ryan Rohrer
My suggestion would be to make a brand-new "test" FLA and try doing only the minimum to try to get it to work. When it works, keep adding stuff to bring it closer to you finish product. Test it every time you change something until it breaks. Post back if you find something.
TandemAdam
+1  A: 

I've found creating links on <img> tags in TextFields in Flash can be problematic.

I spotted the issue has been reported on the adobe bug tracker here:

http://bugs.adobe.com/jira/browse/FP-2146

Once as a workaround I created a separate swf file the exact same size as the image and embedded that instead (i.e. a 160x47 stage and a MovieClip/button with a clickable link using navigateToURL). Basically you can embed swf files within TextFields the same way as images.

It's not ideal but it did seem like a decent compromise considering the swf 'button' can now be used and laid out in more or less the same way as you would have used the <img> tag.

Shrill