Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8610563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:09:48+00:00 2026-06-12T04:09:48+00:00

I have a Flex 4.5 AIR project, and I want to create a component

  • 0

I have a Flex 4.5 AIR project, and I want to create a component that uses stage3D.
I could manage to get the triangle example work in an Actionscript project for flash player, but I couldn’t get it to work with a clean Flex Project either. It goes into the render loop, but its not visible:

main mxml:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark"  creationComplete="application1_initializeHandler(event)"
           xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
    <![CDATA[
        import mx.events.FlexEvent;

        protected function application1_initializeHandler(event:FlexEvent):void
        {
            addEventListener(Event.ADDED_TO_STAGE, init)

        }

        protected function init(e:Event=null):void {
            addElement(new triangle1(stage))
        }

    ]]>
</fx:Script>

triangle.as:
package
{
import com.adobe.utils.AGALMiniAssembler;

import flash.display.Sprite;
import flash.display.Stage;
import flash.display3D.Context3D;
import flash.display3D.Context3DProgramType;
import flash.display3D.Context3DVertexBufferFormat;
import flash.display3D.IndexBuffer3D;
import flash.display3D.Program3D;
import flash.display3D.VertexBuffer3D;
import flash.events.Event;
import flash.geom.Matrix3D;
import flash.geom.Rectangle;
import flash.geom.Vector3D;
import flash.utils.getTimer;

import mx.core.UIComponent;

public class triangle1 extends UIComponent
{
    protected var context3D:Context3D;
    protected var program:Program3D;
    protected var vertexbuffer:VertexBuffer3D;
    protected var indexbuffer:IndexBuffer3D;

    public function triangle1(stage:Stage)
    {           
        super();
        stage.stage3Ds[0].addEventListener( Event.CONTEXT3D_CREATE, initMolehill );
        stage.stage3Ds[0].requestContext3D();

        addEventListener(Event.ENTER_FRAME, onRender);

    }

    protected function initMolehill(e:Event):void
    {
        context3D = stage.stage3Ds[0].context3D;            
        context3D.configureBackBuffer(800, 600, 1, true);

        var vertices:Vector.<Number> = Vector.<Number>([
            -0.3,-0.3,0, 1, 0, 0, // x, y, z, r, g, b
            -0.3, 0.3, 0, 0, 1, 0,
            0.3, 0.3, 0, 0, 0, 1]);

        // Create VertexBuffer3D. 3 vertices, of 6 Numbers each
        vertexbuffer = context3D.createVertexBuffer(3, 6);
        // Upload VertexBuffer3D to GPU. Offset 0, 3 vertices
        vertexbuffer.uploadFromVector(vertices, 0, 3);              

        var indices:Vector.<uint> = Vector.<uint>([0, 1, 2]);

        // Create IndexBuffer3D. Total of 3 indices. 1 triangle of 3 vertices
        indexbuffer = context3D.createIndexBuffer(3);           
        // Upload IndexBuffer3D to GPU. Offset 0, count 3
        indexbuffer.uploadFromVector (indices, 0, 3);           

        var vertexShaderAssembler : AGALMiniAssembler = new AGALMiniAssembler();
        vertexShaderAssembler.assemble( Context3DProgramType.VERTEX,
            "m44 op, va0, vc0\n" + // pos to clipspace
            "mov v0, va1" // copy color
        );          

        var fragmentShaderAssembler : AGALMiniAssembler= new AGALMiniAssembler();
        fragmentShaderAssembler.assemble( Context3DProgramType.FRAGMENT,

            "mov oc, v0"
        );

        program = context3D.createProgram();
        program.upload( vertexShaderAssembler.agalcode, fragmentShaderAssembler.agalcode);
    }   

    protected function onRender(e:Event):void
    {
        if ( !context3D ) 
            return;

        context3D.clear ( 1, 1, 1, 1 );

        // vertex position to attribute register 0
        context3D.setVertexBufferAt (0, vertexbuffer, 0, Context3DVertexBufferFormat.FLOAT_3);
        // color to attribute register 1
        context3D.setVertexBufferAt(1, vertexbuffer, 3, Context3DVertexBufferFormat.FLOAT_3);
        // assign shader program
        context3D.setProgram(program);

        var m:Matrix3D = new Matrix3D();
        m.appendRotation(getTimer()/40, Vector3D.Z_AXIS);
        context3D.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX, 0, m, true);

        context3D.drawTriangles(indexbuffer);

        context3D.present();            
    }
}
}

any ideas? no errors, and it traces onRender, so its just not visible.. :S

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:09:49+00:00Added an answer on June 12, 2026 at 4:09 am
     <s:Application ....  backgroundAlpha="0"
    

    fixed it 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a windowed Flex application (AIR) that uses an HTML file for the
We have a air/flex app that we want to add an effect to. Basically
I have a Flex AIR project that compiles and runs in Flex Builder 4.6.
I have implemented some utility classes in Flex that I want to use in
I have a project where I need to create a desktop app that acts
I have a AIR for mobile pure AS3 project that saves a file on
I have no experience with Adobe Air/Flex and want to know, are there some
I have an ActionScript only Flex project that was written by someone else. I
I have a flex .swf and a seperate AIR project which I'm trying to
I've been using the Flex HTML component in my AIR 2.7 project. It's a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.