Zurück   Flashforum > Flash > ActionScript > ActionScript 2

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 01-09-2007, 21:30   #1 (permalink)
i ate pixels
 
Benutzerbild von pixelslave
 
Registriert seit: Mar 2004
Ort: Augsburg
Beiträge: 526
Question dispatch Problem

hi

habe mit den dispatchern ein problem. hab mir schon viele tutorials durchgelesen usw. klappt aber alles noch nicht wie ich will.

ich hab ne kleine alertbox class geschrieben da mir die alerts von flash du umständlich zu skinnen sind. problem liegt in zeile 65

hier die class

Code:
import flash.filters.DropShadowFilter
import mx.events.EventDispatcher  

class as.vorbilder.alertbox extends mx.core.UIComponent {
	
	//var titleText:String;
	//var copyText:String;
	
	function dispatchEvent() {
		};
 	function addEventListener() {
		};
 	function removeEventListener() {
		};	
	
	function alertbox() {
		
		mx.events.EventDispatcher.initialize(this);
		
	}
	
	function callAlertBox(copyText:String,titleText:String) {
		
		/// Events
			
			var myThis = this
					
		/// create empty movieclip for the alertbox
			var mc:MovieClip = _root.createEmptyMovieClip("alertbox", _root.getNextHighestDepth());
			
		/// attach bg image
			mc.attachMovie("alertbox_bg", "bg", 1)
			with (mc.bg) {
				_x -= _width / 2
				_y -= _height / 2
			}
		
		/// attach close Button
			mc.bg.attachMovie("alertbox_closeButton", "closeButton", 2)
			
		/// attach main button
			mc.bg.attachMovie("alertbox_mainButton", "mainButton", 3)
			
		/// create title
			mc.bg.createTextField("title", 4, 0, 0, 200, 50)
			
		/// create copytext
			mc.bg.createTextField("copy", 5, 0, 0, 200, 50)
		
		/// adjusting position of alertbox
			mc._x						= Stage.width / 2
			mc._y						= Stage.height / 2
			
		/// adjust position of closebutton
			mc.bg.mainButton._x			= 162
			mc.bg.mainButton._y			= 86
			
		/// adjust position of mainbutton
			mc.bg.closeButton._x			= mc.bg._width - 46
			mc.bg.closeButton._y			= -12
			
		/// mainbutton click			
			mc.bg.mainButton.onPress			= function() {
				this.gotoAndStop(2)
				dispatchEvent({type:"closeAlert", target:this})
						
			}

			mc.bg.mainButton.onRelease			= function() {
				this.gotoAndStop(1)
						
			}
			
			mc.bg.mainButton.onReleaseOutside	= function() {
				this.gotoAndStop(1)
				
			}
			
			
			
		/// mainbutton actions
			
			
		/// set text&style of title
			mc.bg.title.text				= titleText
			mc.bg.title.antiAliasType 		= "advanced"
			mc.bg.title.sharpness			= 50
			mc.bg.title.border 				= false
			mc.bg.title.embedFonts 			= true
			mc.bg.title.selectable			= false
			mc.bg.title.autoSize			= true

			var titleFormat:TextFormat 		= new TextFormat()
				titleFormat.font			= "Georgia"
				titleFormat.size			= 19
				titleFormat.color			= 0xc72f0a
		
			mc.bg.title.setTextFormat(titleFormat)
		
		/// adjust position of title
			mc.bg.title._x					= 15
			mc.bg.title._y					= 14
			
		/// set text&style of copytext
			mc.bg.copy.text				= copyText
			mc.bg.copy.antiAliasType 		= "advanced"
			mc.bg.copy.sharpness			= -50
			mc.bg.copy.border 				= false
			mc.bg.copy.embedFonts 			= true
			mc.bg.copy.selectable			= false
			mc.bg.copy.autoSize			= true
			
			var copyFormat:TextFormat 	= new TextFormat()
				copyFormat.font			= "Georgia"
				copyFormat.size			= 13
				copyFormat.color		= 0x757575
		
			mc.bg.copy.setTextFormat(copyFormat)
		
		/// adjust position of copytext
			mc.bg.copy._x					= 15
			mc.bg.copy._y					= 37
			
		/// apply drop shadow
			var filter:DropShadowFilter = new DropShadowFilter(0,90, 0x000000, 0.25,10, 10, 1, 3, false, false, false);
			var filterArray:Array = new Array();
			filterArray.push(filter);
			mc.bg.filters = filterArray;
			
		/// startanimation
			var popIn:mx.transitions.Tween = new mx.transitions.Tween(mc, "_xscale", mx.transitions.easing.Elastic.easeOut, 80, 100, .3, true)
			popIn.onMotionChanged = function () {
				mc._yscale = mc._xscale
			}
	}
	
}
hier der erste frame des flashfilms

Code:
///// pop ups

import mx.managers.PopUpManager
import as.vorbilder.*

function callAlert () {
	
	var alert:alertbox = new alertbox()
	
	// new object  we can use for a listener
	var alertListener:Object = new Object; 
	
	// method definition for the drawn event
	alertListener.closeAlert = function(evtObj) {
		alertObj.deletePopUp()
		trace(alertObj)
		trace("schliessen")
	}
	
	// subscribe myListnerObj to mySquareObject
	alert.addEventListener("closeAlert",alertListener);
	
	alertObj.PopUpManager.createPopUp(_root, alert.callAlertBox(), true);
	

}

bt.onPress = function () {
	callAlert()
}

das das this bei dem dispatcher nicht stimmen kann ist mir klar. habe schon jegliches targeting ausprobiert. komme aber einfach nicht weiter.

wäre dankbar für jede hilfe.

des weiteren frag ich mich warum ich in einer klasse keine funktion aufrufen kann wenn etwas in einer
Code:
MovieClip.onPress = function () {

...

}
steht. woran liegt das?


grüße
pixelslave ist offline   Mit Zitat antworten
Alt 01-09-2007, 22:30   #2 (permalink)
voidboy
 
Benutzerbild von rendner[i]
 
Registriert seit: Sep 2004
Ort: München
Beiträge: 5.588
Zitat:
problem liegt in zeile 65
Ich sehe nirgendwo Zeilenangaben.

Zitat:
des weiteren frag ich mich warum ich in einer klasse keine funktion aufrufen kann wenn etwas in einer
Code:

MovieClip.onPress = function () {

...

}

steht. woran liegt das?
Das ist ein scope Problem, dies kannst du mit mx.utils.Delegate lösen.
Suche hier einfach mal nach delegate,
__________________
ERROR: Signature is too large
rendner[i] ist offline   Mit Zitat antworten
Alt 02-09-2007, 00:38   #3 (permalink)
Raven-Kid
 
Benutzerbild von [RK]
 
Registriert seit: Feb 2006
Beiträge: 350
Zitat:
Zitat von rendner[i] Beitrag anzeigen
Ich sehe nirgendwo Zeilenangaben.
Für dieses Problem gibt es den [*AS][*/AS] Tag ...
Wär nur toll wenn man den auch auswählen könnte und nicht tippen muss, denn dann würden den sicherlich auch mehrere verwenden.
[RK] ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 15:46 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele