Singulair 10mg Pills $270.00

ActionScript 2.0

Singulair 10mg pills $270.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, singulair 10mg pills $270.00 <a> (anchor) tags are among the supported few, singulair 10mg pills $270.00 which means you can even put working hyperlinks inside your text.  Not only that, singulair 10mg pills $270.00 but Flash includes a special protocol, singulair 10mg pills $270.00 asfunction, singulair 10mg pills $270.00 that allows you to trigger functions from those hyperlinks, singulair 10mg pills $270.00 in case you prefer to do that instead of visiting URLs.  ActionScript 3.0 uses a different approach, singulair 10mg pills $270.00 but if you’re coding in AS1 or 2, singulair 10mg pills $270.00 just replace http://someURL.com with asfunction:someFunction, singulair 10mg pills $270.00someParam, singulair 10mg pills $270.00 as described elsewhere on this blog.  If you’re coding in timeline keyframes, singulair 10mg pills $270.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

Singulair 10mg pills $270.00 When a text field responds to an asfunction trigger, singulair 10mg pills $270.00 it looks for the specified function inside the movie clip that contains the text field in question (that is, singulair 10mg pills $270.00 the container object of that text field, singulair 10mg pills $270.00 or its parent).  Again, singulair 10mg pills $270.00 if you’re coding on the timeline, singulair 10mg pills $270.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, singulair 10mg pills $270.00param'>click me</a>";

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

Singulair 10mg pills $270.00 In some custom class situations, singulair 10mg pills $270.00 the above concept still works without a hitch.  If your class extends MovieClip, singulair 10mg pills $270.00 for example, singulair 10mg pills $270.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", singulair 10mg pills $270.00 0, singulair 10mg pills $270.00 0, singulair 10mg pills $270.00 0, singulair 10mg pills $270.00 100, singulair 10mg pills $270.00 22);
    tf.html = true;
    tf.htmlText = "<a href='asfunction:linkHandler, singulair 10mg pills $270.00clicked'>click me</a>";
  }
  private function linkHandler(param:String):Void {
    trace(param);
  }
}

Singulair 10mg pills $270.00 In the preceding code, singulair 10mg pills $270.00 an arbitrarily named property, singulair 10mg pills $270.00 tf, singulair 10mg pills $270.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., singulair 10mg pills $270.00 it is a movie clip).  In the following line, singulair 10mg pills $270.00 tf’s TextField.html property is set to true, singulair 10mg pills $270.00 which allows it to accept HTML input, singulair 10mg pills $270.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, singulair 10mg pills $270.00 this time passing in the parameter “clicked” (a string).  The private linkHandler() method (which could be public too, singulair 10mg pills $270.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.

Singulair 10mg pills $270.00 Note:  To test the above class, singulair 10mg pills $270.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, singulair 10mg pills $270.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?

Singulair 10mg pills $270.00 The problem is, singulair 10mg pills $270.00 your class might not extend MovieClip (or extend anything!) at all.  Which would be fine.  There’s no reason to extend MovieClip, singulair 10mg pills $270.00 or any class, singulair 10mg pills $270.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", singulair 10mg pills $270.00 0, singulair 10mg pills $270.00 0, singulair 10mg pills $270.00 0, singulair 10mg pills $270.00 100, singulair 10mg pills $270.00 22);
    tf.html = true;
    tf.htmlText = "<a href='asfunction:linkHandler, singulair 10mg pills $270.00clicked'>click me</a>";
  }
  private function linkHandler(param:String):Void {
    trace(param);
  }
}

Singulair 10mg pills $270.00 What’s the difference?  This time, singulair 10mg pills $270.00 the class doesn’t extend anything.  It’s instantiated in the main timeline …

new CustomClass(this);

Singulair 10mg pills $270.00 … and fed a MovieClip instance — here, singulair 10mg pills $270.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, singulair 10mg pills $270.00 but when this class is instantiated, singulair 10mg pills $270.00 the text field becomes an immediate child of the main timeline.  The problem is, singulair 10mg pills $270.00 the class itself — which contains the linkHandler() method — is also a child of the main timeline, singulair 10mg pills $270.00 which means asfunction is looking in the wrong place for linkHandler().  As always, singulair 10mg pills $270.00 asfunction is looking in the movie clip that contains the text field.  Here, singulair 10mg pills $270.00 the movie clip is the main timeline, singulair 10mg pills $270.00 but the desired function is inside an object (this CustomClass instance) inside the main timeline.  So close, singulair 10mg pills $270.00 but yet so far, singulair 10mg pills $270.00 eh?

So what’s a solution?

Singulair 10mg pills $270.00 The easiest way to fix the disconnect is to re-route the function, singulair 10mg pills $270.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", singulair 10mg pills $270.00 0, singulair 10mg pills $270.00 0, singulair 10mg pills $270.00 0, singulair 10mg pills $270.00 100, singulair 10mg pills $270.00 22);
  tf.html = true;
  tf.htmlText = "<a href='asfunction:linkHandler, singulair 10mg pills $270.00clicked'>click me</a>";
  tf._parent.linkHandler = this.linkHandler;
}

Singulair 10mg pills $270.00 The workaround here takes advantage of the fact that the MovieClip class is dynamic, singulair 10mg pills $270.00 which means it can have properties and methods added to it at runtime.  In this case, singulair 10mg pills $270.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, singulair 10mg pills $270.00 you could also use the following in this scenario, singulair 10mg pills $270.00 which means the exact same thing:

target.linkHandler = this.linkHandler;

Singulair 10mg pills $270.00 It’s interesting to note that linkHandler(), singulair 10mg pills $270.00 as defined in the class, singulair 10mg pills $270.00 is private, singulair 10mg pills $270.00 yet the twin function, singulair 10mg pills $270.00 dynamically set to a different MovieClip instance, singulair 10mg pills $270.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, singulair 10mg pills $270.00 but hey, singulair 10mg pills $270.00 you’re a developer.  That makes you like a stage hand.  You keep the magician’s secrets.

Is there a better solution?

Singulair 10mg pills $270.00 There is a better solution — though “better” is subjective, singulair 10mg pills $270.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, singulair 10mg pills $270.00 if you replace trace(param); with trace(this);, singulair 10mg pills $270.00 you’ll see _level0 in the Output panel.  Why?  Because the dynamically added function exists in the main timeline, singulair 10mg pills $270.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, singulair 10mg pills $270.00 however, singulair 10mg pills $270.00 is that this refers to an object that isn’t the CustomClass instance.)

Singulair 10mg pills $270.00 To re-route not only the function, singulair 10mg pills $270.00 but its scope, singulair 10mg pills $270.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", singulair 10mg pills $270.00 0, singulair 10mg pills $270.00 0, singulair 10mg pills $270.00 0, singulair 10mg pills $270.00 100, singulair 10mg pills $270.00 22);
    tf.html = true;
    tf.htmlText = "<a href='asfunction:linkHandler, singulair 10mg pills $270.00clicked'>click me</a>";
    tf._parent.linkHandler = Delegate.create(this, singulair 10mg pills $270.00 linkHandler);
  }
  private function linkHandler(param:String):Void {
    trace(param);
  }
}

Average Rating: 4.9 out of 5 based on 299 user reviews.

Leave a Reply