Vardenafil 20mg Pills $143.00

ActionScript 2.0

Vardenafil 20mg pills $143.00 Flash Player has supported a limited subset of the HTML specification since version 6 — just set a text field’s htmlText property to an HTML-formatted string and you’re good to go.  Fortunately, vardenafil 20mg pills $143.00 <a> (anchor) tags are among the supported few, vardenafil 20mg pills $143.00 which means you can even put working hyperlinks inside your text.  Not only that, vardenafil 20mg pills $143.00 but Flash includes a special protocol, vardenafil 20mg pills $143.00 asfunction, vardenafil 20mg pills $143.00 that allows you to trigger functions from those hyperlinks, vardenafil 20mg pills $143.00 in case you prefer to do that instead of visiting URLs.  ActionScript 3.0 uses a different approach, vardenafil 20mg pills $143.00 but if you’re coding in AS1 or 2, vardenafil 20mg pills $143.00 just replace http://someURL.com with asfunction:someFunction, vardenafil 20mg pills $143.00someParam, vardenafil 20mg pills $143.00 as described elsewhere on this blog.  If you’re coding in timeline keyframes, vardenafil 20mg pills $143.00 it’s all pretty straightforward.  But asfunction can seemingly break when used in custom class files.  Here’s what’s going on and how to fix it. 

A bit of backstory

Vardenafil 20mg pills $143.00 When a text field responds to an asfunction trigger, vardenafil 20mg pills $143.00 it looks for the specified function inside the movie clip that contains the text field in question (that is, vardenafil 20mg pills $143.00 the container object of that text field, vardenafil 20mg pills $143.00 or its parent).  Again, vardenafil 20mg pills $143.00 if you’re coding on the timeline, vardenafil 20mg pills $143.00 everything tends to fall into place.  Imagine the following ActionScript 2.0 in a keyframe of the main timeline:

function linkHandler(param:String):Void {
  // do something neat with the hyperlink
}

myTextField.htmlText = "<a href='asfunction:linkHandler, vardenafil 20mg pills $143.00param'>click me</a>";

Vardenafil 20mg pills $143.00 When a user clicks the words “click me” in this text field, vardenafil 20mg pills $143.00 asfunction looks for a function named linkHandler() in the movie clip (aka the timeline) that contains this text field.  And of course, vardenafil 20mg pills $143.00 there it is, vardenafil 20mg pills $143.00 in the very same keyframe.

Vardenafil 20mg pills $143.00 In some custom class situations, vardenafil 20mg pills $143.00 the above concept still works without a hitch.  If your class extends MovieClip, vardenafil 20mg pills $143.00 for example, vardenafil 20mg pills $143.00 then the class itself becomes the “timeline” that contains both the text field and asfunction’s function.

class CustomClass extends MovieClip {
  private var tf:TextField;
  public function CustomClass() {
    tf = this.createTextField("tf", vardenafil 20mg pills $143.00 0, vardenafil 20mg pills $143.00 0, vardenafil 20mg pills $143.00 0, vardenafil 20mg pills $143.00 100, vardenafil 20mg pills $143.00 22);
    tf.html = true;
    tf.htmlText = "<a href='asfunction:linkHandler, vardenafil 20mg pills $143.00clicked'>click me</a>";
  }
  private function linkHandler(param:String):Void {
    trace(param);
  }
}

Vardenafil 20mg pills $143.00 In the preceding code, vardenafil 20mg pills $143.00 an arbitrarily named property, vardenafil 20mg pills $143.00 tf, vardenafil 20mg pills $143.00 is declared and — inside the constructor function — set to an instance of the TextField class by way of the MovieClip.createTextField() method.  This method succeeds here when invoked on the global this property because the class extends MovieClip (i.e., vardenafil 20mg pills $143.00 it is a movie clip).  In the following line, vardenafil 20mg pills $143.00 tf’s TextField.html property is set to true, vardenafil 20mg pills $143.00 which allows it to accept HTML input, vardenafil 20mg pills $143.00 then its htmlText property is set to the same HTML-formatted string as before.  Note that asfunction still points to a custom linkHandler() function, vardenafil 20mg pills $143.00 this time passing in the parameter “clicked” (a string).  The private linkHandler() method (which could be public too, vardenafil 20mg pills $143.00 either way) hears asfunction’s call when the hyperlink is clicked.  All is still well — the Output panel traces the word “clicked” because param’s value is that word.

Vardenafil 20mg pills $143.00 Note:  To test the above class, vardenafil 20mg pills $143.00 you’ll have to save the preceding code as a simple text file named CustomClass.as and put it into the same folder as a new FLA.  Inside that FLA, vardenafil 20mg pills $143.00 draw a quick rectangle and convert it to a movie clip symbol.  Right-click / Command-click the symbol in the Library and choose Linkage from the context menu.  Check “Export for ActionScript” and type the name of the class (CustomClass) into the Class field.

So what’s the problem?

Vardenafil 20mg pills $143.00 The problem is, vardenafil 20mg pills $143.00 your class might not extend MovieClip (or extend anything!) at all.  Which would be fine.  There’s no reason to extend MovieClip, vardenafil 20mg pills $143.00 or any class, vardenafil 20mg pills $143.00 unless the class you’re writing actually is an example of the class you’re extending.  In the following code — almost identical — asfunction is no longer able to find its linkHandler() function:

