我使用带有UIComponent的画布在flex4中加载图像。我想要缩放图像,它完成图像缩放但滚动条没有添加到画布,因为我想用滚动移动图像,鼠标悬停,请建议我任何解决方案为此或任何有应用程序。 谢谢, 尼丁
<mx:Metadata>
[Event(name="PDFComplete",type="flash.events.Event")]
</mx:Metadata>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
private var swfURL:String = "pdf/outra.swf";
public var loader:Loader = null;
public var bool:Boolean = false;
public var myPath:String = "";
import mx.events.ScrollEvent;
public var libMC:MovieClip = new MovieClip();
private function init():void {
/*Hide the default context menu with print option*/
var myMenu:ContextMenu = new ContextMenu();
myMenu.hideBuiltInItems();
var defaultItems:ContextMenuBuiltInItems = myMenu.builtInItems;
defaultItems.print = false;
this.contextMenu = myMenu;
//if (ExternalInterface.available)
ExternalInterface.addCallback("pdfURL", loadPDF);
if(bool == false) {
loadPDF(swfURL);
bool = true;
}
}
private function loadPDF(name:String):void {
myPath = name;
if(loader!= null) {
swfContainer.removeChild(loader);
loader = null;
}
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfComplete);
var fLoader:ForcibleLoader = new ForcibleLoader(loader);
fLoader.load(new URLRequest(myPath));
swfContainer.addChild(loader);
swfContainer.addEventListener(Event.RESIZE, updateStageSize);
}
private function swfComplete(event:Event):void{
libMC = event.currentTarget.content as MovieClip;
libMC.gotoAndStop(1);
dispatchEvent(new Event("PDFComplete"));
controls.target = libMC;
controls.rootSwfContainer = swfContainer;
libMC.x = (swfContainer.width/2)-(libMC.width/2);
libMC.y = (swfContainer.height/2)-(libMC.height/2);
var point:Point=new Point(libMC.x+libMC.width/2, libMC.y+libMC.height/2);
controls.points = point;
}
public function updateStageSize(e:Event):void
{
if(libMC.width < swfContainer.width && libMC.height < swfContainer.height) {
libMC.x = (swfContainer.width-libMC.width)/2;
libMC.y = (swfContainer.height-libMC.height)/2;
}
}
]]>
</mx:Script>
<views:Control id="controls"/>
<mx:HDividedBox top="40" width="100%" height="100%">
<mx:Canvas id="canvasContainer" backgroundColor="#222222" width="100%" height="100%" horizontalScrollPolicy="auto" verticalScrollPolicy="auto">
<mx:UIComponent id="swfContainer" width="100%" height="100%"/>
</mx:Canvas>
</mx:HDividedBox>
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.DropdownEvent;
import mx.events.IndexChangedEvent;
[Bindable]private var _currentPage:Number;
private var _target:*;
private var _swfContainer:*;
private var _point:Point;
private var currentScale:Number =1;
private var rotateIndex:Number = 0;
public function set target(value:*):void {
_target = value;
}
public function get target():*{
return _target;
}
public function set rootSwfContainer(value:*):void {
_swfContainer = value;
}
public function get rootSwfContainer():* {
return _swfContainer;
}
public function set points(point:Point):* {
_point = point;
}
public function get points():* {
return _point;
}
public function zoomIN():void {
if((Number(_target.width - _swfContainer.width) <= 1000 ) || (Number(_target.height - _swfContainer.height ) <= 1000)) {
var xPos:Number = (_swfContainer.width/2)-(_target.width/2);
var yPos:Number = (_swfContainer.height/2)-(_target.height/2);
Tweener.addTween(_target, {x:xPos, y:yPos, scaleX: _target.scaleX * 1.25, scaleY: _target.scaleY * 1.25, transition: 'easeOut'});
repositionObject();
}
}
public function zoomOUT():void {
if((_target.width > 100) && (_target.height > 100)) {
var xPos:Number = (_swfContainer.width/2)-(_target.width/2);
var yPos:Number = (_swfContainer.height/2)-(_target.height/2);
Tweener.addTween(_target, {x:xPos, y:yPos,scaleX: _target.scaleX * .6, scaleY: _target.scaleY * .6, transition: 'easeOut'});
repositionObject();
}
}
public function repositionObject():void {
var tempXPos:Number = Number((_swfContainer.width/2)-(_target.width/2));
var tempYPos:Number = Number((_swfContainer.height/2)-(_target.height/2));
if(tempXPos <= 0) {
tempXPos = 0;
}
if(tempYPos <= 0) {
tempYPos = 0;
}
_target.x = tempXPos;
_target.y = tempYPos;
}
]]>
</mx:Script>
<!-- icon="@Embed(source='assets/buttonicon.png')" height="16"-->
<mx:Button label="Zoom In (+)" click="zoomIN()" />
<mx:Button label="Zoom Out (-)" click="zoomOUT()"/>