Funktion aus anderer Klasse Ausführen [Flash 11]
| Beiträge: 56 Wohnort: magdeburg Registriert: Jun 2004
| 25.11.2012, 11:25
Hallo,
Ja ich weiß Google hat da schon ein paar Beispiele, aber ich steig da irgendwie nicht durch.
Ich habe wie unten zu sehen zwei Klassen wobei Stadtplan der Mainswf und Movie die geladene
swf ist.
Da ich in Flash ein blutiger Anfänger bin habe ich mich eines Tools bedient welches "panning-tool-with-mini-browser-as3-xml" heißt.
Mittels Button möchte ich nun in der geladenen swf ein mc ausblenden.
Da mir der Fad nicht wirklich klar wird, laut dem Loader müsste es eigentlich mc sein, möchte ich das ganze über die Klassen regeln.
An diesem Punkt kommt Ihr nun ins Spiel. ;-)
Danke schon mal Für eventuelle Hilfe.
Mainswf:ActionScript:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | package com.oxylusflash
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import com.oxylusflash.Movie;
public class Stadtplan extends MovieClip
{
public var menue_mc:MovieClip;
public var baum1:MovieClip;
public var karte:MovieClip;
public function Stadtplan()
{
menue_mc.baum1.buttonMode = true;
menue_mc.baum1.addEventListener(MouseEvent.CLICK, b1);
//menue_mc.baum1.addEventListener(MouseEvent.CLICK, Movie.anzeige());
}
public function b1(e:MouseEvent)
{
//mcPanningMinibrowser.mcContainer.hier fehlt mir der pfad.karte.alpha = 0;
//Movie.anzeige(); -->hab mir gedacht das ich so auf die funktion in der klasse movie zugreifen kann
trace("hallo");
}
}
}
|
geladene swfActionScript:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | package com.oxylusflash
{
import flash.display.MovieClip;
public class Movie extends MovieClip
{
public var karte:MovieClip;
public function Movie()
{
karte.alpha = 1;
}
public function anzeige():void
{
karte.alpha = 0;
}
}
}
|
Das sind die drei Hauptklassen des Tools.
ActionScript:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | package com.oxylusflash
{
import fl.motion.Color;
import flash.display.*;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import com.caurina.transitions.Tweener;
import com.caurina.transitions.properties.*;
import com.oxylusflash.Panning;
/**
* ...
* @author Oxylus
*/
public class Navigation extends MovieClip
{
private static const transitionTime : Number = 0.5;
private static const transitionType : String = "easeOutExpo";
public var skin : Number = 2;
/**
* COMPONENTS INSIDE
*/
public var mcBack : MovieClip;
public var mcImage : MovieClip;
public var mcArea : MovieClip;
private var report : Number;
private var _componentWidth : Number;
private var _componentHeight : Number;
private var mcContainer : MovieClip;
private var currentPressedMovieClip : MovieClip;
private var movingX : Number;
private var movingY : Number;
private var delta : Number = -2;
private var _normalAreaFillTransparency : Number;
private var _normalAreaStrokeTransparency : Number;
private var _overAreaFillTransparency : Number;
private var _overAreaStrokeTransparency : Number;
public function Navigation() : void
{
ColorShortcuts.init();
}
/**
* initialize navigation
*/
public function init(bitmap : Bitmap, container : MovieClip, navigationBackgroundColor : Number, navigationAreaFillColor : Number, navigationAreaStrokeColor : Number, navigationAreaFillNormalTrasparency : Number, navigationAreaFillOverTrasparency : Number, navigationAreaStrokeNormalTrasparency : Number, navigationAreaStrokeOverTrasparency : Number) : void
{
_normalAreaFillTransparency = navigationAreaFillNormalTrasparency;
_normalAreaStrokeTransparency = navigationAreaStrokeNormalTrasparency;
_overAreaFillTransparency = navigationAreaFillOverTrasparency;
_overAreaStrokeTransparency = navigationAreaStrokeOverTrasparency;
mcContainer = container;
mcImage.addChild(bitmap);
resizeToFit(mcImage, mcBack.width - 4, mcBack.height - 4);
mcImage.x = Math.round(mcBack.x + (mcBack.width - mcImage.width) / 2);
mcImage.y = Math.round(mcBack.y + (mcBack.height - mcImage.height) / 2);
report = mcImage.width / _componentWidth;
mcArea.width = mcImage.width;
if (mcContainer.height < _componentHeight)
{
mcArea.height = mcImage.height + 1;
}
else
{
mcArea.height = (_componentHeight / mcContainer.height) * mcImage.height;
}
mcArea.x = mcImage.x;
mcArea.y = mcImage.y;
Panning.getInstance().setColor(mcBack, navigationBackgroundColor);
mcArea.mcFill.alpha = _normalAreaFillTransparency;
mcArea.mcStroke.alpha = _normalAreaStrokeTransparency;
Panning.getInstance().setColor(mcArea.mcFill, navigationAreaFillColor);
Panning.getInstance().setColor(mcArea.mcStroke, navigationAreaStrokeColor);
// add events for visible area
mcArea.buttonMode = true;
mcArea.addEventListener(MouseEvent.ROLL_OVER, overHandler);
mcArea.addEventListener(MouseEvent.ROLL_OUT, outHandler);
mcArea.addEventListener(MouseEvent.MOUSE_DOWN, pressHandler);
mcArea.addEventListener(MouseEvent.MOUSE_UP, releaseHandler);
}
/**
* set visible area size
*/
public function setArea(h : Number, w : Number) : void
{
if (mcContainer.height < _componentHeight)
{
Tweener.addTween(mcArea, { height : Math.round(mcImage.height), y : Math.round(mcImage.y), time : transitionTime, transition : transitionType } );
if (mcContainer.width < _componentWidth)
{
Tweener.addTween(mcArea, {width : Math.round(mcImage.width), x : Math.round(mcImage.x), time : transitionTime, transition : transitionType } );
}
else
{
Tweener.addTween(mcArea, {width : Math.round((_componentWidth / w) * mcImage.width), x : Math.round(mcImage.x + (mcImage.width - (_componentWidth / w) * mcImage.width)/2), time : transitionTime, transition : transitionType } );
}
}
else
{
Tweener.addTween(mcArea, {height : Math.round((_componentHeight / h) * mcImage.height), y : Math.round(mcImage.y + (mcImage.height - (_componentHeight / h) * mcImage.height)/2), time : transitionTime, transition : transitionType } );
if (mcContainer.width < _componentWidth)
{
Tweener.addTween(mcArea, {width : Math.round(mcImage.width), x : Math.round(mcImage.x), time : transitionTime, transition : transitionType } );
}
else
{
Tweener.addTween(mcArea, {width : Math.round((_componentWidth / w) * mcImage.width), x : Math.round(mcImage.x + (mcImage.width - (_componentWidth / w) * mcImage.width)/2), time : transitionTime, transition : transitionType } );
}
}
//mcArea.height = (_componentHeight / h) * mcImage.height;
//mcArea.width = (_componentHeight / h) * mcImage.width;
}
/**
* move visible area
*/
public function moveArea(xMove : Number, yMove : Number) : void
{
report = mcImage.height / mcContainer.height;
if (mcContainer.height > _componentHeight)
{
Tweener.addTween(mcArea, {y : Math.round(Math.abs(yMove) * report + mcImage.y), time : transitionTime, transition : transitionType } );
}
if (mcContainer.width > _componentWidth)
{
Tweener.addTween(mcArea, { x : Math.round(Math.abs(xMove) * report + mcImage.x), time : transitionTime, transition : transitionType } );
}
}
/**
*
* getter, setter for component width and height
*/
public function get componentWidth() : Number
{
return _componentWidth;
}
public function get componentHeight() : Number
{
return _componentHeight;
}
public function set componentWidth(no : Number) : void
{
_componentWidth = no;
}
public function set componentHeight(no : Number) : void
{
_componentHeight = no;
}
/**
* resize image to fill a rectangle
*/
public function resizeToFit(mc : MovieClip, width : Number, height : Number) : void
{
var largeWidth : Number = mc.width;
var largeHeight : Number = mc.height;
mc.width = width;
mc.height = int((width * largeHeight ) / largeWidth);
if (mc.height > height)
{
mc.height = height;
mc.width = int((height * largeWidth ) / largeHeight);
}
}
/*******************
* EVENT HANDLERS
*******************/
/**
*
* over handler
*/
private function overHandler(evt : MouseEvent) : void
{
var mc : MovieClip = evt.currentTarget as MovieClip;
if (mc == mcArea)
{
Tweener.addTween(mc.mcFill, { alpha : _overAreaFillTransparency, time : transitionTime, transition : transitionType } );
Tweener.addTween(mc.mcStroke, { alpha : _overAreaStrokeTransparency, time : transitionTime, transition : transitionType } );
}
}
/**
*
* over handler
*/
private function outHandler(evt : MouseEvent) : void
{
var mc : MovieClip = evt.currentTarget as MovieClip;
if (mc == mcArea)
{
Tweener.addTween(mc.mcFill, { alpha : _normalAreaFillTransparency, time : transitionTime, transition : transitionType } );
Tweener.addTween(mc.mcStroke, { alpha : _normalAreaStrokeTransparency, time : transitionTime, transition : transitionType } );
}
}
/**
*
* press handler
*/
private function pressHandler(evt : MouseEvent) : void
{
var mc : MovieClip = evt.currentTarget as MovieClip;
currentPressedMovieClip = mc;
switch(mc)
{
case mcArea :
var rectangle : Rectangle;
if (mcContainer.height < _componentHeight)
{
if (mcContainer.width < _componentWidth)
{
rectangle = new Rectangle(mcImage.x, mcImage.y, 0, 0);
}
else
{
rectangle = new Rectangle(mcImage.x, mcImage.y, mcImage.width - mcArea.width, 0);
}
}
else
{
if (mcContainer.width < _componentWidth)
{
rectangle = new Rectangle(mcImage.x, mcImage.y, 0, mcImage.height - mcArea.height);
}
else
{
rectangle = new Rectangle(mcImage.x, mcImage.y, mcImage.width - mcArea.width, mcImage.height - mcArea.height);
}
}
movingX = mcArea.x;
movingY = mcArea.y;
mcArea.startDrag(false, rectangle);
this.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
break;
}
}
/**
* release handler
*/
private function releaseHandler(evt : MouseEvent) : void
{
var mc : MovieClip = evt.currentTarget as MovieClip;
switch(mc)
{
case mcArea :
mcArea.stopDrag();
this.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
break;
}
}
/**
* mouse move handler
*/
private function onMouseMove(evt : MouseEvent) : void
{
Tweener.addTween(mcContainer, {x : (mcContainer.width / mcImage.width) * (-mcArea.x + mcImage.x), y : (mcContainer.height / mcImage.height) * (-mcArea.y + mcImage.y),time : transitionTime, transition : transitionType});
}
}
}
|
ActionScript:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 | package com.oxylusflash
{
import flash.display.*;
import com.stimuli.loading.BulkLoader;
import com.stimuli.loading.BulkProgressEvent;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.ErrorEvent;
import flash.geom.*;
import flash.ui.Mouse;
import com.caurina.transitions.Tweener;
import com.caurina.transitions.properties.*;
/**
* ...
* @author Oxylus
*/
public class Panning extends MovieClip
{
private var loader : BulkLoader;
private var xmlSettingsPath : String = "stadtplan.xml";
private var path : String;
private var settingsLoaded : Boolean = false;
private var fitPercent : Number;
private var initialContainerWidth : Number;
private var initialContainerHeight : Number;
private var thumbImageData : Bitmap;
private static const transitionTime : Number = 0.5;
private static const transitionType : String = "easeOutExpo";
private static const btnWidth : Number = 14;
private static const backSliderWidth : Number = 18;
private var tempFlashVar : *;
/**
* COMPONENTS INSIDE
*/
public var mcContainer : MovieClip;
public var mcSlider : MovieClip;
public var mcNavigation : MovieClip;
public var mcMask : MovieClip;
public var mcLoader : MovieClip;
public var mcHandCursor : MovieClip;
/**
* SETTINGS PARAMS
*/
private var componentWidth : Number;
private var componentHeight : Number;
private var sliderMargin : Number;
private var sliderAlign : String;
private var minimumZoom : String;
private var maximumZoom : String;
// skin one params
private var zoomText : String;
private var textBackgroundColor : Number;
private var sliderBackgroundColor : Number;
private var textColor : Number;
private var buttonNormalStateColor : Number;
private var buttonOverStateColor : Number;
private var sliderIconInactiveColor : Number;
private var sliderIconActiveColor : Number;
private var sliderShapeInactiveColor : Number;
private var sliderShapeActiveColor : Number;
private var iconColor : Number;
// skin two params
private var percentStrokeColor : Number;
private var percentFillColor : Number;
private var buttonStrokeColor : Number;
private var buttonFillColor : Number;
private var sliderBackFillColor : Number;
private var sliderBackStrokeColor : Number;
private var navigationBackgroundColor : Number;
private var navigationButtonBackgroundColor : Number;
private var navigationButtonNormalColor : Number;
private var navigationButtonOverColor : Number;
private var navigationAreaFillColor : Number;
private var navigationAreaStrokeColor : Number;
private var navigationAreaFillNormalTrasparency : Number;
private var navigationAreaFillOverTrasparency : Number;
private var navigationAreaStrokeNormalTrasparency : Number;
private var navigationAreaStrokeOverTrasparency : Number;
private static var instance : Panning;
public function Panning()
{
ColorShortcuts.init();
//trace("panning constructor");
// make components invisible
mcSlider.alpha = 0;
mcSlider.visible = false;
mcContainer.visible = false;
mcContainer.alpha = 0;
mcNavigation.visible = false;
mcNavigation.alpha = 0;
mcLoader.visible = false;
mcLoader.alpha = 0;
mcHandCursor.visible = false;
//initialize application
init();
}
/**
*
* singleton
*/
public static function getInstance() : Panning
{
if(instance == null)
{
instance = new Panning();
}
return instance;
}
/**
* initialize application
*/
public function init() : void
{
loadContent(xmlSettingsPath);
}
/**
* initWithParams
*/
public function initWithParams(settings : String) : void
{
xmlSettingsPath = settings;
loadContent(xmlSettingsPath);
}
/**
*
* loading content function(image or swf)
*/
private function loadContent(str : String) : void
{
path = str;
loader = new BulkLoader("panning content loader");
loader.addEventListener(BulkProgressEvent.COMPLETE, loadingComplete);
loader.addEventListener(BulkProgressEvent.PROGRESS, loadingProgress);
loader.addEventListener(ErrorEvent.ERROR, loadingError);
loader.add(str);
loader.start(1);
}
/**
*
* loader complete event
*/
private function loadingComplete(evt : BulkProgressEvent) : void
{
switch(findExtension(path))
{
case "xml" :
var settingsXML : XML = new XML(loader.getXML(xmlSettingsPath));
// settings params
componentWidth = int(settingsXML.size.attribute("width"));
componentHeight = int(settingsXML.size.attribute("height"));
// set mask dimension
mcMask.width = componentWidth;
mcMask.height = componentHeight;
// loader color
var loaderColor : Number = Number(settingsXML.loader.attribute("color"));
setColor(mcLoader, loaderColor);
sliderMargin = int(settingsXML.navigation.attribute("margin"));
sliderAlign = String(settingsXML.navigation.attribute("align")).toLowerCase();
zoomText = settingsXML.navigation.attribute("text");
minimumZoom = String(settingsXML.navigation.attribute("minimumZoom")).toLowerCase();
maximumZoom = String(settingsXML.navigation.attribute("maximumZoom")).toLowerCase();
// 1st skin
textBackgroundColor = Number(settingsXML.slider.attribute("textBackgroundColor"));
sliderBackgroundColor = Number(settingsXML.slider.attribute("sliderBackgroundColor"));
textColor = Number(settingsXML.slider.attribute("textColor"));
buttonNormalStateColor = Number(settingsXML.slider.attribute("buttonNormalStateColor"));
buttonOverStateColor = Number(settingsXML.slider.attribute("buttonOverStateColor"));
sliderIconInactiveColor = Number(settingsXML.slider.attribute("sliderIconInactiveColor"));
sliderIconActiveColor = Number(settingsXML.slider.attribute("sliderIconActiveColor"));
sliderShapeInactiveColor = Number(settingsXML.slider.attribute("sliderShapeInactiveColor"));
sliderShapeActiveColor = Number(settingsXML.slider.attribute("sliderShapeActiveColor"));
iconColor = Number(settingsXML.slider.attribute("iconColor"));
// 2nd skin
percentStrokeColor = Number(settingsXML.slider.attribute("percentBackgroundStrokeColor"));
percentFillColor = Number(settingsXML.slider.attribute("percentBackgroundFillColor"));
buttonStrokeColor = Number(settingsXML.slider.attribute("buttonBackgroundStrokeColor"));
buttonFillColor = Number(settingsXML.slider.attribute("buttonBackgroundFillColor"));
sliderBackFillColor = Number(settingsXML.slider.attribute("sliderBackgroundFillColor"));
sliderBackStrokeColor = Number(settingsXML.slider.attribute("sliderBackgroundStrokeColor"));
navigationBackgroundColor = Number(settingsXML.panning.attribute("backgroundColor"));
navigationButtonBackgroundColor = Number(settingsXML.panning.attribute("buttonBackgroundColor"));
navigationButtonNormalColor = Number(settingsXML.panning.attribute("buttonNormalStateColor"));
navigationButtonOverColor = Number(settingsXML.panning.attribute("buttonOverStateColor"));
navigationAreaFillColor = Number(settingsXML.panning.attribute("movingAreaFillColor"));
navigationAreaStrokeColor = Number(settingsXML.panning.attribute("movingAreaStrokeColor"));
navigationAreaFillNormalTrasparency = Number(settingsXML.panning.attribute("movingAreaFillNormalTransparency"));
navigationAreaFillOverTrasparency = Number(settingsXML.panning.attribute("movingAreaFillOverTransparency"));
navigationAreaStrokeNormalTrasparency = Number(settingsXML.panning.attribute("movingAreaStrokeNormalTrasparency"));
navigationAreaStrokeOverTrasparency = Number(settingsXML.panning.attribute("movingAreaStrokeOverTrasparency"));
clearLoader(loader);
// show loader
mcLoader.visible = true;
mcLoader.alpha = 1;
mcLoader.x = Math.round((componentWidth - mcLoader.width) / 2);
mcLoader.y = Math.round((componentHeight - mcLoader.height) / 2);
var contentFile : String = String(settingsXML.source);
loadContent(contentFile);
break;
case "swf" :
var mc : MovieClip = new MovieClip();
mc.addChild(loader.getMovieClip(path));
mcContainer.addChild(mc);
var bitmapData : BitmapData = new BitmapData(mcContainer.width, mcContainer.height);
thumbImageData = new Bitmap(bitmapData);
thumbImageData.smoothing = true;
bitmapData.draw(mc);
resizeToFit(mcContainer, componentWidth, componentHeight);
clearLoader(loader);
// arrange and show elements on the stage
alignComponents();
break;
case "jpg" :
var bitmap : Bitmap = new Bitmap(loader.getBitmapData(path));
bitmap.cacheAsBitmap = true;
bitmap.smoothing = true;
mcContainer.addChild(bitmap);
// duplicate bitmap for the navigation thumb
thumbImageData = new Bitmap(bitmap.bitmapData.clone());
thumbImageData.smoothing = true;
resizeToFit(mcContainer, componentWidth, componentHeight);
clearLoader(loader);
// arrange and show elements on the stage
alignComponents();
break;
}
}
/**
*
* loader progress event
*/
private function loadingProgress(evt : BulkProgressEvent) : void
{
}
/**
* loader error event
*/
private function loadingError(evt : ErrorEvent) : void
{
trace("loading error");
}
/**
*
* show components on the stage
*/
private function alignComponents() : void
{
// remove loader
Tweener.addTween(mcLoader, { alpha : 0, time : transitionTime, transition : transitionType, onComplete : function() : void
{
mcLoader.visible = false;
removeChild(mcLoader);
}} );
// initialize navigation
mcNavigation.componentWidth = componentWidth;
mcNavigation.componentHeight = componentHeight;
if (mcNavigation.skin == 1)
{
mcNavigation.init(thumbImageData, mcContainer, navigationBackgroundColor, navigationButtonBackgroundColor, navigationButtonNormalColor, navigationButtonOverColor, navigationAreaFillColor, navigationAreaStrokeColor, navigationAreaFillNormalTrasparency, navigationAreaFillOverTrasparency, navigationAreaStrokeNormalTrasparency, navigationAreaStrokeOverTrasparency);
}
else
{
mcNavigation.init(thumbImageData, mcContainer, navigationBackgroundColor, navigationAreaFillColor, navigationAreaStrokeColor, navigationAreaFillNormalTrasparency, navigationAreaFillOverTrasparency, navigationAreaStrokeNormalTrasparency, navigationAreaStrokeOverTrasparency);
}
// initialize slider
mcSlider.componentWidth = componentWidth;
mcSlider.componentHeight = componentHeight;
if (mcSlider.skin == 1)
{
mcSlider.init(zoomText, fitPercent, mcContainer, initialContainerWidth, initialContainerHeight, mcNavigation, textBackgroundColor, sliderBackgroundColor, textColor, buttonNormalStateColor, buttonOverStateColor, sliderIconInactiveColor, sliderIconActiveColor, sliderShapeInactiveColor, sliderShapeActiveColor, iconColor, minimumZoom, maximumZoom);
}
else
{
mcSlider.componentAlign = sliderAlign;
mcSlider.componentMargin = sliderMargin;
mcSlider.init(fitPercent, mcContainer, initialContainerWidth, initialContainerHeight, mcNavigation, textColor, buttonNormalStateColor, buttonOverStateColor, sliderIconInactiveColor, sliderIconActiveColor, sliderShapeInactiveColor, sliderShapeActiveColor, percentStrokeColor, percentFillColor, buttonStrokeColor, buttonFillColor, sliderBackFillColor, sliderBackStrokeColor, minimumZoom, maximumZoom);
}
mcContainer.addEventListener(MouseEvent.MOUSE_DOWN, pressHandler);
mcContainer.addEventListener(MouseEvent.MOUSE_UP, releaseHandler);
//mcContainer.addEventListener(MouseEvent.ROLL_OVER, overHandler);
//mcContainer.addEventListener(MouseEvent.ROLL_OUT, outHandler);
switch(sliderAlign)
{
case "tl" :
mcNavigation.x = sliderMargin;
mcNavigation.y = sliderMargin;
break;
case "tr" :
mcNavigation.x = Math.round(componentWidth - sliderMargin - mcNavigation.width);
mcNavigation.y = sliderMargin;
break;
case "br" :
mcNavigation.x = Math.round(componentWidth - sliderMargin - mcNavigation.width);
mcNavigation.y = Math.round(componentHeight - mcNavigation.height - 2 * sliderMargin - mcSlider.height);
break;
case "bl" :
mcNavigation.x = sliderMargin;
mcNavigation.y = Math.round(componentHeight - mcNavigation.height - 2 * sliderMargin - mcSlider.height);
break;
}
if (mcNavigation.skin == 1)
{
mcSlider.x = Math.round(mcNavigation.x + btnWidth);
}
else
{
if (sliderAlign == "tl" || sliderAlign == "bl")
{
mcSlider.x = mcNavigation.x;
}
else
{
mcSlider.x = Math.round(mcNavigation.x + mcNavigation.width - backSliderWidth);
}
}
mcSlider.y = Math.round(mcNavigation.y + mcNavigation.height + sliderMargin);
// show slider
mcSlider.visible = true;
Tweener.addTween(mcSlider, { alpha : 1, time : transitionTime, transition : transitionType } );
// show container
mcContainer.visible = true;
Tweener.addTween(mcContainer, { alpha : 1, time : transitionTime, transition : transitionType } );
// show navigation
mcNavigation.visible = true;
Tweener.addTween(mcNavigation, { alpha : 1, time : transitionTime, transition : transitionType } );
}
/**
*
* clear loader function
*/
private function clearLoader(loader : BulkLoader) : void
{
loader.removeEventListener(BulkProgressEvent.COMPLETE, loadingComplete);
loader.removeEventListener(BulkProgressEvent.PROGRESS, loadingProgress);
loader.clear();
}
/**
*
* find extension of a file
*/
private function findExtension(str : String) : String
{
return String(str.split(".")[1]).toLowerCase();
}
/**
* resize image to fit in a rectangle
*/
public function resizeToFit(mc : MovieClip, width : Number, height : Number) : void
{
var largeWidth : Number = mc.width;
var largeHeight : Number = mc.height;
initialContainerWidth = largeWidth;
initialContainerHeight = largeHeight;
/*if (largeWidth < componentWidth)
{
mc.x = Math.round((componentWidth - largeWidth) / 2);
if (largeHeight < componentHeight)
{
mc.y = Math.round((componentHeight - largeHeight) / 2);
}
else
{
if (mc.height < height)
{
mc.height = height;
mc.width = int((height * largeWidth ) / largeHeight);
}
}
}
else
{
mc.x = Math.round((componentWidth - largeWidth) / 2);
if (largeHeight < componentHeight)
{
mc.y = Math.round((componentHeight - largeHeight) / 2);
}
else
{
mc.width = width;
mc.height = int((width * largeHeight ) / largeWidth);
if (mc.height < height)
{
mc.height = height;
mc.width = int((height * largeWidth ) / largeHeight);
}
}
}*/
// set initial zoom
if (minimumZoom == "auto")
{
fitPercent = (width / largeWidth ) * 100;
}
else
{
fitPercent = Number(minimumZoom) * 100;
}
mc.width = int((fitPercent / 100) * largeWidth);
mc.height = int((fitPercent / 100) * largeHeight);
mc.x = Math.round((componentWidth - mc.width) / 2);
mc.y = Math.round((componentHeight - mc.height) / 2);
}
/**
* set the movie clip color
*/
public function setColor(mc : MovieClip, color : Number) : void
{
var colorTransform : ColorTransform = mc.transform.colorTransform;
colorTransform.color = color;
mc.transform.colorTransform = colorTransform;
}
/****************
* HANDLERS
**************/
/**
* press handler
*/
private function pressHandler(evt : MouseEvent) : void
{
var mc : MovieClip = evt.currentTarget as MovieClip;
if (mcSlider.inAnimation == false)
{
if (mcContainer.width > componentWidth || mcContainer.height > componentHeight)
{
// hide mouse, show hand cursor
Mouse.hide();
// unable the components events
mcHandCursor.mouseChildren = false;
mcHandCursor.mouseEnabled = false;
mcNavigation.mouseEnabled = false;
mcNavigation.mouseChildren = false;
mcSlider.mouseChildren = false;
mcSlider.mouseEnabled = false;
mcHandCursor.x = mouseX;
mcHandCursor.y = mouseY;
mcHandCursor.visible = true;
mcHandCursor.gotoAndPlay(2);
var rectangle : Rectangle;
if (mcContainer.width < componentWidth)
{
rectangle = new Rectangle((componentWidth - mcContainer.width)/2, componentHeight - mcContainer.height, 0, mcContainer.height - componentHeight);
}
else
{
if (mcContainer.height < componentHeight)
{
rectangle = new Rectangle(componentWidth - mcContainer.width, (componentHeight - mcContainer.height)/2, mcContainer.width - componentWidth, 0);
}
else
{
rectangle = new Rectangle(componentWidth - mcContainer.width, componentHeight - mcContainer.height, mcContainer.width - componentWidth, mcContainer.height - componentHeight);
}
}
mc.startDrag(false, rectangle);
this.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
stage.addEventListener(Event.MOUSE_LEAVE, onMouseLeave);
}
}
}
/**
* release handler
*/
private function releaseHandler(evt : MouseEvent) : void
{
var mc : MovieClip = evt.currentTarget as MovieClip;
//mc.buttonMode = false;
releaseFunction(mc);
}
private function releaseFunction(mc : MovieClip) : void
{
// reenable the components events
mcNavigation.mouseEnabled = true;
mcNavigation.mouseChildren = true;
mcSlider.mouseChildren = true;
mcSlider.mouseEnabled = true;
// hide hand cursor and show mouse
mcHandCursor.visible = false;
mcHandCursor.gotoAndStop(1);
Mouse.show();
mc.stopDrag();
this.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
}
/**
* on mouse move event
*/
private function onMouseMove(evt : MouseEvent) : void
{
mcHandCursor.x = mouseX;
mcHandCursor.y = mouseY;
mcNavigation.moveArea(mcContainer.x, mcContainer.y);
}
/**
* on mouse leave the stage event
*/
private function onMouseLeave(evt : Event) : void
{
releaseFunction(mcContainer);
}
}
}
|
ActionScript:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | package com.oxylusflash
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.*;
import flash.geom.Rectangle;
import flash.utils.setTimeout;
import flash.utils.clearTimeout;
// import tweener
import com.caurina.transitions.Tweener;
import com.caurina.transitions.properties.*;
import com.oxylusflash.Panning;
/**
* ...
* @author Oxylus
*/
public class Slider extends MovieClip
{
private static const transitionTime : Number = 0.5;
private static const transitionType : String = "easeOutExpo";
public var skin : Number = 2;
private var plusPressed : Boolean;
public var inAnimation : Boolean = false;
private var timeout : Number;
private var currentPressedMovieClip : MovieClip;
private var mcContainer : MovieClip;
private var mcNavigation : MovieClip;
private var minimumLimitZoom : Number;
private var maximumLimitZoom : Number;
private var currentPercent : Number;
private var maximumWidth : Number;
private var maximumHeight : Number;
private var _componentWidth : Number;
private var _componentHeight : Number;
private var _componentAlign : String;
private var _componentMargin : Number;
private var _iconActiveColor : Number;
private var _iconInactiveColor : Number;
private var _buttonNormalColor : Number;
private var _buttonOverColor : Number;
private var _minimumZoom : String;
private var _maximumZoom : String;
/**
* COMPONENT INSIDE
*/
public var mcZoomBack : MovieClip;
public var mcSliderBack : MovieClip;
public var mcZoomPercent : MovieClip;
public var mcMinusBt : MovieClip;
public var mcPlusBt : MovieClip;
public var mcSlider : MovieClip;
public function Slider() : void
{
ColorShortcuts.init();
mcZoomPercent.mcText.txt.embedFonts = true;
mcZoomPercent.mcText.txt.autoSize = TextFieldAutoSize.LEFT;
mcZoomPercent.visible = false;
mcZoomPercent.alpha = 0;
}
/**
* initialize slider
*/
public function init(initialPercent : Number, container : MovieClip, initialWidth : Number, initialHeight : Number, navigation : MovieClip, textColor : Number, buttonNormalStateColor : Number, buttonOverStateColor : Number, sliderIconInactiveColor : Number, sliderIconActiveColor : Number, sliderShapeInactiveColor : Number, sliderShapeActiveColor : Number, percentStrokeColor : Number, percentFillColor : Number, buttonStrokeColor : Number, buttonFillColor : Number, sliderBackFillColor : Number, sliderBackStrokeColor : Number, minZoom : String, maxZoom : String) : void
{
_minimumZoom = minZoom;
_maximumZoom = maxZoom;
mcNavigation = navigation;
mcContainer = container;
minimumLimitZoom = initialPercent;
maximumLimitZoom = Number(_maximumZoom) * 100;
currentPercent = initialPercent;
maximumWidth = initialWidth;
maximumHeight = initialHeight;
_iconActiveColor = sliderIconActiveColor;
_iconInactiveColor = sliderIconInactiveColor;
_buttonNormalColor = buttonNormalStateColor;
_buttonOverColor = buttonOverStateColor;
Panning.getInstance().setColor(mcZoomBack.mcStroke, sliderBackStrokeColor);
Panning.getInstance().setColor(mcZoomBack.mcFill, sliderBackFillColor);
Panning.getInstance().setColor(mcPlusBt.mcStroke, buttonStrokeColor);
Panning.getInstance().setColor(mcPlusBt.mcFill, buttonFillColor);
Panning.getInstance().setColor(mcMinusBt.mcStroke, buttonStrokeColor);
Panning.getInstance().setColor(mcMinusBt.mcFill, buttonFillColor);
Panning.getInstance().setColor(mcSlider.mcSliderShape, sliderShapeInactiveColor);
Panning.getInstance().setColor(mcSlider.mcSliderValue, sliderShapeActiveColor);
Panning.getInstance().setColor(mcPlusBt.mcIcon, _buttonNormalColor);
Panning.getInstance().setColor(mcMinusBt.mcIcon, _buttonNormalColor);
Panning.getInstance().setColor(mcSlider.mcSliderIcon, sliderIconInactiveColor);
// mouse wheel event for container
mcContainer.addEventListener(MouseEvent.MOUSE_WHEEL, mouseWheel);
updateComponents(initialPercent);
Panning.getInstance().setColor(mcZoomPercent.mcText, textColor);
Panning.getInstance().setColor(mcZoomPercent.mcFill, percentFillColor);
Panning.getInstance().setColor(mcZoomPercent.mcStroke, percentStrokeColor);
Panning.getInstance().setColor(mcSlider.mcSliderIcon, _iconInactiveColor);
mcMinusBt.buttonMode = true;
mcPlusBt.buttonMode = true;
mcSlider.mcSliderBt.buttonMode = true;
// add events for buttons
mcMinusBt.addEventListener(MouseEvent.MOUSE_DOWN, pressHandler);
mcMinusBt.addEventListener(MouseEvent.MOUSE_UP, releaseHandler);
mcMinusBt.addEventListener(MouseEvent.ROLL_OUT, outHandler);
mcMinusBt.addEventListener(MouseEvent.ROLL_OVER, overHandler);
mcPlusBt.addEventListener(MouseEvent.MOUSE_DOWN, pressHandler);
mcPlusBt.addEventListener(MouseEvent.MOUSE_UP, releaseHandler);
mcPlusBt.addEventListener(MouseEvent.ROLL_OUT, outHandler);
mcPlusBt.addEventListener(MouseEvent.ROLL_OVER, overHandler);
mcSlider.mcSliderBt.addEventListener(MouseEvent.MOUSE_DOWN, pressHandler);
mcSlider.mcSliderBt.addEventListener(MouseEvent.MOUSE_UP, releaseHandler);
mcSlider.mcSliderBt.addEventListener(MouseEvent.ROLL_OUT, outHandler);
mcSlider.mcSliderBt.addEventListener(MouseEvent.ROLL_OVER, overHandler);
mcSlider.mcSliderIcon.buttonMode = true;
mcSlider.mcSliderIcon.addEventListener(MouseEvent.MOUSE_DOWN, pressHandler);
mcSlider.mcSliderIcon.addEventListener(MouseEvent.MOUSE_UP, releaseHandler);
mcSlider.mcSliderIcon.addEventListener(MouseEvent.ROLL_OUT, outHandler);
mcSlider.mcSliderIcon.addEventListener(MouseEvent.ROLL_OVER, overHandler);
// arrange percent text value
setPercentPosition(_componentAlign);
//stage.addEventListener(Event.MOUSE_LEAVE, onMouseLeave);
}
/**
* set position of percent text
*/
private function setPercentPosition(_componentAlign) : void
{
switch(_componentAlign)
{
case "tl" :
mcZoomPercent.x = Math.round(mcZoomBack.x + mcZoomBack.width + 2);
break;
case "bl" :
mcZoomPercent.x = Math.round(mcZoomBack.x + mcZoomBack.width + 2);
break;
case "br" :
mcZoomPercent.x = Math.round(mcZoomBack.x - mcZoomPercent.width - 2);
break;
case "tr" :
mcZoomPercent.x = Math.round(mcZoomBack.x - mcZoomPercent.width - 2);
break;
}
}
/**
*
* getter, setter for component width and height
*/
public function get componentWidth() : Number
{
return _componentWidth;
}
public function get componentHeight() : Number
{
return _componentHeight;
}
public function set componentWidth(no : Number) : void
{
_componentWidth = no;
}
public function set componentHeight(no : Number) : void
{
_componentHeight = no;
}
public function set componentAlign(str : String) : void
{
_componentAlign = str;
}
public function get componentAlign() : String
{
return _componentAlign;
}
public function set componentMargin(no : Number) : void
{
_componentMargin = no;
}
public function get componentMargin() : Number
{
return _componentMargin;
}
/**********************
* EVENT HANDLERS
*********************/
/**
* over handler
*/
private function overHandler(evt : MouseEvent) : void
{
var mc : MovieClip = evt.currentTarget as MovieClip;
switch(mc)
{
case mcSlider.mcSliderShape :
Tweener.addTween(mcSlider.mcSliderIcon, { _color : _iconActiveColor, time : transitionTime , transition : transitionType } );
break;
case mcMinusBt :
Tweener.addTween(mc.mcIcon, { _color : _buttonOverColor, time : transitionTime , transition : transitionType } );
break;
case mcPlusBt :
Tweener.addTween(mc.mcIcon, { _color : _buttonOverColor, time : transitionTime , transition : transitionType } );
break;
case mcSlider.mcSliderIcon :
mcZoomPercent.visible = true;
Tweener.addTween(mcZoomPercent, { alpha : 1, time : transitionTime , transition : transitionType } );
Tweener.addTween(mc, { _color : _iconActiveColor, time : transitionTime , transition : transitionType } );
break;
}
}
/**
* out handler
*/
private function outHandler(evt : MouseEvent) : void
{
var mc : MovieClip = evt.currentTarget as MovieClip;
switch(mc)
{
case mcSlider.mcSliderShape :
Tweener.addTween(mcSlider.mcSliderIcon, { _color : _iconInactiveColor, time : transitionTime , transition : transitionType } );
break;
case mcMinusBt :
Tweener.addTween(mc.mcIcon, { _color : _buttonNormalColor, time : transitionTime , transition : transitionType } );
break;
case mcPlusBt :
Tweener.addTween(mc.mcIcon, { _color : _buttonNormalColor, time : transitionTime , transition : transitionType } );
break;
case mcSlider.mcSliderIcon :
Tweener.addTween(mcZoomPercent, { alpha : 0, time : transitionTime , transition : transitionType, onComplete : function() : void
{
mcZoomPercent.visible = false;
}} );
Tweener.addTween(mc, { _color : _iconInactiveColor, time : transitionTime , transition : transitionType } );
break;
}
}
/**
* press handler
*/
private function pressHandler(evt : MouseEvent) : void
{
var mc : MovieClip = evt.currentTarget as MovieClip;
currentPressedMovieClip = mc;
switch(mc)
{
case mcMinusBt :
if (currentPercent > minimumLimitZoom)
{
plusPressed = false;
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
break;
case mcPlusBt :
if (currentPercent < maximumLimitZoom)
{
plusPressed = true;
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
break;
case mcSlider.mcSliderIcon :
var staticMaskH : Number = 0;
var staticMaskY : Number = Math.round(mcSlider.mcSliderShape.y + mcSlider.mcSliderShape.height - staticMaskH);
var rectangle : Rectangle = new Rectangle(mcSlider.mcSliderIcon.x, Math.round(mcSlider.mcSliderValue.y - mcSlider.mcSliderIcon.height / 2), 0, Math.round(staticMaskY - mcSlider.mcSliderIcon.height / 2));
mcSlider.mcSliderIcon.startDrag(false, rectangle);
mcSlider.mcSliderBt.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
mcSlider.mcSliderBt.stage.addEventListener(MouseEvent.MOUSE_UP, releaseHandler);
break;
case mcSlider.mcSliderBt :
currentPercent = Math.round(((mcSlider.mcSliderBt.height - mcSlider.mouseY) / mcSlider.mcSliderBt.height) * (maximumLimitZoom - minimumLimitZoom) + minimumLimitZoom);
if (currentPercent < minimumLimitZoom)
{
currentPercent = minimumLimitZoom;
}
updateComponents(currentPercent);
break;
}
}
/**
* release handler
*/
private function releaseHandler(evt : MouseEvent) : void
{
var mc : MovieClip = evt.currentTarget as MovieClip;
this.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
if (currentPressedMovieClip == mcSlider.mcSliderIcon)
{
//updateComponents(currentPercent);
mcSlider.mcSliderBt.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
mcSlider.mcSliderIcon.stopDrag();
}
}
/**
* enter frame event
*/
private function onEnterFrame(evt : Event) : void
{
if (plusPressed == true)
{
if (currentPercent < maximumLimitZoom)
{
currentPercent++;
Tweener.addTween(mcContainer, {width : (currentPercent / 100 ) * maximumWidth, height : (currentPercent / 100 ) * maximumHeight, x : Math.round((componentWidth - (currentPercent / 100 ) * maximumWidth)/2), y : Math.round((componentHeight - (currentPercent / 100 ) * maximumHeight)/2),time : transitionTime, transition : transitionType} );
}
else
{
this.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
}
else
{
if (currentPercent > minimumLimitZoom)
{
currentPercent--;
Tweener.addTween(mcContainer, {width : (currentPercent / 100 ) * maximumWidth, height : (currentPercent / 100 ) * maximumHeight, x : Math.round((componentWidth - (currentPercent / 100 ) * maximumWidth)/2), y : Math.round((componentHeight - (currentPercent / 100 ) * maximumHeight)/2), time : transitionTime, transition : transitionType} );
}
else
{
this.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
}
updateComponents(currentPercent);
}
/**
* mouse wheel event
*/
public function mouseWheel(evt : MouseEvent) : void
{
if (evt.delta < 0)
{
if (currentPercent >= minimumLimitZoom)
{
currentPercent += evt.delta;
if (currentPercent < minimumLimitZoom)
{
currentPercent = minimumLimitZoom;
}
}
}
else
{
if (currentPercent <= maximumLimitZoom)
{
currentPercent += evt.delta;
if (currentPercent > maximumLimitZoom)
{
currentPercent = maximumLimitZoom;
}
}
}
updateComponents(currentPercent);
}
/**
* on mouse move event
*/
private function mouseMove(evt : MouseEvent) : void
{
//mcSlider.mcSliderIcon.stop();
// currentPercent = ((mcSlider.mcSliderBt.height - (mcSlider.mcSliderIcon.y + mcSlider.mcSliderIcon.height / 2)) / mcSlider.mcSliderBt.height) * 100;
//updateComponents(currentPercent);
currentPercent = Math.round(((mcSlider.mcSliderBt.height - mcSlider.mouseY) / mcSlider.mcSliderBt.height) * (maximumLimitZoom - minimumLimitZoom) + minimumLimitZoom);
if(currentPercent >= minimumLimitZoom && currentPercent <= maximumLimitZoom)
{
updateComponents(currentPercent);
}
}
private function onMouseLeave(evt : Event) : void
{
mcSlider.mcSliderIcon.stopDrag();
updateComponents(currentPercent);
this.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
}
/**
* update components
*/
private function updateComponents(percent : Number) : void
{
if (currentPercent >= maximumLimitZoom)
{
currentPercent = maximumLimitZoom;
}
else
{
if (currentPercent <= minimumLimitZoom)
{
currentPercent = minimumLimitZoom;
}
}
setAnimation(true);
mcZoomPercent.mcText.txt.htmlText = String(Math.round(currentPercent)) + "%";
mcZoomPercent.mcText.x = Math.round((mcZoomPercent.mcStroke.width - mcZoomPercent.mcText.width)/2);
var maskH : Number = Math.round(((currentPercent - minimumLimitZoom)/ (maximumLimitZoom - minimumLimitZoom)) * mcSlider.mcSliderValue.height);
var maskY : Number = Math.round(mcSlider.mcSliderShape.y + mcSlider.mcSliderShape.height - maskH);
Tweener.addTween(mcSlider.mcMask, {height : maskH, y : maskY , time : transitionTime, transition : transitionType } );
Tweener.addTween(mcSlider.mcSliderIcon, { y : Math.round(maskY - mcSlider.mcSliderIcon.height / 2), time : transitionTime, transition : transitionType } );
Tweener.addTween(mcZoomPercent, { y : Math.round(maskY - mcZoomPercent.mcStroke.height / 2 + mcSlider.y), time : transitionTime, transition : transitionType } );
Tweener.addTween(mcContainer, { width : (currentPercent / 100 ) * maximumWidth, height : (currentPercent / 100 ) * maximumHeight, x : Math.round((componentWidth - (currentPercent / 100 ) * maximumWidth) / 2), y : Math.round((componentHeight - (currentPercent / 100 ) * maximumHeight) / 2), time : transitionTime, transition : transitionType } );
mcNavigation.setArea((currentPercent / 100 ) * maximumHeight, (currentPercent / 100 ) * maximumWidth);
timeout = setTimeout(setAnimation, transitionTime, false);
}
/**
* set animation to false
*/
private function setAnimation(val : Boolean) : void
{
inAnimation = val;
clearTimeout(timeout);
}
}
}
|
| | | Beiträge: 56 Wohnort: magdeburg Registriert: Jun 2004
Themenautor/in
| 29.11.2012, 09:20
Habs selber raus bekommen, hier die Lösung wenn es wer brachen kann.
MainSWF
ActionScript:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | package com.oxylusflash
{
import com.oxylusflash.*;
import flash.display.*;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.ErrorEvent;
public class Stadtplan extends MovieClip
{
public var menue_mc:MovieClip;
public var mcContainer:MovieClip;
public var plan_o : MovieClip;
public var meineKarte:Karte = new Karte;
public function Stadtplan():void
{
menue_mc.btn_1.buttonMode = true;
menue_mc.btn_1.addEventListener(MouseEvent.CLICK, b_1);
menue_mc.btn_2.buttonMode = true;
menue_mc.btn_2.addEventListener(MouseEvent.CLICK, b_2);
menue_mc.btn_3.buttonMode = true;
menue_mc.btn_3.addEventListener(MouseEvent.CLICK, b_3);
menue_mc.btn_4.buttonMode = true;
menue_mc.btn_4.addEventListener(MouseEvent.CLICK, b_4);
menue_mc.btn_5.buttonMode = true;
menue_mc.btn_5.addEventListener(MouseEvent.CLICK, b_5);
menue_mc.btn_6.buttonMode = true;
menue_mc.btn_6.addEventListener(MouseEvent.CLICK, b_6);
}
public function b_1(e:MouseEvent):void
{
meineKarte.anzeige_1();
}
public function b_2(e:MouseEvent):void
{
meineKarte.anzeige_2();
}
public function b_3(e:MouseEvent):void
{
meineKarte.anzeige_3();
}
public function b_4(e:MouseEvent):void
{
meineKarte.anzeige_4();
}
public function b_5(e:MouseEvent):void
{
meineKarte.anzeige_5();
}
public function b_6(e:MouseEvent):void
{
meineKarte.anzeige_6();
}
}
}
|
geladene SWF
ActionScript:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | package com.oxylusflash
{
import flash.display.*;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.ErrorEvent;
import flash.geom.*;
import flash.ui.Mouse;
import com.oxylusflash.Stadtplan;
public class Karte extends MovieClip
{
private var tempFlashVar:*;
public var plan_o:MovieClip = new MovieClip ;
public function Karte()
{
plan_o.alpha = 0;
plan_o.val = 0;
}
public function anzeige_1():void
{
trace("Singnal 1 angekommen");
if (plan_o.alpha == 0)
{
plan_o.alpha = 1;
plan_o.val = 1;
}
else
{
plan_o.alpha = 0;
plan_o.val = 0;
}
}
public function anzeige_2():void
{
trace("Singnal 2 angekommen");
}
public function anzeige_3():void
{
trace("Singnal 3 angekommen");
}
public function anzeige_4():void
{
trace("Singnal 4 angekommen");
}
public function anzeige_5():void
{
trace("Singnal 5 angekommen");
}
public function anzeige_6():void
{
trace("Singnal 6 angekommen");
}
}
}
|
leider wir nur das trace ausgegeben vieleicht kann mir ja jemand sagen worann es liegt.
Da man aber in diesem Forum keine Anwort bekommt rechne ich damit mal nicht. | Geändert von andy1301 am 29.11.12 um 09:25 Uhr | |
|
| Ähnliche Beiträge zum Thema | |
|
Flashhilfe.de Flash Platform Tipps & Tutorials Flash Platform Andere Programmiersprachen Jobangebote Diskussionen
Flashhilfe News
Regeln & Bedingungen
|