Skip to main content
Inspiring
May 20, 2010
Answered

modifyInlineGraphic ???

  • May 20, 2010
  • 1 reply
  • 1504 views

Hi,

How can I use modifyInlineGraphi? The main problem is find a way to supply the "source property". All my images are remote, the only value I have is the url. I tried  these options without luck:

1)

var urlreq:URLRequest = new URLRequest( 'www.example.com/img.jpg' );
IEditManager( textFlow.interactionManager ).modifyInlineGraphic(urlreq, newWidth, newHeight);

2)
IEditManager( textFlow.interactionManager ).modifyInlineGraphic( 'www.example.com/img.jpg' ,newWidth, newHeight);

3)

var img:InlineGraphicElement = textFlow.getElementByID( imgId ) as InlineGraphicElement;
IEditManager( textFlow.interactionManager ).modifyInlineGraphic(img.source, newWidth, newHeight);

4)

var img:InlineGraphicElement = textFlow.getElementByID( imgId ) as InlineGraphicElement;
IEditManager( textFlow.interactionManager ).modifyInlineGraphic(img, newWidth, newHeight);

This is what the documentation:

@9397041    source    can be either a String interpreted as a uri, a Class interpreted as the class of an Embed DisplayObject,  a DisplayObject instance or a URLRequest.

I'm able to modify the InlineGraphicElement directly, but that is less than optimal, because resets the undomanager.

Any ideas?

This topic has been closed for replies.
Correct answer rdermer

In option 4 I'm able to get the instance of the inLineGrpachElement:

4)

var img:InlineGraphicElement =  textFlow.getElementByID( imgId ) as InlineGraphicElement;

IEditManager( textFlow.interactionManager ).modifyInlineGraphic(img, newWidth, newHeight);

What I'm doing is looping thru all images and modifing them without the users's interaction (selection or buttons). I guess the problem is that when I call modifyInlineGraphic, the inLineGrpachElement is not recognized.

Any ideas?


var img:InlineGraphicElement =  textFlow.getElementByID( imgId ) as  InlineGraphicElement;

// create a state and pass it to the modifyInlineGraphic function as below

var state:SelectionState = new SelectionState(textFlow,img.getAbsoluteStart(),img.getAbsoluteStart()+1);

IEditManager( textFlow.interactionManager  ).modifyInlineGraphic(img, newWidth, newHeight, null, state);

Richard

1 reply

oscar7878Author
Inspiring
May 20, 2010

quick note:

I just saw how this is handled in the Demo Editor:

          protected function applyChange():void
            {
                changeForeignElement(imageURL.text, imageWidth.text, imageHeight.text, "none", doChangeImage);               
            }
           
              protected function changeForeignElement(foreignElementUrl:String, width:String, height:String, float:String, changeCurrent:Boolean):void
             {
                 if (activeFlow && activeFlow.interactionManager is IEditManager)
                 {
                    if (changeCurrent)
                         IEditManager(activeFlow.interactionManager).modifyInlineGraphic(foreignElementUrl, width, height, float);
                    else
                        IEditManager(activeFlow.interactionManager).insertInlineGraphic(foreignElementUrl, width, height, float);
                     activeFlow.interactionManager.setFocus();
                 }
             }

The difference between this and what I tried in option 2, is that my images are been added in a initial import, not one by one, or using insertInlineGraphic.

The demo editor doesn't have an undomananger, so there is no way to know for sure if this is not reseting it.

any ideas?

Adobe Employee
May 20, 2010

textFlow.findLeaf(textFlow.interactionManager.absoluteStart) should return an InlineGraphicElement before calling modifyInlineGraphic.  If it doesn't you can either pass a SelectionState to modifyInlineGraphic or set the absoluteStart of the interactionManager.

Hope that helps,

Richard

Participant
June 29, 2011

var img:InlineGraphicElement =  textFlow.getElementByID( imgId ) as  InlineGraphicElement;

// create a state and pass it to the modifyInlineGraphic function as below

var state:SelectionState = new SelectionState(textFlow,img.getAbsoluteStart(),img.getAbsoluteStart()+1);

IEditManager( textFlow.interactionManager  ).modifyInlineGraphic(img, newWidth, newHeight, null, state);

Richard


Thanks Richard for solution.

I have one obiection, though:

instead of: IEditManager( textFlow.interactionManager  ).modifyInlineGraphic(img, newWidth, newHeight, null, state);

one should use: IEditManager( textFlow.interactionManager  ).modifyInlineGraphic(img.source, newWidth, newHeight, null, state);

OR: IEditManager( textFlow.interactionManager  ).modifyInlineGraphic(img.graphic, newWidth, newHeight, null, state);

because of ModifyInlineGraphicOperation -> doOperation().

At least this is the case if used with the sdk <version>4.5.0</version><build>20967</build>.