Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy can't I get a returned value from my custom class?
    text
    copied!<pre><code>package com.adam.etutorial </code></pre> <p>{ import flash.display.MovieClip; import flash.text.TextField; import flash.display.Sprite; import flash.text.TextFormat; import flash.display.Shape;</p> <pre><code>public class adamsboxmaker { //(boxWidth, boxHeight, lineColour, lineThickness, beginFillColour, fillIf, fontcolour, fontsize, fonttype, textFormat, textWidth, textHeight, text, Xoffset, Yoffset, textIf) public function adamsboxmaker(boxWidth:Number,boxHeight:Number,lineColour:Number,lineThickness:int, beginFillColour:Number, fillIf:Boolean, fontColour:Number, fontSize:int, fontType:String, textWidth:Number, textHeight:Number, txt:String, Xoffset:Number, Yoffset:Number, textIf:Boolean) { createBox(boxWidth,boxHeight,lineColour,lineThickness, beginFillColour, fillIf, fontColour, fontSize, fontType, textWidth, textHeight, txt, Xoffset, Yoffset, textIf); } private function createBox(boxWidth:Number,boxHeight:Number,lineColour:Number,lineThickness:int, beginFillColour:Number, fillIf:Boolean, fontColour:Number, fontSize:int, fontType:String, textWidth:Number, textHeight:Number, txt:String, Xoffset:Number, Yoffset:Number, textIf:Boolean) { /*BUILD CONTAINER*/ var container:MovieClip = new MovieClip(); /*END CONTAINER*/ /*BUILD BOX*/ var theBox:Shape = new Shape(); container.addChild(theBox); theBox.graphics.lineStyle(lineThickness, lineColour); if (fillIf == true) { theBox.graphics.beginFill(beginFillColour); } theBox.graphics.moveTo(0, 0); theBox.graphics.lineTo(boxWidth, 0); theBox.graphics.lineTo(boxWidth, boxHeight); theBox.graphics.lineTo(0, boxHeight); theBox.graphics.lineTo(0, 0); if (fillIf == true) { theBox.graphics.endFill(); } /*END BOX*/ if (textIf == true) { /*BUILD FORMATTING*/ var myFormat:TextFormat = new TextFormat(); myFormat.color = fontColour; myFormat.size = fontSize; myFormat.font = fontType; /*END FORMATTING*/ /*BUILD TEXTFIELD*/ var theText:TextField = new TextField(); theText.text = txt; theText.x = Xoffset; theText.y = Yoffset; theText.width = textWidth; theText.height = textHeight; theText.wordWrap = true; theText.setTextFormat(myFormat); container.addChild(theText); /*END TEXTFIELD*/ } container.visible = false; return container; } } </code></pre> <p>}</p> <p>This is my first crack at writing a class and after reading up this is what I have.</p> <p>Essentially, I want to be able to write var txt:adamsboxmaker = new adamsboxmaker(parameters);</p> <p>and have txt be a display object from the returned MovieClip. But that's not happening. Can someone point me in the right direction?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload