A bare-bones example of a navigation button you are after:
// NavigationButton class
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
public class NavigationButton extends Sprite {
public var href:String;
public var label:String;
public function NavigationButton(h:String, l:String):void {
href = h;
label = l;
init();
}
private function init():void {
mouseChildren = false;
var tf:TextField = new TextField();
with(tf){
autoSize = TextFieldAutoSize.LEFT;
text = label;
}
addChild(tf);
}
}
}
//
...then you create a NavigationButton instance from your document class:
//
private function init():void {
var navBtn:NavigationButton = new NavigationButton("index.html", "Home");
navBtn.addEventListener(MouseEvent.CLICK, navBtnClick);
addChild(navBtn);
}
private function navBtnClick(e:MouseEvent):void {
navigateToURL(new URLRequest(e.target.href));
}
//
--
Kenneth Kawamoto
http://www.materiaprima.co.uk/
On 11 March 2010 11:46, Susan Day <[email protected]> wrote:
> On Wed, Mar 10, 2010 at 7:07 PM, Kenneth Kawamoto
> <[email protected]> wrote:
>>
>> If I understand you correctly you want to trace "index.html"?
>>
>> One funky way is...
>>
>> trace(new XML("<a href='index.html'>Home</a>")....@href);
>> // traces "index.html"
>>
>> ...therefore if your e.currentTarget.getChildAt(0).htmlText is giving you
>> "<a href='index.html'>Home</a>" you can do:
>>
>> trace(new XML(e.currentTarget.getChildAt(0).htmlText)....@href);
>
> I don't know where the heck that took me, something about "go to this
> address here" or some such in the address bar of the browser lol. Yeah,
> pretty out there and crazy. Definitely not elegant, but you knew that, too.
> Karl DeSaulniers asks if I can give the Sprite/MC a name and call that. I've
> tried that and I don't get the results I want; namely, an URL.
> Paul Andrews asks me to state more clearly that for which I am looking.
> Probably a good idea to re-clarify things.
> 1) I have a TextField (TF) to which I assign attributes.
> 2) TF is the child of an MC
> 3) The MC has listeners which call functions
> 4) One of the functions (onClick) requires that a new Web page be opened;
> therefore, either:
> a) I attach and call the URL to/from the TF, or;
> b) I do so from the MC.
> TIA,
> Susan
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders