GuiStaticImageLoadImage: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: {{Client function}} __NOTOC__ <!-- Describe in plain english what this function does. Don't go into details, just give an overview --> This function allows you to change the image in GUI s...)
 
m (Added OOP Method + Variable Information)
 
(12 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{Client function}}
{{Client function}}
__NOTOC__
__NOTOC__
<!-- Describe in plain english what this function does. Don't go into details, just give an overview -->
This function allows you to change the image in GUI static image element to another one. '''Tip''': If you set other images as children you will have to use [[setElementCallPropagationEnabled]] to only affect the parent image.
This function allows you to change the image in GUI static image element to another one.


==Syntax==  
==Syntax==  
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool guiStaticImageLoadImage ( element theElement, string filename )
bool guiStaticImageLoadImage ( element theElement, string filename )
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[Element/GUI/Static_image|GuiStaticImage]]:loadImage|image}}
===Required Arguments===  
===Required Arguments===  
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type -->
*'''theElement:''' The static image element to be changed.
*'''theElement:''' The static image element to be changed.
*'''filename:''' A string specifying the location of the image file being loaded in current resource. The file must be predefined in resource's meta.xml file (see example).
*'''filename:''' A string specifying the [[filepath]] of the image file being loaded in current resource.  


===Returns===
===Returns===
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check -->
Returns ''true'' if the the image in the static image element was successfully changed, ''false'' otherwise.
Returns ''true'' if the the image in the static image element was successfully changed, ''false'' otherwise.


==Example==  
==Example==  
This example creates a static image (myimage.png) and replaces it with other image (otherimage.png) 10 seconds after creation.
This example creates a static image ("myimage.png") and replaces it with other image ("otherimage.png") 10 seconds after creation.
<section name="Client-side script (example.lua)" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
[lua]
local myImage = guiCreateStaticImage( 0.45, 0.48, 0.2, 0.5, "myimage.png", true )
local myImage = guiCreateStaticImage ( 0.45, 0.48, 0.2, 0.5, "myimage.png", true )
setTimer( guiStaticImageLoadImage, 10000, 1, myImage, "otherimage.png" )
setTimer( guiStaticImageLoadImage, 10000, 1, myImage, "otherimage.png" )
</syntaxhighlight>
</syntaxhighlight>
</section>
<section name="meta.xml" class="server" show="true">
In this example meta.xml is used to tell the server which files it will be using.
<syntaxhighlight lang="lua">
  <info author="Yourname" version="1.0" />
  <script src="example.lua" type="client" />
  <file src="myimage.png" />
  <file src="otherimage.png" />
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{GUI_functions}}
{{GUI_functions}}
{{GUI_events}}

Latest revision as of 12:03, 7 August 2019

This function allows you to change the image in GUI static image element to another one. Tip: If you set other images as children you will have to use setElementCallPropagationEnabled to only affect the parent image.

Syntax

bool guiStaticImageLoadImage ( element theElement, string filename )

OOP Syntax Help! I don't understand this!

Method: GuiStaticImage:loadImage(...)
Variable: .image


Required Arguments

  • theElement: The static image element to be changed.
  • filename: A string specifying the filepath of the image file being loaded in current resource.

Returns

Returns true if the the image in the static image element was successfully changed, false otherwise.

Example

This example creates a static image ("myimage.png") and replaces it with other image ("otherimage.png") 10 seconds after creation.

local myImage = guiCreateStaticImage( 0.45, 0.48, 0.2, 0.5, "myimage.png", true )
setTimer( guiStaticImageLoadImage, 10000, 1, myImage, "otherimage.png" )

See Also

General functions

Browsers

Buttons

Checkboxes

Comboboxes

Edit Boxes

Gridlists

Memos

Progressbars

Radio Buttons

Scrollbars

Scrollpanes

Static Images

Tab Panels

Tabs

Text Labels

Windows

Input

GUI