Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This works for me in LivePreview, as long as I apply it in configUI, and not draw:</p> <pre><code>public class EditableBitmap extends UIComponent { protected var placeholder:String = "None"; protected var bitmap:Bitmap; protected var scale:Number = 1; [Inspectable(name = "Placeholder", type = String, defaultValue="None")] public function set Placeholder($value:String):void { placeholder = $value; configUI(); } public function get Placeholder():String { return placeholder; } public function EditableBitmap() { //Console.Debug("NEW EditableBitmap"); super(); } override protected function configUI():void { //Console.Debug("EditableBitmap configUI: " + width); if (!isNaN(width)) { wDim = width; hDim = height; graphics.clear(); graphics.beginFill(0x000000, 0.1); graphics.drawRect(0, 0, wDim, hDim); } if (placeholder != "None" &amp;&amp; placeholder != "") { var asset:Class = getDefinitionByName(placeholder) as Class; var data:BitmapData = new asset() as BitmapData; bitmap = new Bitmap(data); } super.configUI(); } override protected function draw():void { if (bitmap) { addChild(bitmap); bitmap.x = off_x * scale; bitmap.y = off_y * scale; bitmap.scaleX = bitmap.scaleY = scale; } } } </code></pre> <p><strong>NOTE:</strong> When I'm working on the FLA where I am editing the component, the bitmap is only displayed from the library inconsistenty. Sometimes it works, sometimes it doesn't. But when I export the SWC and then import the component to another movie, it works every time, in LivePreview as well as at runtime.</p> <p><strong>UPDATE</strong> It seems this doesn't work in CS6 unless the symbol is already embedded in the component .SWC I wanted to see if I could trick it, by embedding one image in the SWC and then replacing it with another of the same name in the destination file. This didn't work, but it did point me to how you can do this: </p> <p><img src="https://i.stack.imgur.com/uVIhz.png" alt="enter image description here"></p> <p>So, it's a bit laborious, but you could work around this by:</p> <p>1) Creating a dummy asset for each property in the component SWC. 2) Overriding this using a custom class in the file where you deploy the component</p> <p>... all of which may be more trouble than it's worth, but which should provide a solution to the problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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