class CustomClass {
  private var tf:TextField;
  public function CustomClass(target:MovieClip) {
    tf = target.createTextField("tf", vardenafil 20mg pills $143.00 0, vardenafil 20mg pills $143.00 0, vardenafil 20mg pills $143.00 0, vardenafil 20mg pills $143.00 100, vardenafil 20mg pills $143.00 22);
    tf.html = true;
    tf.htmlText = "<a href='asfunction:linkHandler, vardenafil 20mg pills $143.00clicked'>click me</a>";
  }
  private function linkHandler(param:String):Void {
    trace(param);
  }
}

Vardenafil 20mg pills $143.00 What’s the difference?  This time, vardenafil 20mg pills $143.00 the class doesn’t extend anything.  It’s instantiated in the main timeline …

new CustomClass(this);

Vardenafil 20mg pills $143.00 … and fed a MovieClip instance — here, vardenafil 20mg pills $143.00 the global this property — as a parameter.  The only reason for the parameter is so that the target reference inside the constructor function can be used in the very next line as the MovieClip instance required for the createTextField() method.  The difference may be subtle, vardenafil 20mg pills $143.00 but when this class is instantiated, vardenafil 20mg pills $143.00 the text field becomes an immediate child of the main timeline.  The problem is, vardenafil 20mg pills $143.00 the class itself — which contains the linkHandler() method — is also a child of the main timeline, vardenafil 20mg pills $143.00 which means asfunction is looking in the wrong place for linkHandler().  As always, vardenafil 20mg pills $143.00 asfunction is looking in the movie clip that contains the text field.  Here, vardenafil 20mg pills $143.00 the movie clip is the main timeline, vardenafil 20mg pills $143.00 but the desired function is inside an object (this CustomClass instance) inside the main timeline.  So close, vardenafil 20mg pills $143.00 but yet so far, vardenafil 20mg pills $143.00 eh?

So what’s a solution?

Vardenafil 20mg pills $143.00 The easiest way to fix the disconnect is to re-route the function, vardenafil 20mg pills $143.00 which can be done with a single line.  Here’s a quick look at the constructor function only:

public function CustomClass(target:MovieClip) {
  tf = target.createTextField("tf", vardenafil 20mg pills $143.00 0, vardenafil 20mg pills $143.00 0, vardenafil 20mg pills $143.00 0, vardenafil 20mg pills $143.00 100, vardenafil 20mg pills $143.00 22);
  tf.html = true;
  tf.htmlText = "<a href='asfunction:linkHandler, vardenafil 20mg pills $143.00clicked'>click me</a>";
  tf._parent.linkHandler = this.linkHandler;
}

Vardenafil 20mg pills $143.00 The workaround here takes advantage of the fact that the MovieClip class is dynamic, vardenafil 20mg pills $143.00 which means it can have properties and methods added to it at runtime.  In this case, vardenafil 20mg pills $143.00 a reference is made to the movie clip that contains the text field — tf._parent (the TextField._parent property of tf) — and then a new function is declared in that movie clip and set to the function defined inside the class.  Because the constructor function accepts a target parameter, vardenafil 20mg pills $143.00 you could also use the following in this scenario, vardenafil 20mg pills $143.00 which means the exact same thing:

target.linkHandler = this.linkHandler;

Vardenafil 20mg pills $143.00 It’s interesting to note that linkHandler(), vardenafil 20mg pills $143.00 as defined in the class, vardenafil 20mg pills $143.00 is private, vardenafil 20mg pills $143.00 yet the twin function, vardenafil 20mg pills $143.00 dynamically set to a different MovieClip instance, vardenafil 20mg pills $143.00 is able to invoke this private method without any issues.  That’s just the broken way it works in AS2.  It shouldn’t do that, vardenafil 20mg pills $143.00 but hey, vardenafil 20mg pills $143.00 you’re a developer.  That makes you like a stage hand.  You keep the magician’s secrets.

Is there a better solution?

Vardenafil 20mg pills $143.00 There is a better solution — though “better” is subjective, vardenafil 20mg pills $143.00 and you really only need the alternate approach if the scope of your function needs to reside inside the class.  Under the current setup, vardenafil 20mg pills $143.00 if you replace trace(param); with trace(this);, vardenafil 20mg pills $143.00 you’ll see _level0 in the Output panel.  Why?  Because the dynamically added function exists in the main timeline, vardenafil 20mg pills $143.00 so the this reference thinks that’s where it is.  (It only happens like this because the parent of the text field happens to be the main timeline.  The point, vardenafil 20mg pills $143.00 however, vardenafil 20mg pills $143.00 is that this refers to an object that isn’t the CustomClass instance.)

Vardenafil 20mg pills $143.00 To re-route not only the function, vardenafil 20mg pills $143.00 but its scope, vardenafil 20mg pills $143.00 use the Delegate class as follows:

import mx.utils.Delegate;
class CustomClass {
  private var tf:TextField;
  public function CustomClass(target:MovieClip) {
    tf = target.createTextField("tf", vardenafil 20mg pills $143.00 0, vardenafil 20mg pills $143.00 0, vardenafil 20mg pills $143.00 0, vardenafil 20mg pills $143.00 100, vardenafil 20mg pills $143.00 22);
    tf.html = true;
    tf.htmlText = "<a href='asfunction:linkHandler, vardenafil 20mg pills $143.00clicked'>click me</a>";
    tf._parent.linkHandler = Delegate.create(this, vardenafil 20mg pills $143.00 linkHandler);
  }
  private function linkHandler(param:String):Void {
    trace(param);
  }
}

Average Rating: 5 out of 5 based on 297 user reviews.

Leave a Reply