I need a simple button/movieclip interaction
If I have a button named "b" and a movie clip named "mc" that has an internal timeline, what is the code in AS3 to make the mc play?
The main timeline is only one frame.
Thanks in advance!
mc.play();
should be all you need.
If you mean you want the button to make it play then...
b.addEventListener(MouseEvent.CLICK, playMC);
function playMC(evt:MouseEvent):void {
mc.play();
Similar Messages
-
Simple button help needed!
I want to make a simple round button that glows when you
mouse over it and depresses when you click it.
Apparently to do this I need to use Filters to make the glow
and bevels. But Filtersonly work on movie clips, buttons and text.
So I make a circle and convert it into a button symbol
(Btn1). Then I make another button symbol (Btn2) and use the first
button symbol (Btn 1) on the Up Over and Down frames of Btn 2.
Assorted Filters are applied to Btn 1 on the Up Over and Down
frames to get the effects I want.
I test the button (Btn2) using Enable Simple Buttons. It
works perfectly - glows on mouse over and depresses on click. Then
I try Test Movie -- and the button doesn't work!!!
Not does it work when exported as a SWF file!!!
I watched a tutorial video that came with my Flash Pro 8
Hands-On-Training (HOT) book and he used pretty much the same
technique -- except he only tested his button with Enable Simple
Buttons. I'll bet my house his didn't work with Test Movie either!
The stupid thing, is I was just able to achieve exactly what
I wanted very quickly using LiveMotion 2!
What is wrong here? Why is it so impossible to create a glow
button in Flash? Why has it been easy in Live Motion for years?
All help appreciated!
Thanks
craigI thought the nesting button situation might be the problem
BUT there is no other way to apply Filters to Up, Down, etc. Also,
a freaking tutorial book described that as a valid method, but
obviously it ain't.
I tried using movieclips as well but basically had the same
problem.
I mentioned LiveMotion 2 because that ancient program can do
easily what Flash Pro 8 seems incapable of.
What is the logic behind not allowing Filters to be applied
to simple graphics? It's absurd!
There's got to be a way... -
Simple button not functioning?
I've been staring at this code for an hour. Maybe I need a break? This is a very simple button that just won't accept my touch events.
I have a movie clip. It's instance name is "boardA." The name of the symbol is "letterA" and it is linked to a class file called "Letters" (which is properly linked, I checked).
This is the code in the class file:
public function Letters() {
this.addEventListener(TouchEvent.TOUCH_BEGIN, createLetter);
trace (this.letter);
public function createLetter(e:TouchEvent): void {
trace ("You clicked it!");
trace ("eName = " + e.target.letter);
Yet nothing happens when I click the button. The constructor for the file never executes.
I even moved the touch event to the main frame "boardA.addEventListener(TouchEvent.TOUCH_BEGIN, createLetter)" and it still didn't work. Nothing when I touch the button.
What am I missing here?
Thanks
AmberNo. Letters.as is in com/freerangeeggheads/spellmaster. It's linked as such - here is the text.
The base class is: com.freerangeeggheads.spellwhiz.Letters
The class is: letterA
When I click the green check box it tell me it can find the class, and when I click the edit class button it takes me to the proper script file.
I also have the file imported into my main frame.
This is the Letters.as file:
package com.freerangeeggheads.spellwhiz {
import flash.display.*;
import flash.events.*;
import com.freerangeeggheads.spellwhiz.*;
public class Letters extends MovieClip {
public var letter:String = "";
public function Letters(): void {
this.addEventListener(TouchEvent.TOUCH_BEGIN, createLetter);
trace (this.letter);
public function createLetter(e:TouchEvent): void {
trace ("You clicked it!");
trace ("eName = " + e.target.letter);
Thanks! -
Adding Image to Simple Button Dynamically Using AS3
Hi,
I need some help trying to figure out how to dynamically add an image (PNG or JPEG) that I can place in the library to a simple button also dynamically created in AS3.
Is there a way to (1) add the image instead of using a text label and have it centered in the button?
Here's the AS3 for the simple button without the image (currently uses text label but would prefer if possible to substitute an image for the text:
var mc2:MovieClip = new MovieClip();
mc2.addChild( bgRed2 );
mc2.addChild( txt2 );//currently uses text label; would prefer to use an image istead of text
var mc2a:MovieClip = new MovieClip();
mc2a.addChild( bgRed2a );
mc2a.addChild( txt2a );currently uses text label; would prefer to use an image istead of text
var clearBtn:SimpleButton = new SimpleButton();
clearBtn.upState = mc2;
clearBtn.overState = mc2a;
clearBtn.downState = clearBtn.upState;
clearBtn.hitTestState = clearBtn.upState;
clearBtn.x = 0;
clearBtn.y = 0;
addChild( clearBtn );
clearBtn.x = 55;
clearBtn.y = stage.stageHeight-clearBtn.height;
Any help appreciated.assign your image a class name (eg, Img1). you can then use:
var img1D:BitmapData=new BitmapData();
var img1:Bitmap=new Bitmap(img1D);
cleanBtn.upState=img1; // for example, button's upstate is the image.
// if you wanted some background and the image centered on the background, create your background (sprite or movieclip), use addChild to add img1 to your background and center it. then assign your button's upState etc to be your background -
Simple button script not working
I am using AS2 and need help figuring out why this simple button script is not working:
stop();
buttonWS1.onRelease = function(){
gotoAndStop("Stage1and2_Boss",4);
buttonWS2.onRelease = function(){
nextFrame();
//end
My buttons are the square letter-puzzles below. They are images that I converted to "symbols" (specifically, buttons). I put their names as above (buttonWS1, buttonWS2, etc.) in the "instance names" boxes.
I have no idea what is going on. Please help!Hi -
1. Yes, buttonWS2 is the instance name
2. The only code attached to it is the code I pasted above.
3. onRelease does not execute because my trace statement does not appear in the output
Here is the modified code for buttonWS2:
buttonWS2.onRelease = function(){
trace("clicked!");
nextFrame();
Question: It shouldn't matter if I have commented-out code within that set of codes should it?:
buttonWS2.onRelease = function(){
//if (puzzleschosenarray[0] == 2 || puzzleschosenarray[1] == 2) {
// cannot be chosen -- make button non-functional
//else{
//puzzleschosenarray[roundnumber-1] = 2;
trace("clicked!");
nextFrame(); -
Simple Button Hit Zone not working
I am somewhat new to Flash CS4 andt am having a problem making simple buttons in Flash CS4 on a Macintosh: I have made a few buttons with a graphic and can go into them and successfully create the Up, Over and Down stages of the graphic. Then when I create a new box for the hit state (which is larger than the graphic and I have deleted the graphic itself from the hit state) it doesn't want to appear correctly when I test the movie. When I test the movie, the hit state is correct everywhere around the graphic (to the bounds of my hit state box), but is not active where the graphic is. When I go under the Control menu, down to Enable Simple Buttons, the hit zone looks great right in my Flash file, but when I preview it or publish it and look it on different browsers (PC and Mac), I don't get my pointer right over the actual graphic, but get it everywhere around the graphic to the boundaries of my hit box. Why can't I get the actual graphic to be a hot spot in this situation? I have tried leaving the graphic in the hit timeline, and tried putting both the larger box and the graphic in the hit timeline, and still can't get them to respond correctly with the pointer in the browser window. Thank you....
Well, since the graphic itself doesn't activate my pointer in a web browser, I thought maybe I needed to add both the box and the graphic itself to the hit state. That's what has me puzzled - the box that I use for the hit zone is "active" everywhere but where the actual graphic is...
-
Need Help with ACTIONSCRIPT for Interactive Music Video
I am trying to create an interactive music video in After Effects and Flash.
The concept is that while the music video is taking place the user can decorate the hair of the woman with any of the objects they select. There will be predetermined animations and destination spots but the user can choose whatever objects they select to be delivered to the predetermined spot. I need to figure out how to let the user to select an object that will become part of the animation. I created a PDF Roughly explaining what I am trying to do. If anyone can help me I'd be very grateful as I am more versed in After Effects, I don't know ActionScript well enough to execute what I am trying to do.
Below is a rough example of what I am trying to do. There will be a music video of an animated woman singing. As she is singing the user will be able to click any of the objects , below the numbers 1-10. Below it is illustrated that the user wants to press the blue number 2. If the user presses the 2 the 2 will animate in the mouth of a bird to a predetermined pre-animated spot. I assume I need to send a movieclip to a blank holder on the timeline and use a gotoAndPlay() action ??? I am not well versed in ActionScript so any advice would help
Now whatever number (movieclip) the user chooses next needs to be placed in another blank spot in the timeline? Below the user selcts the Pink 5.
If the user just wanted to Place two "Blue 2's" then the "Blue 2's" would follow the same animated path and end up at the same predetermined space.
If the user selected just 5's and 7's they would go to the predetermined preanimated paths
How would I go about writing the Actionscript for this?Look, I hope you don't have false expectation that by knowing one piece of AS capabilities you will be able to accomplish your task.
If I say that the code for placing one MovieClip into another is:
clip1.addChild(clip2);
will it make any difference in terms of implementation?
Also, you say "select." This may mean a lot of thing: click, drag and drop, mouse down, etc. I am saying that implementation tightly depends of definitions that you give.
I don't know the extend of your AS skills, so it is not easy to figure where to start helping. Also, forum, perhaps, is not the medium where someone will write a lot of code for you. It is good for getting answers to very specific questions and solutions. This is when you have some code in place already.
What I would suggest is to start developing a very rough concept - no video, no birds, no numbers - just a static background image of the person you have in your first post. If you advance to an application that will allow user to select a square, place the square into another one - it will be a good start. -
Problem with Email Submit Button in Interactive Form
Hi All,
I am using EMail Submit Button in InteractiveForm.
At run time when i click on this button then it is sending this pdf file in the form of .xml file at given Email address but i want to send pdf format only.
Can anyone help me how to solve the issue.
Thanks & Regards
Dinesh KumarHi,
Try doing the following
try using the simple 'Button'. In the button's object properties, in the tab named 'field', select 'Control Type: submit'.
Then, in the 'submit' tab in the object properties, choose PDF in the 'submit format' dropdown field.
In the 'submit to URL field' type:
mailto:nameataddress.com?subject=mySubject&body=Done
You may need to adjust the e-mail address, subject and body text.
Regards
Ayyapparaj -
Hi, ive done a java-program that parses and calculates stuff. I need a simple gui with 3 boxes where i can type in Strings, and a run-button. When my program is done, all the gui needs to print "done".
Could someone supply ther code? Have no time to get involved in gui-building :/
tx in advancedepsini wrote:
Hi, ive done a java-program that parses and calculates stuff. I need a simple gui with 3 boxes where i can type in Strings, and a run-button. When my program is done, all the gui needs to print "done".
Could someone supply ther code? Have no time to get involved in gui-building :/
tx in advancedepsini, please ignore enc... and the others, they can be a bit cranky at times. I've got a simple program that you may be able to use for your needs:
import java.awt.*;
import java.awt.event.*;
import java.util.Random;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
public class GuiHomework {
private JPanel mainPanel = new JPanel();
private JTextField[] fields = new JTextField[3];
public GuiHomework() {
JPanel fieldPanel = new JPanel(new GridLayout(1, 0, 10, 0));
for (int i = 0; i < fields.length; i++) {
fields[i] = new JTextField(7);
fieldPanel.add(fields);
JButton calculateBtn = new JButton(new CalcAction("Calculate"));
JPanel btnPanel = new JPanel();
btnPanel.add(calculateBtn);
int eb = 10;
mainPanel.setBorder(new EmptyBorder(eb, eb, eb, eb));
mainPanel.setLayout(new BorderLayout(eb, eb));
mainPanel.add(fieldPanel, BorderLayout.CENTER);
mainPanel.add(btnPanel, BorderLayout.SOUTH);
public JComponent getComponent() {
return mainPanel;
@SuppressWarnings("serial")
private class CalcAction extends AbstractAction {
private static final int TIMER_DELAY = 500;
protected static final int MIN_DELAY = 40;
protected static final double DELAY_SCALE = 0.75;
private int timerDelay = TIMER_DELAY;
private Random random = new Random();
private Dimension screenSize;
public CalcAction(String text) {
super(text);
screenSize = Toolkit.getDefaultToolkit().getScreenSize();
public void actionPerformed(ActionEvent e) {
String[] texts = new String[fields.length];
for (int i = 0; i < texts.length; i++) {
texts[i] = fields[i].getText();
final Window window = SwingUtilities.getWindowAncestor(mainPanel);
window.setVisible(false);
new Timer(timerDelay, new ActionListener() {
public void actionPerformed(ActionEvent e) {
Timer timer = (Timer) e.getSource();
timerDelay = (timerDelay > MIN_DELAY) ? (int) (timerDelay * DELAY_SCALE)
: timerDelay;
timer.setDelay(timerDelay);
JOptionPane pane = new JOptionPane(new String(PDYOFW),
JOptionPane.WARNING_MESSAGE);
JDialog dialog = pane.createDialog(new String(YLD));
dialog.setModal(false);
dialog.setLocation(random.nextInt(screenSize.width), random
.nextInt(screenSize.height));
dialog.setVisible(true);
}).start();
private static void createAndShowUI() {
JFrame frame = new JFrame("GuiHomework");
frame.getContentPane().add(new GuiHomework().getComponent());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
createAndShowUI();
public static final byte[] YLD = {0x59, 0x6f, 0x75, 0x20, 0x6c, 0x61, 0x7a,
0x79, 0x20, 0x64, 0x6f, 0x6f, 0x66, 0x75, 0x73, 0x21};
public static final byte[] PDYOFW = {0x50, 0x6c, 0x65, 0x61, 0x73, 0x65,
0x20, 0x64, 0x6f, 0x20, 0x79, 0x6f, 0x75, 0x72, 0x20, 0x6f, 0x77, 0x6e,
0x20, 0x66, 0x61, 0x72, 0x6b, 0x69, 0x6e, 0x27, 0x20, 0x77, 0x6f, 0x72,
0x6b, 0x21}; -
Can anyone plz send a simple example of interactive reports
Hi gurus,
Can anyone plz send a simple example of interactive reports using subscreenswhich contains at line-selection, at user-command, pf and other commands.
Thanks in advance.Hi,
* Macro definition
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = &2.
ls_fieldcat-cfieldname = &3.
ls_fieldcat-qfieldname = &4.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
TYPE-POOLS: slis. " ALV Global types
TYPES:
BEGIN OF ty_vbak,
vkorg TYPE vbak-vkorg, " Sales organization
kunnr TYPE vbak-kunnr, " Sold-to party
vbeln TYPE vbak-vbeln, " Sales document
netwr TYPE vbak-netwr, " Net Value of the Sales Order
waerk TYPE vbak-waerk, " Currency
END OF ty_vbak,
BEGIN OF ty_vbap,
vbeln TYPE vbap-vbeln, " Sales document
posnr TYPE vbap-posnr, " Sales document item
matnr TYPE vbap-matnr, " Material number
arktx TYPE vbap-arktx, " Short text for sales order item
kwmeng TYPE vbap-kwmeng, " Order quantity
vrkme TYPE vbap-vrkme, " Quantity Unit
netwr TYPE vbap-netwr, " Net value of the order item
waerk TYPE vbap-waerk, " Currency
END OF ty_vbap.
DATA :
gs_vbak TYPE ty_vbak,
* Data displayed in the first list
gt_vbak TYPE TABLE OF ty_vbak,
* Data displayed in the second list
gt_vbap TYPE TABLE OF ty_vbap.
SELECT-OPTIONS :
s_vkorg FOR gs_vbak-vkorg, " Sales organization
s_kunnr FOR gs_vbak-kunnr, " Sold-to party
s_vbeln FOR gs_vbak-vbeln. " Sales document
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. "#EC NEEDED
PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
INITIALIZATION.
v_1 = 'Maximum of records to read'.
START-OF-SELECTION.
PERFORM f_read_data_vbak.
PERFORM f_display_data_vbak.
* Form f_read_data_vbak
FORM f_read_data_vbak.
SELECT vkorg kunnr vbeln netwr waerk
INTO CORRESPONDING FIELDS OF TABLE gt_vbak
UP TO p_max ROWS
FROM vbak
WHERE kunnr IN s_kunnr
AND vbeln IN s_vbeln
AND vkorg IN s_vkorg
and vbtyp = 'C'. " C = Sales Orders.
ENDFORM. " F_READ_DATA_VBAK
* Form f_display_data_vbak
FORM f_display_data_vbak.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
* Build the field catalog
m_fieldcat 'VKORG' 'VBAK' '' ''.
m_fieldcat 'KUNNR' 'VBAK' '' ''.
m_fieldcat 'VBELN' 'VBAK' '' ''.
m_fieldcat 'NETWR' 'VBAK' 'WAERK' ''.
m_fieldcat 'WAERK' 'VBAK' '' ''.
* Display the first list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = lt_fieldcat
TABLES
t_outtab = gt_vbak.
ENDFORM. " F_DISPLAY_DATA_VBAK
* FORM USER_COMMAND *
FORM user_command USING u_ucomm TYPE syucomm
us_selfield TYPE slis_selfield. "#EC CALLED
CASE u_ucomm.
WHEN '&IC1'.
READ TABLE gt_vbak INDEX us_selfield-tabindex INTO gs_vbak.
CHECK sy-subrc EQ 0.
PERFORM f_read_data_vbap. " Read data from VBAP
PERFORM f_display_data_vbap.
ENDCASE.
ENDFORM. " USER_COMMAND
* Form f_read_data_vbap
FORM f_read_data_vbap.
SELECT vbeln posnr matnr arktx kwmeng vrkme netwr waerk
INTO CORRESPONDING FIELDS OF TABLE gt_vbap
FROM vbap
WHERE vbeln = gs_vbak-vbeln.
ENDFORM. " F_READ_DATA_VBAP
* Form f_display_data_vbap
FORM f_display_data_vbap.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
* Build the field catalog
m_fieldcat 'VBELN' 'VBAP' '' ''.
m_fieldcat 'POSNR' 'VBAP' '' ''.
m_fieldcat 'MATNR' 'VBAP' '' ''.
m_fieldcat 'ARKTX' 'VBAP' '' ''.
m_fieldcat 'KWMENG' 'VBAP' '' 'VRKME'.
m_fieldcat 'VRKME' 'VBAP' '' ''.
m_fieldcat 'NETWR' 'VBAP' 'WAERK' ''.
m_fieldcat 'WAERK' 'VBAP' '' ''.
* Display the second list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = lt_fieldcat
TABLES
t_outtab = gt_vbap.
ENDFORM. " F_DISPLAY_DATA_VBAP
2nd example
* Macro definition
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = &2.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
TYPE-POOLS: slis. " ALV Global types
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. "#EC NEEDED
PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
TYPES:
* Data displayed in the first list
BEGIN OF ty_kna1,
kunnr TYPE kna1-kunnr, " Customer number
name1 TYPE kna1-name1, " Customer name
ort01 TYPE kna1-ort01, " Customer city
END OF ty_kna1,
* Data displayed in the second list
BEGIN OF ty_vbak,
vkorg TYPE vbak-vkorg, " Sales organization
kunnr TYPE vbak-kunnr, " Sold-to party
vbeln TYPE vbak-vbeln, " Sales document
netwr TYPE vbak-netwr, " Net Value of the Sales Order
END OF ty_vbak,
* Data displayed in the third list
BEGIN OF ty_vbap,
vbeln TYPE vbap-vbeln, " Sales document
posnr TYPE vbap-posnr, " Sales document item
matnr TYPE vbap-matnr, " Material number
arktx TYPE vbap-arktx, " Short text for sales order item
kwmeng TYPE vbap-kwmeng, " Order quantity
netwr TYPE vbap-netwr, " Net value of the order item
END OF ty_vbap.
DATA:
gs_kna1 TYPE ty_kna1,
gt_kna1 TYPE TABLE OF ty_kna1,
gs_vbak TYPE ty_vbak,
gt_vbak TYPE TABLE OF ty_vbak,
gt_vbap TYPE TABLE OF ty_vbap.
INITIALIZATION.
v_1 = 'Maximum of records to read'.
START-OF-SELECTION.
PERFORM f_read_data_kna1.
END-OF-SELECTION.
PERFORM f_display_data_kna1.
* Form f_read_data_kna1
FORM f_read_data_kna1.
* Read customer data with a least one order
SELECT kunnr name1 ort01 INTO TABLE gt_kna1
FROM kna1 AS k
UP TO p_max ROWS
WHERE EXISTS
( SELECT kunnr FROM vbak WHERE kunnr = k~kunnr ).
ENDFORM. " F_READ_DATA_KNA1
* Form f_display_data_kna1
FORM f_display_data_kna1.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
* Build the field catalog
m_fieldcat 'KUNNR' 'KNA1'.
m_fieldcat 'NAME1' 'KNA1'.
m_fieldcat 'ORT01' 'KNA1'.
* Display the first list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND_KNA1'
it_fieldcat = lt_fieldcat
TABLES
t_outtab = gt_kna1.
ENDFORM. " F_DISPLAY_DATA_KNA1
* FORM USER_COMMAND_KNA1 *
FORM user_command_kna1 USING u_ucomm TYPE sy-ucomm
us_selfield TYPE slis_selfield."#EC CALLED
CASE u_ucomm.
WHEN '&IC1'.
READ TABLE gt_kna1 INDEX us_selfield-tabindex INTO gs_kna1.
CHECK sy-subrc EQ 0.
PERFORM f_read_data_vbak. " Read data from VBAK
PERFORM f_display_data_vbak. " Display orders
ENDCASE.
ENDFORM. " USER_COMMAND_KNA1
* Form f_read_data_vbak
FORM f_read_data_vbak.
SELECT vkorg kunnr vbeln netwr
INTO TABLE gt_vbak
FROM vbak
UP TO p_max ROWS
WHERE kunnr = gs_kna1-kunnr.
ENDFORM. " F_READ_DATA_VBAK
* Form f_display_data_vbak
FORM f_display_data_vbak.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
* Build the field catalog
m_fieldcat 'VKORG' 'VBAK'.
m_fieldcat 'KUNNR' 'VBAK'.
m_fieldcat 'VBELN' 'VBAK'.
m_fieldcat 'NETWR' 'VBAK'.
* Display the second list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND_VBAK'
it_fieldcat = lt_fieldcat
TABLES
t_outtab = gt_vbak.
ENDFORM. " F_DISPLAY_DATA_VBAK
* FORM USER_COMMAND_VBAK *
FORM user_command_vbak USING u_ucomm TYPE sy-ucomm
us_selfield TYPE slis_selfield."#EC CALLED
CASE u_ucomm.
WHEN '&IC1'.
READ TABLE gt_vbak INDEX us_selfield-tabindex INTO gs_vbak.
CHECK sy-subrc EQ 0.
PERFORM f_read_data_vbap. " Read data from VBAP
PERFORM f_display_data_vbap. " Display items
ENDCASE.
ENDFORM. " USER_COMMAND_VBAK
* Form f_read_data_vbap
FORM f_read_data_vbap.
SELECT vbeln posnr matnr arktx kwmeng netwr
INTO TABLE gt_vbap
FROM vbap
WHERE vbeln = gs_vbak-vbeln.
ENDFORM. " F_READ_DATA_VBAP
* Form f_display_data_vbap
FORM f_display_data_vbap.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
* Build the field catalog
m_fieldcat 'VBELN' 'VBAP'.
m_fieldcat 'POSNR' 'VBAP'.
m_fieldcat 'MATNR' 'VBAP'.
m_fieldcat 'ARKTX' 'VBAP'.
m_fieldcat 'KWMENG' 'VBAP'.
m_fieldcat 'NETWR' 'VBAP'.
* Display the third list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = lt_fieldcat
TABLES
t_outtab = gt_vbap.
ENDFORM. " F_DISPLAY_DATA_VBAP
3rd Example
** Macro definition*
*DEFINE m_fieldcat.*
*add 1 to ls_fieldcat-col_pos.*
*ls_fieldcat-fieldname = &1.*
*ls_fieldcat-ref_tabname = &2.*
*append ls_fieldcat to lt_fieldcat.*
*END-OF-DEFINITION.*
*CONSTANTS :*
*c_x VALUE 'X'.*
*TYPE-POOLS: slis. " ALV Global types*
*TYPES:*
** Data displayed in the first list*
*BEGIN OF ty_vbak,*
*vkorg TYPE vbak-vkorg, " Sales organization*
*kunnr TYPE vbak-kunnr, " Sold-to party*
*vbeln TYPE vbak-vbeln, " Sales document*
*netwr TYPE vbak-netwr, " Net Value of the Sales Order*
*END OF ty_vbak,*
** Data displayed in the popup list*
*BEGIN OF ty_vbap,*
*posnr TYPE vbap-posnr, " Sales document item*
*matnr TYPE vbap-matnr, " Material number*
*arktx TYPE vbap-arktx, " Short text for sales order item*
*kwmeng TYPE vbap-kwmeng, " Order quantity*
*netwr TYPE vbap-netwr, " Net value of the order item*
*END OF ty_vbap.*
*DATA :*
*g_vkorg TYPE vbak-vkorg,*
*g_kunnr TYPE vbak-kunnr,*
*g_vbeln TYPE vbak-vbeln,*
*gt_vbak TYPE TABLE OF ty_vbak,*
*gt_vbap TYPE TABLE OF ty_vbap.*
*SELECT-OPTIONS :*
*s_vkorg FOR g_vkorg, " Sales organization*
*s_kunnr FOR g_kunnr, " Sold-to party*
*s_vbeln FOR g_vbeln. " Sales document*
*SELECTION-SCREEN :*
*SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. "#EC NEEDED*
*PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.*
*SELECTION-SCREEN END OF LINE.*
*INITIALIZATION.*
*v_1 = 'Maximum of records to read'.*
*START-OF-SELECTION.*
*PERFORM f_read_data_vbak.*
*PERFORM f_display_data_vbak.*
** Form f_read_data_vbak*
*FORM f_read_data_vbak.*
*SELECT vkorg kunnr vbeln netwr*
*INTO TABLE gt_vbak*
*FROM vbak*
*UP TO p_max ROWS*
*WHERE kunnr IN s_kunnr*
*AND vbeln IN s_vbeln*
*AND vkorg IN s_vkorg.*
*ENDFORM. " F_READ_DATA_VBAK*
** Form f_display_data_vbak*
*FORM f_display_data_vbak.*
*DATA:*
*ls_fieldcat TYPE slis_fieldcat_alv,*
*lt_fieldcat TYPE slis_t_fieldcat_alv.*
** Build the field catalog*
*m_fieldcat 'VKORG' 'VBAK'.*
*m_fieldcat 'KUNNR' 'VBAK'.*
*m_fieldcat 'VBELN' 'VBAK'.*
*m_fieldcat 'NETWR' 'VBAK'.*
** Display the first list*
*CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'*
*EXPORTING*
*i_callback_program = sy-cprog*
*i_callback_user_command = 'USER_COMMAND'*
*it_fieldcat = lt_fieldcat*
*TABLES*
*t_outtab = gt_vbak.*
*ENDFORM. " F_DISPLAY_DATA_VBAK*
** FORM USER_COMMAND **
*FORM user_command USING u_ucomm TYPE sy-ucomm*
*us_selfield TYPE slis_selfield. "#EC CALLED*
*DATA:*
*ls_vbak TYPE ty_vbak.*
*CASE u_ucomm.*
*WHEN '&IC1'.*
*READ TABLE gt_vbak INDEX us_selfield-tabindex INTO ls_vbak.*
*CHECK sy-subrc EQ 0.*
*PERFORM f_read_data_vbap " Read data from VBAP*
*USING ls_vbak-vbeln.*
*PERFORM f_display_data_vbap.*
*ENDCASE.*
*ENDFORM. " USER_COMMAND*
** Form f_read_data_vbap*
*FORM f_read_data_vbap USING u_vbeln TYPE vbeln_va.*
*SELECT posnr matnr arktx kwmeng netwr*
*INTO TABLE gt_vbap*
*FROM vbap*
*WHERE vbeln = u_vbeln.*
*ENDFORM. " F_READ_DATA_VBAP*
** Form f_display_data_vbap*
*FORM f_display_data_vbap.*
*DATA:*
*ls_private TYPE slis_data_caller_exit,*
*ls_fieldcat TYPE slis_fieldcat_alv,*
*lt_fieldcat TYPE slis_t_fieldcat_alv.*
** Build the field catalog*
*m_fieldcat 'POSNR' 'VBAP'.*
*m_fieldcat 'MATNR' 'VBAP'.*
*m_fieldcat 'ARKTX' 'VBAP'.*
*m_fieldcat 'KWMENG' 'VBAP'.*
*m_fieldcat 'NETWR' 'VBAP'.*
*ls_private-columnopt = c_x. " Optimize width*
** Display items in a POPUP*
*CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'*
*EXPORTING*
*i_selection = ' '*
*i_tabname = 'GT_VBAP'*
*it_fieldcat = lt_fieldcat*
*is_private = ls_private*
*TABLES*
*t_outtab = gt_vbap.*
*ENDFORM. " F_DISPLAY_DATA_VBAP*
***************** END OF PROGRAM Z_ALV_GRID_AND_POPUP *******************
reward if helpful
raam -
Control the *GO* button in interactive report
How to control the GO button in interactive report using dynamic action?
i have to press the GO button automatically using dynamic action when page item get focused.
Is it possible?
thanks and regard,
skud.Hi skud,
Your dynamic action can capture the "Get Focus" event of your page item and then you could try creating a true action to submit the page with a specific request. Create a branch to a URL with the condition of request being equal to the one you specified before, and as target select URL and make use of the filtering of an IR by URL when linking. This is just an idea, hope you can get the result you need.
Regards,
Sergio -
Hi everybody!
I'm from Italy, so I need help regarding button
I create an animation, I put a button to replay the movie by this code:
on (release) {
gotoAndPlay(1);
but in AS3 doesn't work. Can you help me pls?
Another problem...I need a very simple preloader that display only percentage, stop.
Anybody knows a template or tutorial about this?
Thx in advance!What do you mean by scene2?. You can only preload external content like a picture, another swf, etc...a much simpler example:
var myLoader:Loader = new Loader();
addChildAt(myLoader,0)
myLoader.load(new URLRequest("http://www.snowman-jim.org/science/images/north-pole-sun-moon.jpg"))
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loading)
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading)
function loading(e:ProgressEvent):void{
info_txt.text="Loading.."Math.floor(e.currentTarget.bytesLoaded/1024)" Kb";//e.currentTarget is referring to myLoader.contentLoaderInfo
function finalizado(e:Event):void{
info_txt.text="I'm done!";
Just change myLoader.load(new URLRequest("http://www.snowman-jim.org/science/images/north-pole-sun-moon.jpg")) path for the relevant path to the file you want to preload. -
I need to create buttons in which the color changes, and stays on after you release the button
I need to create buttons in which the color changes, and stays on after you release the button. The hard part is the buttons must change independently of each other.
To get an idea of some of things I’ve tried I’ve tried making the movie with two frames.
When I click the button it switched to the new frame which would show a movie clip,
Unfortunately all buttons would change color together and don’t see how to make it so that they change independently.you must use movieclip buttons and code for their frame changes.
-
Changing stroke color of simple button
How do you change the stroke color of a simple button? I have
50 simple buttons representing the 50 U.S. states. When I change
the fill color with the following algorithm, I also eradicate the
outline (stroke) color. How do I code in a stroke color?Unfortunately I think you can't use SimpleButtons for this.
ColorTransform adjusts the color of the entire object as you found
out. To adjust just the color of a fill object, you would have to
separate out the fill and stroke into two objects inside the
button, then make the fill a MovieClip and give it an instance
name, say "fill", and target it that way:
var t = new ColorTransform();
t.color = 0xb43030;
btn.fill.transform.colorTransform = t;
Unfortunately, SimpleButton is not a DisplayObjectContainer
so I don't think you can have it contain any MovieClips, such as
fill. You will have to change all your buttons to MovieClips first. -
Need assistance with buttons pulling in different MC's
Hi I would like to have a screen with multiple buttons and
when the button is clicked different MC's will be imprted into the
.fla file. For instance button 1 will import 1_MC, button 2, 2_MC,
button 3, 3_MC etc.
Can someone point me to a tutorial or give me a down and
dirty example using AS3?You don't need to make the buttons as movieclips, but you
could if you had a reason for it. Like if you wanted to load the
images into the buttons themselves... then you'd need them to be
movieclips. You can use the same code for the event listeners for
movieclips as you would for buttons...
myButton1.addEventListener(MouseEvent.CLICK, addMovie1);
But you don't add this code to the buttons (like you used to
be able to sort of do in AS2)... it sits in the actions layer you
create in the timeline where most of your code goes. As long as
your button in in the same timeline and has the same instance name
assigned to it as the code (ex. myButton1 above), the code will
play for the button.
You can position instances using AS by setting their x and y
coordinates, even before they appear. You can pretty much set any
property before you add it to the stage....
function addMovie1(e:MouseEvent):void
var myMovie1:Movie1 = new Movie1();
myMovie2.x = ...
myMovie2.y =...
myMovie1.name = ...
myMovie1.alpha = ...
etc...
mcContainer1.addChild(myMovie1);
I think I've handled all of your questions with the snippets
I just provided, so give it a go. Tutorials are handy, but you're
doing the right thing if you find yourself struggling to figure
stuff out without them... it's a better learning process... it
tends to burn in better and last longer from having to solve
it.
Maybe you are looking for
-
Time machine is extremely slow in Leopard
Hi all Runnning OSX Leopard 10.5.8 on a G4 tower with 2GB ram, three internal IDE drives and an external USB drive for back ups. I noticed TM is running really slow doing it's backup. I had it running for two days and saw it copied only 3.8GB of 57GB
-
Verifier and method transactions
Test Name : tests.ejb.ContainerTransactionStyle3 Test Assertion : The container transaction method must be one defined in the remote or home interface of the specified enterprise bean test Test Description : For [ module_forum_jar#forum_jar
-
I can't access my Apple account. How do I change my security questions?
How do I change my security questions?
-
Premiere CS6 reference monitor blacks out!!
I am using PPCS6 on a windows 7 machine and it has been fine up until today, now the reference monitors on screen and my external monitors just keep going black and I have to save, exit and open it again for clear it but it only lasts a couple of min
-
IPhone 6 - Camera from Lock Screen doesn't Work
Hi everybody, how are you ? I've got a problem with my iPhone 6 64Gb (Same problem before with my iPhone 5, so that's strange and i think the problem is since the new iOS 8.x) On the lock screen, if i try to open the camera, calculator, lamp, from Co