Skip to main content
Participant
October 18, 2009
Question

Can`t change inline graphics

  • October 18, 2009
  • 1 reply
  • 716 views

I`am trying to change inline graphics in textFlow

I tried in both ways:

1. Directly - find image node (by getElementByID) and change it source field

2. By EditManager.modifyInlineGraphic

No luck. Image stays the same, I can only change the size of it.

What did I do wrong?

This topic has been closed for replies.

1 reply

Adobe Employee
October 19, 2009

Works here.  Do you have some sample code - as small AS program that demonstrates the problem would be very useful.

Thanks,

Richard

alexruAuthor
Participant
October 20, 2009

Sure, her is simple code from FlashDevelop. On enter I trying to change image by using EditManager method. But only size changes

public class Main extends Sprite {
        private var txtSprite:Sprite = new Sprite();
        private var tf:TextFlow = new TextFlow();
        private var edit:EditManager = new EditManager();
       
       
        [Embed(source = "imgA.jpg")]
        public var IMG_A:Class;   
       
        [Embed(source = "imgB.jpg")]
        public var IMG_B:Class;
       
       
        public function Main():void {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }
       
        private function init(e:Event = null):void {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            stage.addEventListener(KeyboardEvent.KEY_DOWN, onKey);
           
            tf.flowComposer.addController(
                new ContainerController(txtSprite, 300, 300);
               
            tf.interactionManager = edit;
           
            var p:ParagraphElement = new ParagraphElement();
            tf.addChild(p);
           
            var ig:InlineGraphicElement = new InlineGraphicElement();
            ig.source = new IMG_A();           
            ig.id = "img";
            p.addChild(ig);
           
            tf.flowComposer.updateAllControllers();
                       
            addChild(txtSprite);
        } // init()
       
        private function onKey(e:KeyboardEvent):void {
            if (e.keyCode == 13) {
                var ss:SelectionState = new SelectionState(tf, 0, 0);
                edit.modifyInlineGraphic(new IMG_B(), 100, 100, null, ss);
                tf.flowComposer.updateAllControllers();               
            }
        } // onKey()
    } 

Adobe Employee
October 21, 2009

Hi,


1) Change the source to be like this:

ig.source = IMG_A;

and in onKey to be like this:

edit.modifyInlineGraphic(IMG_B, 100, 100, null, ss);

2) The call to updateAllControllers after modifyInlineGraphic is redundant - you can remove it.

Then it works.

Not sure why it doesn't work when you "new" the classes but I'll look into that.

Hope that helps,

Richard