The class MacaoObject is the base class for every object displayed in a page. It implements basic functionality as displaying, positioning, sizing and event handling.
Because it is the basic interface to the browser's objects, it contains the majority of the browser specific code (even if there is not much brwoser specific code).
To use more complex functionality as walking and talking include the package dynamic in the page. This will extend MacaoObject with the methods and properties of the MacaoObject defined in that package.
Constructor Summary |
---|
MacaoObject(String name, String title, number left, number top)
Use this constructor to create new objects at your page. |
Method Summary | |
---|---|
void | activateDrag(boolean active, optional boolean moveBack, optional String cssClassName)
Use this method to activate or deactivate dragging for this object and to set dragging characteristics. |
void | activateDrop(optional boolean active, optional String hiliteCssClassName)
Call this method to activate or deactivate the drop functionality for this object. |
void | addController(String controllerObjectName)
Use this method to set the name of an object, which is accepted as controller by this object. |
void | broadcastEvent(String eventType, optional Array params, optional boolean toAllFrames)
Sends an event to all objects of the sender's frame or to all objects of all frames. |
DIV | createLayer()
This method creates the DIV element (= layer), which is used to display the object. There may be only one layer for each object. If there is already a layer for this object, the existing layer is returned. See also getLayer(). |
MacaoLook | createLook(String name, String imageSource, number baseWidth, number baseHeight, optional number deltaLeft, optional number deltaTop, optional String html)
Use this method to create a look and add it to the list of looks, which is maintained by the object. |
void | displayMeasures()
This method displays the basic measures of this object in the browser's status bar. |
String | getActualLook()
This method returns the name of the look, which is currently displayed. |
boolean | getCollisionCheck()
Gets the information, if collision check is turned on for this object. |
String | getCssClassName()
Gets the object layer's cascading stylesheet class name. |
String | getFrameName()
Gets the name of the frame, where the object is in. |
integer | getHeight()
Gets the current height of the object. |
DIV | getLayer()
The method return the DIV object, which is used to display the object. The DIV object is part of the HTML DOM (Document Object Model). |
number | getLeft()
The method returns the position of the left edge of the object. |
MacaoLook | getLook(String lookName)
Use this method to retrieve a look, which was previously added to the object. |
String | getName()
Gets the name of the object. The name can be used to reach the object using events. |
String | getTitle()
Use this method to get the title of the object. See also setTitle(). |
number | getTop()
This method returns the position of the top edge of the object. |
String | getType()
Gets the type of the object. |
boolean | getVisibility()
Gets the visibility of the object's layer. |
integer | getWidth()
Gets the current width of the object. |
integer | getZIndex()
Gets the z-index of the object's layer. |
number | getZoom()
Gets the current zoom factor. |
boolean | hasLook(String lookName)
Use this method to test, if a look with the specified name has been added to the object. |
void | initObject(String name, String title, number left, number top)
This method initializes the properties of the object. If the package dynamic is loaded into the page, this method also calls the method initDynamic(). |
boolean | isController(String controllerObjectName)
Use this method to test, if another object is accepted as controller by this object. |
boolean | isDragActive()
Call this method to check, if this object can be dragged by the user. |
boolean | isDragged()
Call this method to check, if the object is currently being dragged. |
boolean | isDropActive()
Call this method to check, if Drop is activated for this object. |
boolean | isDropAllowed(MacaoObject forObject)
This method controls, if another object may be dropped to this object. |
void | moveTo(number left, number top)
This method moves the object to a position on the page immediately. |
void | moveToCenter()
This method moves the object so that it is horizontally and vertically centred in the frame where the page is displayed in. |
void | notifyControllers(String notificationType, optional variant param)
Call this method to send a notification to all controllers, which are registered to this object. |
void | onClick(Event event, integer mouseX, integer mouseY)
This event handler is called when the user clicks on the object. |
void | onClickOther(String objectName, Event event, integer mouseX, integer mouseY)
This event handler is called when another object is clicked. |
void | onClickOtherItem(String itemName, String itemTitle)
This event handler is called, when the user clicks at an item in a MacaoInventory. |
void | onClickWindow(Event event, integer mouseX, integer mouseY, String frameName)
This event handler is called, when the mouse is clicked in any frame. |
void | onCollisionOut(optional String objectName)
This event handler is called when the object starts colliding with another object. |
void | onCollisionOver(String objectName)
This event handler is called, when the object ends colliding with another object. |
void | onDblClick(Event event, integer mouseX, integer mouseY)
This event handler is called when the user double clicks on the object. |
void | onDblClickOther(String objectName, Event event, integer mouseX, integer mouseY)
This event handler is called when another object is double clicked. |
void | onDblClickWindow(Event event, integer mouseX, integer mouseY, String frameName)
This event handler is called, when the mouse is double clicked in any frame. |
void | onDragEnd(Event event, integer mouseX, integer mouseY)
This method is called, when the user ends to drag this object. |
void | onDragOut(Event event, integer mouseX, integer mouseY, MacaoObject otherObject)
This method is called, when the user drags this object out from over another object. |
void | onDragOver(Event event, integer mouseX, integer mouseY, MacaoObject otherObject)
This method is called, when the user drags this object over another object to which it can be dropped. |
void | onDragStart(Event event, integer mouseX, integer mouseY)
This method is called, when the user starts to drag this object. |
void | onDrop(Event event, integer mouseX, integer mouseY, MacaoObject toObject)
This method is called, when the user drops another object to this object. |
void | onKeyDown(Event event, integer keyCode, boolean shiftKey, boolean altKey, boolean ctrlKey, String frameName)
This event handler is called, when a key goes down on window level. |
void | onKeyPress(Event event, integer keyCode, boolean shiftKey, boolean altKey, boolean ctrlKey, String frameName)
This event handler is called, when a key is pressed on window level. |
void | onKeyUp(Event event, integer keyCode, boolean shiftKey, boolean altKey, boolean ctrlKey, String frameName)
This event handler is called, when a key goes up on window level. |
void | onLoad(Event event)
This method is called when the page's loading is complete. |
void | onMouseDown(Event event, integer mouseX, integer mouseY)
This event handler is called when the mouse button goes down on the object. |
void | onMouseDownWindow(Event event, integer mouseX, integer mouseY, String frameName)
This event handler is called, when the mouse button goes down in any frame. |
void | onMouseMove(Event event, integer mouseX, integer mouseY)
This event handler is called when the user moves the mouse pointer over the object. |
void | onMouseOut(event event, integer mouseX, integer mouseY)
This event handler is called when the user removes the mouse pointer from over the object. |
void | onMouseOver(event event, integer mouseX, integer mouseY)
This event handler is called when the user moves the mouse pointer over the object. |
void | onMouseUp(Event event, integer mouseX, integer mouseY)
This event handler is called when the mouse button goes up on the object. |
void | onMouseUpWindow(Event event, integer mouseX, integer mouseY, String frameName)
This event handler is called, when the mouse button goes up in any frame. |
void | onUnload(Event event)
This method is called before the page is unloaded. |
void | openPage(String pageURL, optional String frameName, optional boolean forceReload)
Opens a page in the defined frame. |
MacaoEvent | postEvent(String eventType, Array params, integer delay, optional String recipientName, optional String frameName)
Sends an event to an object with a delay. |
void | refreshZoom()
Call this method to refresh the size of the image, which is used to display the object. |
void | removeController(String controllerObjectName)
Use this method to remove the name of an object, which is accepted as controller by this object. |
void | removeObject()
This method removes the object from the list of the objects. And it removes the layer of the object from the DOM of the page. |
void | say(String text, optional String html, optional String imageSource, optional integer imageWidth, optional integer imageHeight, optional integer duration, optional String afterEventType, optional Array afterEventParams, optional String cssClassName, optional String lookName)
This method displays a bubble near the object, showing a text, which is "said" by the object. |
void | scrollVisible()
Scrolls the object into view. |
variant | sendEvent(String eventType, optional Array params, optional String recipientName, optional String frameName)
Sends an event to an object. |
void | setActualLook(String lookName, optional boolean forceReload)
Use this method to display a look, which has been added to the object. |
void | setBaseSize(optional integer baseWidth, optional integer baseHeight)
Sets the base size of the object. The base size is used for calculating the zoom size. |
void | setCollisionCheck(boolean active)
Activates or deactivates the collision check of the object. |
void | setCssClassName(optional String cssClassName)
Set the name of the object layers cascading stylesheet class. |
void | setForwardMouseEvents(optional boolean active)
Call this method to activate the forwarding of mouse events to the underlying objects. |
void | setHTML(String html)
This method sets HTML to the layer. |
void | setImage(String imageSource, number baseWidth, number baseHeight, optional number deltaLeft, optional number deltaTop)
Sets an image to the object. |
void | setScrollVisibleOptions(boolean autoScroll, integer borderDistance)
Sets the characteristics for scrolling an object into view. |
void | setTitle(String title)
This method sets the title of the object. The title is used for displays to the user. See also getTitle(). |
void | setToolTip(optional String toolTip)
The method sets the content of tool tip of the object. The tool tip is displayed when the user places the mouse pointer over the object. By default the title of the object is set as the tool tip content. |
void | setType(String type)
Sets the type of the object. Initially the type is set by the name of the object. |
void | setVisibility(boolean visibility)
Sets the visibility of the object's layer. |
void | setZIndex(integer zIndex)
Sets the z-index of the object's layer. |
void | setZoom(number zoomFactor)
The method sets the zoom factor for the current object. |
integer | toBack()
This method drops the object behind each other on the page. |
integer | toFront()
This method raises the object above each other object on the page. |
Constructor Details |
---|
Use this constructor to create new objects at your page.
Method Details |
---|
Use this method to activate or deactivate dragging for this object and to set dragging characteristics.
See also activateDrop(). If you use Drag and Drop, you should call the method MacaoPage.setPageSize() to limit the drag area for the user.
Call this method to activate or deactivate the drop functionality for this object.
If drop is activated, the object gets events, when the user drags an object over this object or drops an object to this object. See also activateDrag() and hearEvent().
Use this method to set the name of an object, which is accepted as controller by this object.
The concept of controllers is the following: A controller may broadcast a user input as an event to all objects. Each object
gets the event including the name of the controller. If the controller is activated in the object, the event is accepted and
executed by the receiving method. Otherwise the event is ignored by the method. If the controller name is set to null, the
method call should be executed.
It's up to a method to use the controller logic or don't use it.
Methods that use this controller function are tryAction(), approchAndTryAction() and setSteeringIndex(). See also removeController(), isController() and notifyControllers().
Sends an event to all objects of the sender's frame or to all objects of all frames.
Sending an event is similar to calling a method of a target object. The event system is finding the target object even if it's in another frame. If there is no fitting method at the target object, the event is not delivered and no error is raised. It's recommended to send an event to another object rather than calling a method directly.
See also sendEvent() and postEvent().
This method creates the DIV element (= layer), which is used to display the object. There may be only one layer for each object. If there is already a layer for this object, the existing layer is returned. See also getLayer().
Use this method to create a look and add it to the list of looks, which is maintained by the object.
There can only be one look with the same name at an object. If you try to add another look with the same name, an error message is displayed.
Looks are used to preload images and to predefine HTML to display. Preloaded images are displayed immediately when the look is set as the actual look. Use the method setActualLook() to display the added look. See also hasLook(), getLook() and setActualLook() and getActualLook().
If there is not already a look displayed for this object, the look you provide will be displayed. If there is already a look displayed, the display of the object stays unchanged. It's recommended to add all the looks to an object during the opening of the page.
The parameters deltaLeft and deltaTop assume, that your object has a standard size. If this image has another size than the standard size, the object possibly has to be shifted to display this image in the right position. To shift the object to the right position set the parameters deltaLeft and deltaTop. The delta values will be maintained. So if the delta values of the next object are 0, the object will be shifted back.
This method displays the basic measures of this object in the browser's status bar.
By default this method is called, when you hold down the shift and the control key and click on an object.
This method returns the name of the look, which is currently displayed.
Use getLook() to get the look itself. See also setActualLook().
Gets the information, if collision check is turned on for this object.
See also setCollisionCheck().
Gets the object layer's cascading stylesheet class name.
See also setCssClassName().
Gets the name of the frame, where the object is in.
The name of a frame is set when defining a frameset. If you don't use a frameset, you can define the frame name by setting window.name.
Gets the current height of the object.
See also getWidth() and setZoom().
The method return the DIV object, which is used to display the object. The DIV object is part of the HTML DOM (Document Object Model).
Normally you should use the methods createLook() and setActualLook() or setImage() and setHtml() to modify the content of the layer. If you need to maintain special dynamic html, you may access the layer directly. The layer is automatically created when an image, HTML or a look is added to the object. If you want to access the layer directly without using one of those methods, you have to call the method createLayer() to create the layer. There is only support for one layer per object.
The DIV object contains sub-DIV objects, one for each look. Only one of the sub-DIVs is visible at a time.
If a sub-Div is displayed, which consists of an image, the property image of the DIV object keeps a reference to the image. The div object also contains the event handlers used to forward the ui-events to the object.
The method returns the position of the left edge of the object.
Use this method to retrieve a look, which was previously added to the object.
See also createLook().
Gets the name of the object. The name can be used to reach the object using events.
There must only be one object with the same name on a page. If you create more than one object with the same name, a number will automatically extend the name. You can get the original name using the method getType().
Use this method to get the title of the object. See also setTitle().
This method returns the position of the top edge of the object.
Gets the type of the object.
See also setType().
Gets the visibility of the object's layer.
See also setVisibility().
Gets the current width of the object.
See also getHeight() and setZoom().
Gets the z-index of the object's layer.
The z-index controls, which layer covers which other layer. See also setZIndex().
Gets the current zoom factor.
See also setZoom().
Use this method to test, if a look with the specified name has been added to the object.
See also createLook().
This method initializes the properties of the object. If the package dynamic is loaded into the page, this method also calls the method initDynamic().
The initObject() method creates the array objects for the properties. If you create a MacaoObject or another object of a standard class, the constructor automatically calls this method. But if you implement your own class subclassing a standard class, you have to call this method yourself. In this case you should implement your own init method, which initializes your properties and calls this method. Call your own init method in the constructor of your own class.
Use this method to test, if another object is accepted as controller by this object.
See also addController() and removeController().
Call this method to check, if this object can be dragged by the user.
See also activateDrag().
Call this method to check, if the object is currently being dragged.
See also activateDrag().
Call this method to check, if Drop is activated for this object.
See also activateDrop().
This method controls, if another object may be dropped to this object.
You can override this method to change the selection, which objects may be dropped to this object. The default implementation returns true, if drop is activated for this object. See also activateDrop(). When the user drops the other object to this object, the event handler onDrop() is called.
This method moves the object to a position on the page immediately.
This method moves the object so that it is horizontally and vertically centred in the frame where the page is displayed in.
The method moves the object not the page. It is used to centre popups such like splash screens.
Call this method to send a notification to all controllers, which are registered to this object.
The notification is send to all objects, which are registered to this object using the method addController(). A controller, which has to receive this notification, has to implement the method receiveNotification(senderObject, notificationType, param). The receiving method has to filter the calls with the required notification type and may react to the notification. The parameter senderObject is the MacaoObject, which sent the notification.
For example you have a controller, which has to display the velocity of an object. First you have to register the controller to the controlled object by calling addController(). When the velocity of an object changes, it sends a notification of the type velocityChanged to all its controllers. The described controller implements the method receiveNotification(). It tests the notification type, gets the velocity from the senderObject and displays it.
This event handler is called when the user clicks on the object.
You may override this method to implement your own event handler. But keep in mind , that the standard functionality is implemented by this event handler. If you don't need the coordinates of the click, you should better add a MacaoTalkItem to respond to the click instead. See addTalkItem().
The standard functionality of this event handler displays the position and the measures of the object in the status bar when the user holds down the shift and the control key and clicks on the object.
This event handler is called when another object is clicked.
You may implement this method to respond to that event. In the package dynamic this handler is implemented to let the object the clicked object.
This event handler is called, when the user clicks at an item in a MacaoInventory.
You may implement this event handler to respond to that event.
This event handler is called, when the mouse is clicked in any frame.
You may implement this handler. In the package dynamic this handler is implemented to let the object approach the mouse click position.
This event handler is called when the object starts colliding with another object.
You may implement this event handler to get the event. See also setCollisionCheck().
This event handler is called, when the object ends colliding with another object.
You may implement this event handler to get the event. See also setCollisionCheck().
This event handler is called when the user double clicks on the object.
You may implement this method to respond to that event.
This event handler is called when another object is double clicked.
You may implement this method to respond to that event.
This event handler is called, when the mouse is double clicked in any frame.
You may implement this handler. There is no default implementation.
This method is called, when the user ends to drag this object.
You may implement this handler. There is no default implementation.
This method is called, when the user drags this object out from over another object.
You may implement this handler. There is no default implementation.
See also the method isDropAllowed(). It controlls, which object may be dropped.
This method is called, when the user drags this object over another object to which it can be dropped.
You may implement this handler. There is no default implementation.
See also the method isDropAllowed(). It controlls, which object may be dropped.
This method is called, when the user starts to drag this object.
You may implement this handler. There is no default implementation.
This method is called, when the user drops another object to this object.
You may implement this handler. There is no default implementation.
See also the method isDropAllowed(). It controlls, which object may be dropped.
This event handler is called, when a key goes down on window level.
You may implement this handler. There is no default implementation.
This event handler is called, when a key is pressed on window level.
You may implement this handler. There is no default implementation.
This event handler is called, when a key goes up on window level.
You may implement this handler. There is no default implementation.
This method is called when the page's loading is complete.
You may implement this handler. There is no default implementation.
This event handler is called when the mouse button goes down on the object.
You may override this method to implement your own event handler. But keep in mind that the standard functionality is implemented by this event handler. If you don't need the coordinates of the click, you should better add a MacaoTalkItem to respond to the click instead. See addTalkItem().
The standard implementation of this event handler initiates the dragging of the object. If dragging is set active to this object or the shift and the control keys are pressed, the object starts dragging. See also activateDrag().
This event handler is called, when the mouse button goes down in any frame.
You may implement this handler. There is no default implementation.
This event handler is called when the user moves the mouse pointer over the object.
You may override this method to implement your own event handler. But keep in mind that the standard functionality is implemented by this event handler.
The standard implementation moves the object when the object is being dragged. See also activateDrag().
This event handler is called when the user removes the mouse pointer from over the object.
You may implement this method to respond to that event.
This event handler is called when the user moves the mouse pointer over the object.
You may implement this method to respond to that event.
This event handler is called when the mouse button goes up on the object.
You may override this method to implement your own event handler. But keep in mind that the standard functionality is implemented by this event handler.
The standard implementation of this event handler ends a dragging operation and starts the drop operation when dragging and dropping is activated for this object. See activateDrag() and activateDrop().
This event handler is called, when the mouse button goes up in any frame.
You may implement this handler. There is no default implementation.
This method is called before the page is unloaded.
You may implement this handler. There is no default implementation.
Opens a page in the defined frame.
It's recommended to open a page by using this method rather than by assigning window.location. This method maintains the auto restore functionality for the objects on this page. It informs the opened page which its opener was. This method does the same as the global method openPage(). See also store(), restore(), setAutoRestore() and getOpenerPageName().
Sends an event to an object with a delay.
Posting an event is similar to calling a method of the target object. But the event is delayed. The event system is finding the target object even if it's in another frame. If there is no fitting method at the target object, the event is not delivered and no error is raised. An object may also send an event to itself to delay the execution of a method.
Every event is also delivered to the talk system. See addTalkItem().
See also sendEvent() and broadcastEvent().
Call this method to refresh the size of the image, which is used to display the object.
See also setZoom().
Use this method to remove the name of an object, which is accepted as controller by this object.
See also addController().
This method removes the object from the list of the objects. And it removes the layer of the object from the DOM of the page.
This method displays a bubble near the object, showing a text, which is "said" by the object.
The method forwards the request to the MacaoBubble object. It is recommended to add talk items to the object in order to let it say something, rather than call the method say directly. See also addTalkItem().
If there is already another object speaking using the bubble, then the display for this object is delayed until the previous sentences have been finished.
Scrolls the object into view.
The method scrolls the page so that the object comes into view. Call setScrollVisibleOptions() to set the characteristics for this action.
Sends an event to an object.
Sending an event is similar to calling a method of the target object. The event system is finding the target object, even if it's in another frame. If there is no fitting method at the target object, the event is not delivered and no error is raised. It's recommended to send an event to another object rather than calling a method directly.
Every event is also delivered to the talk system. See addTalkItem().
The following example hides the car object. Even the only parameter must be enclosed in an array.
this.sendEvent("setVisibility", [false], "car")
See also postEvent() and broadcastEvent().
Use this method to display a look, which has been added to the object.
Use the method createLook() to add looks to the object. See also hasLook() and getActualLook().
Sets the base size of the object. The base size is used for calculating the zoom size.
You may set the base size to null to clear it. In this case the base size is got from the image itself. But this may fail, if the image is not already loaded. See also setZoom().
Activates or deactivates the collision check of the object.
When the collision check is activated, the object receives onCollisionOver() and onCollisionOut() events when the object is overlapping another object whose collision check is also activated. See also getCollisionCheck().
Set the name of the object layers cascading stylesheet class.
See also getCssClassName().
Call this method to activate the forwarding of mouse events to the underlying objects.
If you activate the forwarding of mouse events, the object will ignore its own mouse events. The events are forwarded to the next object, which is lying below this object. Or the events are ignored, if there is no other object below this. This behaviour is useful for character objects, which are controlled by the user. So the object will not cover other objects. By default this behaviour is off.
This property doesn't affect the tool tip. If you don't want the tool tip of the object to be displayed, call setToolTip(null).
This method sets HTML to the layer.
If the object hasn't already a layer, the layer will be created. The method replaces the HTML, which was previously displayed in the layer. See also createLayer(), setImage() and clearHtml().
Sets an image to the object.
If you used setImage() before to set an image, the image is replaced by this image.
It is recommended to use looks to maintain the images for an object rather than loading them direct by setImage(). See createLook() and setActualLook().
The parameters deltaLeft and deltaTop assume, that your object has a standard size. If this image has another size than the standard size, the object possibly has to be shifted to display this image in the right position. To shift the object to the right position set the parameters deltaLeft and deltaTop. The delta values will be maintained. So if the delta values of the next object are 0, the object will be shifted back.
Sets the characteristics for scrolling an object into view.
See also scrollVisible().
This method sets the title of the object. The title is used for displays to the user. See also getTitle().
This method doesn't change the content of the tool tip. Use the method setToolTip() instead.
The method sets the content of tool tip of the object. The tool tip is displayed when the user places the mouse pointer over the object. By default the title of the object is set as the tool tip content.
Sets the type of the object. Initially the type is set by the name of the object.
If you create more than one object with the same name, there will automatically assigned different names. But the original name is kept as the type. You may use the type property to identify a group of objects of the same type to handle them in the same manner. At the moment there is no special support for groups of objects of the same type except the maintaining of this property. See also getType().
Sets the visibility of the object's layer.
You can set this property before creating the layer to determine if the layer will be visible. See also getVisibility().
Sets the z-index of the object's layer.
The z-index controls, which layer covers which other layer. See also getZIndex()., toFront() and toBack().
The method sets the zoom factor for the current object.
Zooming an object is currently supported for images only. So if you set HTML to the object by calling setHtml() or set a look containing HTML, setting the zoom factor will have no effect.
Setting the zoom factor changes the size of the currently displayed image. The new size of the image is calculated by the base size and the zoom factor. The base size of the object can be defined by the method setBaseSize() or setImage() when creating a look containing an image. See also MacaoLook(), refreshZoom() and getZoom().
This method drops the object behind each other on the page.
See also toFront() and setZIndex().
This method raises the object above each other object on the page.
See also toBack() and setZIndex().