Would someone be willing to check as3 code for a guestbook

Would someone be willing to check out some as3 code for a guestbook? I'm an old person, and can't seem to get it working.
Thanks!

Ned suggested that I post the code, so everyone could see it. The SWF works, but the code doesn't. Any help appreciated!
package com.mgraph\
  //IMPORTS
  import flash.display.Loader;
  import flash.display.MovieClip;
  import flash.display.Sprite;
  import flash.display.StageAlign;
  import flash.display.StageScaleMode;
  import flash.events::EventDispatcher/dispatchEventFunction();
  import flash.events::EventDispatcher/dispatchEvent();
  import flash.events.MouseEvent;
  import flash.events.TextEvent;
  import flash.events.KeyboardEvent;
  import flash.geom.Rectangle;
  import flash.net::URLLoader/onComplete();
  import flash.net.URLRequest;
  import flash.net.URLRequestMethod;
  import flash.net.URLVariables;
  import flash.text.TextFieldAutoSize;
  import flash.text.TextFormat;
  import com.utils.StringUtils;
  import com.caurina.transitions.Tweener;
  import com.pageflip.Page;
  import com.pageflip.PageEvent;
  public class Guestbook extends MovieClip {
  //PRIVATE VARS
  private var myXML:XML;
  private var frm:TextFormat;
  private var popup_mc:MovieClip;
  private var greySprite:Sprite;
  private var initPosition:Number;
  private var dy:Number;
  private var initContentPos:Number;
  private var moveVal:Number;
  private var rectScroll:Rectangle;
  private var stageWidth:Number;
  private var stageHeight:Number;
  public function Guestbook(){
  addEventListener(Event.ADDED_TO_STAGE,init);
  private function init(e:Event):void {
  stage.showDefaultContextMenu = false;
  stage.align = StageAlign.TOP_LEFT;
  stage.scaleMode = StageScaleMode.NO_SCALE;
  stageWidth = stage.stageWidth;
  stageHeight = stage.stageHeight;
  // LOAD THE XML
  var xmlPath:String;
  var xmlLoader:URLLoader = new URLLoader;
  if (root.loaderInfo.parameters.myconfig) {
  // XML PATH FROM HTML flashvars (myconfig)
  xmlPath = root.loaderInfo.parameters.myconfig;
  else {
  // DEFAUL PATH OF XML
  xmlPath = "config.xml";
  xmlLoader.load(new URLRequest(xmlPath));
  xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);
  private function xmlLoaded(e:Event):void {
  // XML LOADED COMPLETE
  myXML = new XML(e.target.data);
  // ADD EVENT LISENER TO FIELDS AND TO (send_btn)
  form_mc.name_txt.addEventListener(TextEvent.TEXT_INPUT,clearAlert);
  form_mc.email_txt.addEventListener(TextEvent.TEXT_INPUT,clearAlert);
  form_mc.message_txt.addEventListener(TextEvent.TEXT_INPUT,clearAlert);
  form_mc.email_txt.addEventListener(Event.CHANGE,checkMail);
  addMouseEvent(form_mc.send_btn,sendEvent);
  // CREATE TEXT FORMAT (frm)
  frm = new TextFormat  ;
  frm.leading = 4;
  form_mc.message_txt.defaultTextFormat = frm;
  // LOAD BACKGROUND IMAGE
  var backLoader:Loader = new Loader();
  backLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,backLoaded);
  backLoader.load(new URLRequest(myXML.img_back));
  // ADD KEYBOARD EVENT WHEN PRESSING ENTER KEY
  stage.addEventListener(KeyboardEvent.KEY_DOWN,keyboardDown);
  // CREATE THE GREY SPRITE
  greySprite = new Sprite  ;
  greySprite.graphics.beginFill(0x000000,0.2);
  greySprite.graphics.drawRect(0,0,stageWidth,stageHeight);
  greySprite.graphics.endFill();
  greySprite.useHandCursor = false;
  // CREATE THE POPUP and ADD EVENTLISTENER TO (close_btn)
  popup_mc = new popup_obj;
  popup_mc.x = (stageWidth - popup_mc.width)/2;
  popup_mc.y = (stageHeight - popup_mc.height)/2;
  addMouseEvent(popup_mc.close_btn,closeEvent);
  private function keyboardDown(e:KeyboardEvent):void{
  if(e.keyCode == 13){
  // STOP USING BREAK LINE IN message_txt
  stage.focus = null;
  private function backLoaded(e:Event):void{
  // BACKGROUND LOADED COMPLETE
  var back_mc:MovieClip = new MovieClip;
  back_mc.addChild(e.target.content);
  addChildAt(back_mc,0);
  form_mc.wait_mc.visible = false;
  startPageFlip();
  // START LOADING GUEST MESSAGE FROM DATABASE
  load_guestbook();
  private function startPageFlip():void{
  var flipedPage:Page = new Page(this, stageWidth, stageHeight, 0, 0);
  flipedPage.turnPageForward();
  private function load_guestbook():void {
  // GET MESSAGES FROM DATABASE USING PHP
  var guestLoad:URLLoader = new URLLoader  ;
  var guestReq:URLRequest = new URLRequest(myXML.phpURL);
  guestReq.method = URLRequestMethod.POST;
  guestReq.data = new URLVariables  ;
  guestReq.data["getMessage"] = 1;
  guestLoad.addEventListener(Event.COMPLETE,bookLoaded);
  guestLoad.load(guestReq);
  private function bookLoaded(e:Event):void {
  // MESSAGES LOADED SUCCESSFULLY FROM DATABASE
  var bookXML:XML = new XML(e.target.data);
  showMessages(bookXML);
  private function showMessages(_xml:XML):void{
  var guest_mc:MovieClip;
  // CREATE (guest_mc) to SHOW EACH GUEST NAME & MESSSAGE
  for (var u=0; u<_xml.guest.length(); u++) {
  guest_mc = new messageObj  ;
  guest_mc.y = 95 * u;
  //CAPITALIZE THE FIRST CHAR IN NAME
  guest_mc._Name = StringUtils.capitalize(_xml.guest[u].name);
  guest_mc._Msg = _xml.guest[u].msg;
  guest_mc._Date = _xml.guest[u].sdate;
  guest_mc.guestName_txt.htmlText = setHtmlFormat(14,myXML.name_color,guest_mc._Name);
  //IF guestMessage_txt TEXT LENGTH > 110 substr guestMessage_txt AND ADD (...)
  guest_mc.guestMessage_txt.htmlText = setHtmlFormat(12,myXML.message_color,StringUtils.capitalize(StringUtils.truncate(_xml.gue st[u].msg,110,"...")));
  guest_mc.guestMessage_txt.setTextFormat(frm);
  guest_mc.tabChildren = false;
  guest_mc.tabEnabled = false;
  // ADD EVENT LISTISTENER  TO (readMore_btn) FOR EACH (guest_mc)
  addMouseEvent(guest_mc.readMore_btn,readEvent);
  msgContainer.addChild(guest_mc);
  // SHOW/HIDE SCROLL
  if (msgContainer.height < mask_mc.height) {
  scroller.scroll_btn.visible = false;
  else {
  this.mouseChildren = false;
  scroller.scroll_btn.y = 0;
  if(msgContainer.y != 10){
  Tweener.addTween(msgContainer,{y:10,time:1.5,onComplete:initScrollPos});
  else{
  initScrollPos();
  scroller.scroll_btn.visible = true;
  // ADD EVENT  TO SCROLL
  addMouseEvent(scroller.scroll_btn,scroll_Event);
  scroller.scroll_btn.addEventListener(MouseEvent.MOUSE_UP,scroll_Event);
  private function initScrollPos():void{
  this.mouseChildren = true;
  dy = 0;
  initPosition = scroller.scroll_btn.y = scroller.bar_mc.y;
  initContentPos = msgContainer.y;
  moveVal = (msgContainer.height-mask_mc.height)/(scroller.bar_mc.height-scroller.scroll_btn.height);
  rectScroll = new Rectangle(scroller.bar_mc.x + 4,scroller.bar_mc.y,0,scroller.bar_mc.height - scroller.scroll_btn.height);
  private function readEvent(me:MouseEvent):void {
  var _this = me.currentTarget;
  switch (me.type) {
  case "mouseOver" :
  _this.alpha = 0.8;
  break;
  case "mouseOut" :
  _this.alpha = 1;
  break;
  case "mouseDown" :
  // SHOW POPUP WITH MORE INFORMATIONS ABOUT THE CURRENT MESSAGE
  popup_mc.pop_nom.htmlText = setHtmlFormat(15,myXML.name_color,_this.parent._Name) + setHtmlFormat(13,myXML.datePosted_color," - Posted "+_this.parent._Date);
  popup_mc.pop_message.htmlText = setHtmlFormat(13,myXML.message_color,StringUtils.capitalize(_this.parent._Msg));
  popup_mc.pop_message.autoSize = TextFieldAutoSize.LEFT;
  popup_mc.pop_message.setTextFormat(frm);
  popup_mc.back_mc.height = popup_mc.pop_message.height + 50;
  popup_mc.x = (stageWidth - popup_mc.width)/2;
  popup_mc.y = (stageHeight - popup_mc.height)/2;
  addChild(greySprite);
  addChild(popup_mc);
  popup_mc.alpha = 0;
  greySprite.alpha = 0;
  Tweener.addTween(popup_mc,{alpha:1,time:0.6});
  Tweener.addTween(greySprite,{alpha:1,time:0.6});
  break;
  private function setHtmlFormat(_size:Number,_color,_txt:String):String{
  var htmlFrm:String  = "<font size='"+_size+"'color='"+_color+"'>"+_txt+"</font>";
  return htmlFrm;
  private function closeEvent(me:MouseEvent):void {
  switch (me.type) {
  case "mouseOver" :
  popup_mc.close_btn.alpha = 0.8;
  break;
  case "mouseOut" :
  popup_mc.close_btn.alpha = 1;
  break;
  case "mouseDown" :
  if (stage.contains(popup_mc)) {
  Tweener.addTween(greySprite,{alpha:0,time:0.6,onComplete:function(){removeChild(greySprit e)}});
  Tweener.addTween(popup_mc,{alpha:0,time:0.6,onComplete:function(){removeChild(popup_mc)}} );
  break;
  private function scroll_Event(me:MouseEvent):void {
  switch (me.type) {
  case "mouseOver" :
  scroller.scroll_btn.alpha = 0.7;
  break;
  case "mouseOut" :
  scroller.scroll_btn.alpha = 1;
  break;
  case "mouseUP" :
  scroller.scroll_btn.stopDrag();
  scroller.scroll_btn.removeEventListener(Event.ENTER_FRAME, scrollMove);
  break;
  case "mouseDown" :
  scroller.scroll_btn.startDrag(false, rectScroll);
  scroller.scroll_btn.addEventListener(Event.ENTER_FRAME, scrollMove);
  stage.addEventListener(MouseEvent.MOUSE_UP, releaseOut);
  break;
  private function scrollMove(event:Event):void {
  dy = Math.abs(initPosition - scroller.scroll_btn.y);
  msgContainer.y = Math.round(dy * -1 * moveVal + initContentPos);
  private function releaseOut(me:MouseEvent):void {
  scroller.scroll_btn.stopDrag();
  scroller.scroll_btn.removeEventListener(Event.ENTER_FRAME, scrollMove);
  stage.removeEventListener(MouseEvent.MOUSE_UP, releaseOut);
  private function sendEvent(e:MouseEvent):void {
  switch (e.type) {
  case "mouseOver" :
  form_mc.send_btn.alpha = 0.7;
  break;
  case "mouseOut" :
  form_mc.send_btn.alpha = 1;
  break;
  case "mouseDown" :
  // CHECK FIELDS AND EMAIL THEN SEND DATA TO PHP
  if (form_mc.name_txt.text == "") {
  stage.focus = form_mc.name_txt;
  show_alert("You must enter the : « Name »");
  else if (form_mc.email_txt.text == "") {
  stage.focus = form_mc.email_txt;
  show_alert("You must enter the : « E-mail »");
  else if (form_mc.validating.currentFrame == 1) {
  stage.focus = form_mc.email_txt;
  form_mc.validating.alpha = 1;
  form_mc.validating.gotoAndStop(1);
  show_alert("« E-mail » address is incorrect");
  else if (form_mc.message_txt.text == "") {
  stage.focus = form_mc.message_txt;
  show_alert("You must enter the : « Message »");
  else {
  sendData();
  break;
  private function checkMail(e:Event):void {
  form_mc.validating.alpha = 1;
  var mail_validation:RegExp = /^[a-z][\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;
  mail_validation.test(form_mc.email_txt.text);
  if (mail_validation.test(form_mc.email_txt.text) == true) {
  form_mc.validating.gotoAndStop(2);
  form_mc.alert_txt.text = "";
  else {
  form_mc.validating.gotoAndStop(1);
  private function clearAlert(te:TextEvent):void {
  if (form_mc.alert_txt.text != "") {
  form_mc.alert_txt.text = "";
  private function show_alert(txt:String):void {
  form_mc.alert_txt.htmlText = "<font color='" + myXML.alert_color + "'>" + txt + "</font>";
  private function sendData():void {
  // SEND NAME-EMAIL-MESSAGE TO PHP
  this.mouseChildren = false;
  form_mc.wait_mc.visible = true;
  var phpLoad:URLLoader = new URLLoader  ;
  var phpReq:URLRequest = new URLRequest(myXML.phpURL);
  phpReq.method = URLRequestMethod.POST;
  phpReq.data = new URLVariables  ;
  phpReq.data["name"] = StringUtils.stripTags(form_mc.name_txt.text);
  phpReq.data["email"] = form_mc.email_txt.text;
  phpReq.data["message"] = StringUtils.stripTags(form_mc.message_txt.text);
  phpLoad.addEventListener(Event.COMPLETE,insertPHP);
  phpLoad.load(phpReq);
  private function insertPHP(e:Event):void {
  this.mouseChildren = true;
  var phpXML:XML = new XML(e.target.data);
  form_mc.send_btn.mouseEnabled = true;
  form_mc.wait_mc.visible = false;
  if (phpXML.inserted == 1) {
  startPageFlip();
  form_mc.alert_txt.htmlText = myXML.insert_ok;
  form_mc.validating.alpha = 0;
  form_mc.validating.gotoAndStop(1);
  while (msgContainer.numChildren) {
  msgContainer.removeChildAt(msgContainer.numChildren-1);
  // SHOW THE CURRENT POSTED MESSAGE AND CLEAR FIELDS
  showMessages(phpXML);
  clearFields();
  else {
  form_mc.alert_txt.htmlText = myXML.insert_error;
  private function clearFields():void {
  form_mc.name_txt.text = "";
  form_mc.email_txt.text = "";
  form_mc.message_txt.text = "";
  form_mc.validating.gotoAndStop(1);
  form_mc.validating.alpha = 0;
  private function addMouseEvent(_targ,_func):void {
  _targ.buttonMode = true;
  _targ.mouseChildren = false;
  _targ.addEventListener(MouseEvent.MOUSE_OVER,_func);
  _targ.addEventListener(MouseEvent.MOUSE_OUT,_func);
  _targ.addEventListener(MouseEvent.MOUSE_DOWN,_func);

Similar Messages

  • Any Idea when Apple will email the redemption code for Mountain Lion?

    Any Idea when Apple will email the redemption code for Mountain Lion? I got a code but it said it was invalid on the app store. When will this issue be solved? Kind of getting impatient, given I dropped 2k over their product...

    Any Idea when Apple will email the redemption code for Mountain Lion? I got a code but it said it was invalid on the app store. When will this issue be solved? Kind of getting impatient, given I dropped 2k over their product...

  • Would someone be willing to try this program as a possible whine fix?

    First off I am assuming that the macbook whine exists while running bootcamp as well. IF this is the case would someone consider running SPEEDSWITCHXP while using windows. You can pick the lowest low power state for the processor with this program. If the whine is cause by low current to the proc raising the lowest state a stage or two higher should fix it.
    Please don't flame me for this post if this has been suggested. There are far too many whine threads to sift through. I don't mean to be rude but if you do flame don't expect a response from me.
    Kal

    I hope you don’t consider it a flame, but I’d point out that when you’ve got distinctive keywords for searching, such as SpeedStep, you’ve got a good chance of homing in on the relevent posts pretty quickly with out a lot of “sifting.”
    Randall Schulz

  • Creating AS3 code for C++ classes converted with Alchemy (a là Box2D)

    So I've a collection of C++ classes which I now have converting fine with Alchemy to a swc file and can call the exposed functions fine from my AS3 code.
    What I'd really like to do is recreate stuff like Box2D's b2Vec.as class,
    public class b2Vec2 extends b2Base {
        public function b2Vec2(p:int) {
            _ptr = p;
        public function get v2():V2 {
            return new V2(x, y);
        public function set v2(v:V2):void {
            x = v.x;
            y = v.y;
        public function get x():Number { return mem._mrf(_ptr + 0); }
        public function set x(v:Number):void { mem._mwf(_ptr + 0, v); }
        public function get y():Number { return mem._mrf(_ptr + 4); }
        public function set y(v:Number):void { mem._mwf(_ptr + 4, v); }
    This is a simple example, but shows what I'd like to do.  On the C side of things, b2Vec2 is a struct,
    /// A 2D column vector.
    struct b2Vec2
        /// Default constructor does nothing (for performance).
        b2Vec2() {}
        float32 x, y;
    So, for this struct, it's easy to calculate that the first variable of a b2Vec2 object is a float, which will be the value in x and can be read via Alchemy's MemUser classes _mrf (read a fload from a point in memory) with _mrf(pointerAddress) and you can read in the second float with _mrf(pointerAddress + 4).
    My question is, if you're not a C++ expert (me), is there any way to get the definition of a class, as in the addresses of all the variables within and what they are?  So, for the b2Vec2 one, I'd imaging it'd be something like, float32 x 0 float34 y 4 ...
    The reason I'm asking is because one of the classes in particular has loads of variables and to try and get each and every one's information so I can access it directly from the AS3 code would be lots of work and I'm going to assume I'll introduce plenty of human error to it.

    Hi,
    I am facing the similar issue. Can you please tell me how you solved this problem in more details?
    which sample code and how u can find that in SE24 and where to copy that code.
    Thanks in advance..
    vamsi.

  • When will pre-order beta codes for Rainbow Six Siege be sent out?

    I pre-ordered Rainbow Six Siege Gold Edition and it's supposed to include guarenteed closed beta access. I have not recieved any emails in regards to this, nor can I find any info on when these will be sent out. Any help would be appreciated

    Hi there  welcome to Plug-In ,
    Codes were sent out about a month ago - Please check your junk mail (for the account you used to place the order) and if you're not seeing it there, call customer service directly, they will be able to hook you right up! 

  • Could anyone check this code for errors for me??

    Hi! Could someone please tell me if you see any problems with this code?? a friend wants me to check it for errors, but can't find any. I just wanted to make sure, because there are probably a lot of better scripters than me reading this. Please answer soon!!
    heres the code:
    stop();
    addEventListener(Event.ENTER_FRAME, preLoad);
    function  preLoad(e:Event):void{
    var bytestoLoad):Number = loaderInfo.bytesTotal; 
    var numberLoaded:Number = loaderInfo.bytesLoaded;
    if (bytestoLoad ==  numberLoaded) {
    removeEventListener)Event.ENTER_FRAME, preLoad) 
    gotoAndStop(2);
    }else {
    preLoader.preLoaderFill.scaleX =  numberLoaded/bytestoLoad;
    preLoader.bytePercent.text = Math.floor  (numberLoaded/bytestoLoad*100) + "%";
    Thanks!!
    -Sammy

    I ran it on debug mode and changed it to this? see any problems now? or are they fixed? It looks to me like it took some actions out, I hope that doesn't
    effect it....
    stop();
    addEventListener(Event.ENTER_FRAME, preLoad);
    function preLoad(e:Event):void{
    var bytestoLoad):Number = loaderInfo.bytesTotal;
    var numberLoaded:Number = loaderInfo.bytesLoaded;
    if (bytestoLoad == numberLoaded) {
    removeEventListener)Event.ENTER_FRAME, preLoad)
    gotoAndStop(2);
    i'm kinda new to flash ((I started as a lua scripter (on Roblox)) so I'm a little confused about this. Thanks for the help!!

  • URGENT Check this code for me please

    Dear whoeverthisreads, please read and see at the bottom my sourcecode, or whatever I could make of it until (even with help) I failed to see any solution. Please copy, paste and run to see if you can manage to adjust the program to make it work in the way as described. And I think I made it unnecessarily complicated. Whatever you can do for me, I will be very, very grateful.
    Prem Pradeep, email: [email protected]
    (A beginning dutch Java student who is running out of time and hope)
    Catalogue Manager
    Specification:
    a) Develop an object to represent to encapsulate an item in a catalogue. Each CatalogueItem has three pieces of information: an alphanumeric catalogue code, a name, and a price (in dollars and cents), that excludes sales tax. The object should also be able to report the price, inclusive of a 15% sales tax, and the taxed component of the price.
    b) Work out a way to be able to support the inc tax/ex tax price accessors, and the tax component accessor, without needing to store any additional information in the object.
    c) Use an array of 5 CatalogueItem items to store data. (You may assume that no imported goods will be recorded.)
    d) Write a driver program that prompts for three sets of user input (catalogue number, description and price), to be stored in the atalogueItem instance.
    e) The data are to be read for each item in a single line. The data lines will be in the format:
    CatNo:Description:Price
    Use a StringTokenizer object to separate these data lines into their components.
    f) Review the class definition of CatalogueItem, and use modifiers where appropriate to:
    � Ensure that data is properly protected;
    � Ensure that the accessors and mutators are most visible;
    � The accessors and mutators for the catalogue number and description cannot be overridden.
    � The constant for the tax rate is publicly accessible, and does not need an instance of the class
    present in order to be accessible.
    As well as a summary, the program should also calculate and display:
    � All of the cheapest and most expensive item(s) in the catalogue. In the case of more than one
    item being the cheapest (or most expensive), they should all be listed.
    � A total of the pre-tax worth of the goods in the catalogue.
    � The average amount of tax on the items in the catalogue.
    A sample execution of the program may be as follows (output should be tabulated):
    Enter five items of data:
    AA123: Telephone: 52.00
    ZJ282: Pine Table: 98.00
    BA023: Headphones: 23.00
    ZZ338: Wristwatch: 295.00
    JW289: Tape Recorder: 23.00
    LISTING OF ALL GOODS
    Cat      Description      ExTax           Tax           IncTax ~
    ZJ282      pine Table           98.00           14.70           112.70
    AA123 Telephone           52.00           7.80           59.80
    BA023 Headphones      23.00           3.45           26.45
    ZZ338      Wristwatch      295.00      44.25      339.25
    JW289 Tape Recorder      23.00           3.45           26.45
    CHEAPEST GOODS IN CATALOGUE
    Cat      Description      ExTax           Tax           IncTax
    BA023 Headphones           23.00           3.45           26.45
    JW289 Tape Recorder      23.00           3.45           26.45
    MOST EXPENSIVE GOODS IN CATALOGUE
    Cat      Description      ExTax           Tax           IncTax
    ZZ338      Wristwatch      295.00      44.25      339.25
    TOTAL PRE-TAX WORTH OF CATALOGUE ITEMS:      491.00
    AVERAGE AMOUNT OF TAX PAYABLE PER ITEM:      14.73
    The next code is what I could make of it�until I got terribly stuck...
    //CatalogueItem.java
    import java.io.*;
    import java.text.DecimalFormat;
    import java.util.StringTokenizer;
    public class CatalogueItem {
    private static final double TAXABLE_PERCENTAGE = 0.15;
    private String catalogNumber;
    private String description;
    private double price;
    /** Creates a new instance of CatalogueItem */
    public CatalogueItem() {
    catalogNumber = null;
    description = null;
    price = 0;
    public CatalogueItem(String pCatalogNumber, String pDescription, double pPrice) {
    catalogNumber = pCatalogNumber;
    description = pDescription;
    price = pPrice;
    void setCatalogNumber(String pCatalogNumber) {
    catalogNumber = pCatalogNumber;
    String getCatalogNumber() {
    String str = catalogNumber;
    return str;
    void setDescription(String pDescription) {
    description = pDescription;
    String getDescription() {
    String str = description;
    return str;
    void setPrice(String pPrice) {
    price = Double.parseDouble(pPrice);
    double getPrice() {
    double rprice = price;
    return formatDouble(rprice);
    double getTaxAmount(){
    double rTaxAmount = price * TAXABLE_PERCENTAGE;
    return formatDouble(rTaxAmount);
    double getIncTaxAmount() {
    double rTaxAmount = price * (1 + TAXABLE_PERCENTAGE);
    return formatDouble(rTaxAmount);
    double formatDouble(double value) {
    DecimalFormat myFormatter = new DecimalFormat("###.##");
    String str1 = myFormatter.format(value);
    // System.out.println("String is " + str1);
    // System.out.println("The format value : " + value);
    return Double.parseDouble(str1);
    public static void main(String[] args) throws IOException {
    final int MAX_INPUT_SET = 5;
    final String strQ = "Enter five items of data:";
    CatalogueItem[] catalogList = new CatalogueItem[MAX_INPUT_SET];
    String strInput;
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    String header = "Cat\tDescription\tExTax\tTax\tInc Tax";
    String lines = "---\t-----------\t------\t---\t-------";
    // Input of five items with three data each, delimiter ":"
    for (int i = 0; i < MAX_INPUT_SET; i++) {
    catalogList[i] = new CatalogueItem();
    System.out.print(strQ);
    strInput = stdin.readLine();
    StringTokenizer tokenizer = new StringTokenizer(strInput, ":" );
    String inCatNo = tokenizer.nextToken();
    String inDescr = tokenizer.nextToken();
    String inPrice = tokenizer.nextToken();
    catalogList.setCatalogNumnber(inCatNo);
    catalogList[i].setDescription(inDescr);
    catalogList[i].setPrice(inPrice);
    // Listing of all goods
    System.out.println("LISTING OF ALL GOODS");
    System.out.println(header);
    System.out.println(lines);
    for (int i = 0; i < MAX_INPUT_SET; i++) {
    System.out.println(
    catalogList[i].getCatalogNumber() + "\t" +
    catalogList[i].getDescription() + "\t" +
    catalogList[i].getPrice() + "\t" +
    catalogList[i].getTaxAmount() + "\t" +
    catalogList[i].getIncTaxAmount());
    // This should pick the cheapest and most expensive goods in catalogue, but
    // this code is not good:
    // In the case of more than one item being the cheapest (or most expensive),
    // they should all be listed.
    double cheapest = cataloguelist[1].getPrice();
    double mostExpensive = cataloguelist[1].getPrice();
              for(int i=2; i< MAX_INPUT_SET; i++){
                   if (cataloguelist[i].getPrice < cheapest)
              cheapest = i;}
              for(int i=2; i< MAX_INPUT_SET; i++){
                   if (cataloguelist[i].getPrice > mostExpensivet)
              mostExpensive = i;}
    // Lists cheapest goods (not complete enough)
    i = cheapest;
    System.out.println("CHEAPEST GOODS IN CATALOGUE");
    System.out.println(header);
    System.out.println(lines);
    System.out.println(
    catalogList[i].getCatalogNumber() + "\t" +
    catalogList[i].getDescription() + "\t" +
    catalogList[i].getPrice() + "\t" +
    catalogList[i].getTaxAmount() + "\t" +
    catalogList[i].getIncTaxAmount());
    // Lists most expensive goods (not complete enough)
    i = mostExpensive;
    System.out.println("MOST EXPENSIVE GOODS IN CATALOGUE");
    System.out.println(header);
    System.out.println(lines);
    System.out.println(
    catalogList[i].getCatalogNumber() + "\t" +
    catalogList[i].getDescription() + "\t" +
    catalogList[i].getPrice() + "\t" +
    catalogList[i].getTaxAmount() + "\t" +
    catalogList[i].getIncTaxAmount());}}
    // Generates and shows total pre-tax worth of catalogue items (how??)
    // generates and shows amount of tax payable per item (how??)

    How is this:
    import java.io.*;
    import java.text.*;
    import java.util.*;
    public class Cat
         Vector items = new Vector();
    public Cat()
    public void read(String fname)
         FileReader     fr;
        BufferedReader br;
         String         str ="";
        try
             fr = new FileReader(fname);
            br = new BufferedReader(fr);
            while ((str = br.readLine()) != null && items.size() < 30)
                   if (!str.trim().equals(""))
                        StringTokenizer tokenizer = new StringTokenizer(str, ":");
                     String n = tokenizer.nextToken().trim();
                        String d = tokenizer.nextToken().trim();
                        String s = tokenizer.nextToken().trim();
                        double p = Double.parseDouble(s);
                        items.add(new Item(n,d,p));
            fr.close();
        catch (FileNotFoundException e)
            System.out.println("Input file cannot be located, please make sure the file exists!");
            System.exit(0);
        catch (IOException e)
            System.out.println(e.getMessage());
            System.out.println("Application cannot read the data from the file!");
            System.exit(0);
    public void displayAll()
         for (int j=0; j < items.size(); j++)
              Item item = (Item)items.get(j);
              System.out.println(item.toString());
    public void sort()
         Collections.sort(items);     
    public class Item implements Comparable
         String       number, description;
         double       price,pricep;
         final double TAXRATE = 0.15;
    public Item(String number, String description, double price)
         this.number      = number;
         this.description = description;
         this.price       = price;
         this.pricep      = price * TAXRATE;
    public int compareTo(Object o1)
         String o = ((Item)o1).number;
         return(number.compareTo(o));
    public String toString()
         DecimalFormat df = new DecimalFormat("#.00");     
         String        p1 = df.format(TAXRATE*price);
         String        p2 = df.format(TAXRATE*price+price);
         String s = number+"\t "+description+"\t"+price+"\t"+p1+"\t"+p2+"\t" ;
         return(s);
    public static void main (String[] args)
         Cat catalog = new Cat();
         catalog.read("C31.dat");
         String reply = "";
         BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
         while (!reply.equals("e"))
              System.out.println("");
            System.out.println("CATALOGUE MANAGER: MAIN MENU");
            System.out.println("============================");
            System.out.println("a) display all goods        b) display cheapest/dearest goods");
            System.out.println("c) sort the goods list      d) search the good list");
            System.out.println("e) quit");
            System.out.print("Option:");
              try
                   reply = stdin.readLine();
              catch (IOException e)
                System.out.println("ERROR:" + e.getMessage());
                System.out.println("Application exits now");
                System.exit(0);
              if (reply.equals("a")) catalog.displayAll();
              if (reply.equals("c")) catalog.sort();
    Noah

  • Checking T code for HR only

    Hi Experts
    How can I write a program to search only tcode belongs to HR , Managment need a report which shows who have been assign the tcode for Payroll , I check in suim but it is not in detail
    Can anyone send me send sample of report or give an idea how to design it
    regards
    Monto

    Hi Aatish
    I don't want the reports from SUIM, it is showing all the tcodes
    I want only t codes belong to payroll or sales etc
    Monto

  • Would someone please give me a top anchor for my stack of 200 mp3's instead of a bottom anchor for the the stack.

    I would just like my stack of 200 mp3's to display from the top down that are sitting on my dock and Not from the bottom up when I open them.
    They displayed correctly when I ran Snow Leopard but I'm thinking some genious wrote a bottom anchor into the operating system for Mountain Lion.
    Would you like it if a news article open at the bottom instead of the top?

    The answer to both of your questions is No.
    What I have is a stacked list and apparently this issue will never be resolved.
    I even had a supervisor said he would ask that we be given an option to display the list contents the way we wanted, but that was over a year ago and nothing was ever done.
    Which tells me either Apple script writers don't have the knowledge to reverse the list order or they don't care.
    As I've already mentioned, the list displayed alphabetically from top to bottom when I was running Snow Leopard!

  • URGENT check the code for vendor ageing (Give Solution)

    hi this is the code which i am using to calculate the
    ageing but not able to get the result.
    every time the result is 0.plz suggest me the solution.
    its very urgent.
    *& Report  Z_VENDOR AGEING                                                    *
    *&  in this repoet I am calculating the vendor ageing
        which is depending on formula
        AGEING = Current Date(or any date entered by user) – Bline Date(BSIK-zfbdt) 
    REPORT  z_vendor  NO STANDARD PAGE HEADING
                      LINE-SIZE 200
                      LINE-COUNT 65(3).
    TABLES : bsik.
    DATA : BEGIN OF t_out OCCURS 0,
           bukrs LIKE bsik-bukrs,
           saknr LIKE bsik-saknr,
           bldat LIKE bsik-bldat,
           wrbtr LIKE bsik-wrbtr,
           lifnr LIKE bsik-lifnr,
           zfbdt like bsik-zfbdt,
           ageing type i,
           END OF t_out.
    parameters : p_date1 type d.
    SELECT-OPTIONS : s_bukrs FOR bsik-bukrs,
                     s_saknr FOR bsik-saknr,
                     s_lifnr FOR bsik-lifnr.
    SELECT bukrs saknr bldat wrbtr lifnr zfbdt
           FROM bsik
           INTO  TABLE t_out
           WHERE saknr IN s_saknr
           AND bukrs IN s_bukrs
           AND lifnr IN s_lifnr.
    CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
      EXPORTING
        i_datum_bis                   = p_date1
        i_datum_von                   = t_out-zfbdt
      I_KZ_EXCL_VON                 = '0'
      I_KZ_INCL_BIS                 = '0'
      I_KZ_ULT_BIS                  = ' '
      I_KZ_ULT_VON                  = ' '
      I_STGMETH                     = '0'
      I_SZBMETH                     = '1'
    IMPORTING
       E_TAGE                        = t_out-ageing
    EXCEPTIONS
      DAYS_METHOD_NOT_DEFINED       = 1
      OTHERS                        = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    LOOP AT t_out.
      WRITE : / t_out-saknr,
                t_out-lifnr,
                t_out-wrbtr,
                t_out-zfbdt,
                t_out-ageing.
    ENDLOOP.

    hi sanjeev,
    still problem there.
    dont worry. just copy this code.
    try this code.
    TABLES : bsik.
    DATA : BEGIN OF t_out OCCURS 0,
    bukrs LIKE bsik-bukrs,
    saknr LIKE bsik-saknr,
    bldat LIKE bsik-bldat,
    wrbtr LIKE bsik-wrbtr,
    lifnr LIKE bsik-lifnr,
    zfbdt like bsik-zfbdt,
    ageing type i,
    END OF t_out.
    parameters : p_date1 type d.
    SELECT-OPTIONS : s_bukrs FOR bsik-bukrs,
    s_saknr FOR bsik-saknr,
    s_lifnr FOR bsik-lifnr.
    SELECT bukrs saknr bldat wrbtr lifnr zfbdt
    FROM bsik
    INTO <b>corresponding fields of</b> TABLE t_out
    WHERE saknr IN s_saknr
    AND bukrs IN s_bukrs
    AND lifnr IN s_lifnr.
    <b>loop at t_out.</b>
    CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
    EXPORTING
    i_datum_bis = p_date1
    i_datum_von = t_out-zfbdt
    I_KZ_EXCL_VON = '0'
    I_KZ_INCL_BIS = '0'
    I_KZ_ULT_BIS = ' '
    I_KZ_ULT_VON = ' '
    I_STGMETH = '0'
    I_SZBMETH = '1'
    IMPORTING
    E_TAGE = t_out-ageing
    EXCEPTIONS
    DAYS_METHOD_NOT_DEFINED = 1
    OTHERS = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    <b>modify t_out.</b>
    clear t_out.
    <b>endloop.</b>
    LOOP AT t_out.
    WRITE : / t_out-saknr,
    t_out-lifnr,
    t_out-wrbtr,
    t_out-zfbdt,
    t_out-ageing.
    endloop
    rgds
    anver
    Message was edited by: Anversha s

  • Can check the code for me??

    import java.io.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.filechooser.*;
    import java.applet.*;
    public class Mplayer extends Applet
         JButton openButton;
         JButton cancelButton;
         JFileChooser fc;
         int returnVal;
         public void init()
              fc = new JFileChooser();
              returnVal = fc.showOpenDialog(this);
         public void start()
              if(returnVal == JFileChooser.APPROVE_OPTION)
                   File file = fc.getSelectedFile();
                   String path = file.getPath();
                   System.out.println("Opening: " +file.getPath());
              else
                   System.out.println("Cancelled by user");
    -- this code can be compiled, but when i open this applet, the 1st error is about java.security.AccessControlException, i think got some problem about " returnVal = fc.showOpenDialog(this);".. can help me to figure out..?? --

    Try this: this (ie: 'grant{ ...' isn't an Internet solution but it should allow you to use your app locally in appletviewer and develop your skills unhindered
    // not tested
    import java.io.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.filechooser.*;
    public class Mplayer extends JApplet{
       JButton openButton;
       JButton cancelButton;
       JFileChooser fc= new JFileChooser();
       int returnVal;
       public void init(){
          grant{ permission java.security.AllPermission; };
          returnVal = fc.showOpenDialog(this);
          if(returnVal == JFileChooser.APPROVE_OPTION){
             File file = fc.getSelectedFile();
             String path = file.getPath();
             System.out.println("Opening: " +file.getPath());
          else System.out.println("Cancelled by user");

  • Please check the code for me

    DATA :Begin of itab_reqid occurs 0,
          objid like hrp1001-objid,
           end of itab_reqid,
          Begin of itab_postid occurs 0,
           postid like hrp1001-objid,
           end of itab_postid.
    Select distinct objid from hrp5125 into table itab_reqid
                                     where aedtm BETWEEN '20060107' and '20073108'.
    Select OBJID from hrp1001 into table itab_postid where objid IN itab_reqid
                                                           AND SCLAS = 'NC'.
    The above code gives an error called "line type for itab_reqid is incorrect".
    Please advise,
    Thanks

    Hi Reena,
    I am not sure if your approach works for ranges. I think the problem in your code is that itab_reqid is not a range and yet you have used it like a range in your SQL SELECT where clause.
    You could try this approach instead:
    DATA :Begin of itab_reqid occurs 0,
                 objid like hrp1001-objid,
               end of itab_reqid,
               Begin of itab_postid occurs 0,
                 postid like hrp1001-objid,
               end of itab_postid.
    RANGES: r_reqid for hrp1001-objid.
    Select distinct objid from hrp5125 into table itab_reqid
    where aedtm BETWEEN '20060107' and '20073108'.
    if not itab_reqid[] is initial.
      r_reqid-option = 'EQ'.
      r_reqid-sign = 'I'.
      LOOP AT itab_reqid.
         r_reqid-low = itab_reqid-objid.
         append r_reqid.
      ENDLOOP.
      Select OBJID from hrp1001 into table itab_postid where objid IN itab_reqid
         AND SCLAS = 'NC'.
    endif.
    Kind Regards,
    Darwin

  • AS3 code for Mouse Event

    Hi,
    I had uploaded jpeg file onto the stage using
    File->Import.
    Now, how to access the mouse-events using AS3.0?
    i.e., when we click with mouse on the stage
    it should display the x and y co-ordinates of the point
    being clicked.
    These x and y coordinates must be displayed in text-boxes
    provided down on the same stage.
    Please reply me

    You can do show/hide movieclip on mouseover. get your box
    position and assign to the popup (tooltip movieclip).
    see this...
    not tested. but it should work.
    import flash.events.MouseEvent;
    function showClip(evt:MouseEvent) {
    tooltips.x = evt.target.x + evt.target.width;;
    tooltips.y = evt.target.y - evt.target.height;
    tooltips.visible = true
    function hideClip(evt:MouseEvent) {
    tooltips.visible = false;
    box.addEventListener(MouseEvent.MOUSE_OVER, showClip);
    box.addEventListener(MouseEvent.MOUSE_OUT, hideClip);
    I assume you'll create two movieclips named: box and tooltips

  • Can Someone in Admin pls check my account for me

    I have a years subscription and it is still asking for credit.

    I'Ve just had your account checked: You have a subscription which only covers calls to landline numbers. But you tried calling shared cost and mobile numbers which are not included.
    Follow the latest Skype Community News
    ↓ Did my reply answer your question? Accept it as a solution to help others, Thanks. ↓

  • Would someone try leaving 1.3.1 minimized for a bit (XP SP2) ?

    All,
    I am getting one of those intermittent (more often than not) issues with 1.3.1 on an XP SP2 machine. If I leave LR minimized to the applications Taskbar at the bottom for an extended period, I am not able to click on the Taskbar representation to restore the window. I can right click and do a restore that way, but as I said, more often than not it just sits there when I click on it. After doing a "Maximize" it works minimizing and restoring, until I let it sit for a while. I tried re-installing 1.3.1 back over itself with a "repair" option, turned off the screen saver, etc. It appears as though the connection to the application and the Taskbar have lost touch with one another.
    Anyone with any thoughts? I can't pin down a time.. e.g. 15 minutes, 30 minutes, etc. I'd appreciate some folks trying and letting me know. It isn't happening with the Mac Dock..
    Jay S.

    A similar glitch: I can get Lightroom either full-screen or minimized, but I can't size the window. With LR full-screen, the traditional upper RH corner symbols for minimize, size and close are not visible. I can close LR from the file menu, so that is hardly a problem, and I run two monitors, so not being able to size the screen is something I can work with, too.
    The oddest thing about this glitch is that the task bar does not work in the usual way. Left clicking the task bar tab acts as a toggle between full-screen and minimized, as it should. But right-clicking the task bar does nothing. Usually, you get a pop-up menu that has a few simple commands, one of which allows you to size the window.
    I am running Lightroom 1.3.1 under XP, service pack 2. I didn't have this problem with LR 1.3.0.
    Cheers,
    Bob

Maybe you are looking for

  • Issue with Instantiation of a Class in Workflow

    I created a subclass of CL_HRASR00_WF_PROCESS_OBJECT to include some of my custom methods to be used in the workflow. Since the subclass methods cant be referred using the super class name(as we do in BO) in the standard task , i used a custom method

  • Why can't I use the Feedback Button in 4.0 Beta 1 (it says I need to update)?

    I'm trying to use Firefox 4.0 Beta 1 and wanted to send Feedback. When I click on Feedback it brings up the following text: "Oh! So, you want to offer us feedback on the next version of Firefox. Thank you, but you'll need to be a part of our Beta Pro

  • BDC Program for Uploading Data for Property Tree in cg02

    Hi,     How to upload data for property tree ( standard Properties ) of CG02. I checked for BAPI or Function Module but most them supports for specification header and sub item.  Please Let me know if any function module or BAPI available for this pr

  • Constructor behaviour via INSERT SQL

    Interestingly, using an object constructor itself as the insert value seems to have overheads, with the constructor being called multiple times for instantiating the single same object. Cannot recall seeing this documented. Here's an example (on 11.2

  • Count Distinct Over Partition Syntax Error

    Count(Distinct [field]) over (partition by [field2]) returns a syntax error at the key word distinct Count(all [field]) over (partition by [field2]) compiles fine I am writing a query to count the number of clients a sales rep has when the sales rep