• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

HI Im trying to make my as3 start on a specific frame but for some reason I just cant find a solutio

Guest
Mar 12, 2014 Mar 12, 2014

Copy link to clipboard

Copied

THe below is the AS and i am trying to make it start on a specific frame, can anyone help me please?

package

{

import fl.controls.Button;

import flash.display.Bitmap;

import flash.display.Loader;

import flash.display.MovieClip;

import flash.net.FileFilter;

import flash.net.FileReference;

import flash.text.TextField;

import flash.text.TextFieldType;

import flash.events.MouseEvent;

import flash.events.Event;

public class BitmapLoader extends MovieClip

{

  private static const _MAX_WIDTH: Number = 640;

  private static const _MAX_HEIGHT:Number = 410;

  private var _fileRef:FileReference;

  private var _fileFilter: FileFilter;

  private var _loader: Loader;

  private var _bitmap:MovieClip;

  private var _browseBtn:Button;

  private var _staticTxt:TextField;

  private var _browseTxt:TextField;

  public function BitmapLoader( )

  {

   _init( );

  }

  private function _init( ):void

  {

   _staticTxt = new TextField ( );

   _staticTxt.type = TextFieldType.DYNAMIC;

   _staticTxt.x = 10;

   _staticTxt.y = 10;

   _staticTxt.height = 21;

   _staticTxt.text = "Select a Video:";

   addChild( _staticTxt );

   _browseTxt = new TextField ( ) ;

   _browseTxt.type = TextFieldType.INPUT;

   _browseTxt.x = _staticTxt.x + _staticTxt.width + 4;

   _browseTxt.y = 10;

   _browseTxt.height = 21;

   _browseTxt.width = 200;

   _browseTxt.border = true;

   _browseTxt.background = true;

   addChild( _browseTxt );

   _browseBtn = new Button ( ) ;

   _browseBtn.label = "Browse";

   _browseBtn.name = "browse";

   _browseBtn.x = _browseTxt.x + _browseTxt.width + 4;

   _browseBtn.y = 10;

   _browseBtn.useHandCursor = true;

   _browseBtn.addEventListener(MouseEvent.CLICK, _handleMouseEvent);

   addChild( _browseBtn );

   _fileFilter = new FileFilter("clips","*.swf;*.flv;*.f4v;*.mov;*.mp4");

  }

  private function _handleMouseEvent( evt : MouseEvent ):void

  {

   switch ( String ( evt.target.name ))

   {

    case "browse" :

     _fileRef = new FileReference ( ) ;

     _fileRef.browse( [_fileFilter]);

     _fileRef.addEventListener( Event.SELECT, _onImageSelect);

     trace( "Browse" );

     break;

   }

  }

  private function _onImageSelect( evt : Event ):void

  {

   _fileRef.load( );

   _fileRef.addEventListener(Event.COMPLETE, _onDataLoaded);

   _browseTxt.text = String(evt.target.name);

  }

  private function _onDataLoaded(evt:Event ):void

  {

   var tempFileRef:FileReference = FileReference(evt.target);

   _loader = new Loader( ) ;

   _loader.contentLoaderInfo.addEventListener( Event.COMPLETE, _onImageLoaded );

   _loader.loadBytes( tempFileRef.data );

  }

  private function _onImageLoaded(evt:Event ):void

  {

   _bitmap = MovieClip(evt.target.content);

   _bitmap.smoothing = true;

   _bitmap.x = 5;

   _bitmap.y = _browseTxt.y + _browseTxt.height + 5;

   addChild( _bitmap );

   if (_bitmap.width > _MAX_WIDTH || _bitmap.height > _MAX_HEIGHT)

   {

    _resizeBitmap( _bitmap );

   }

  }

  private function _resizeBitmap( target : MovieClip ):void

  {

   if (target.height > target.width)

   {

    target.width = _MAX_WIDTH;

    target.scaleY = target.scaleX;

   }

   else if (target.width >= target.height )

   {

    target.height = _MAX_HEIGHT;

    target.scaleX = target.scaleY;

   }

  }

}

}

TOPICS
ActionScript

Views

224

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 12, 2014 Mar 12, 2014

Copy link to clipboard

Copied

I'm confused. It looks like you're placing everything through ActionScript, so it would seem you don't really have a timeline involved. If you do have a timeline involved that's not reflected in your code, have you tried gotoAndPlay(someFrame)? I don't see anything like that in your code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 13, 2014 Mar 13, 2014

Copy link to clipboard

Copied

LATEST

I have a timeline with other assets in it. The assets were inserted using the codes that were available on the flash. However, I want this ActionScript to start on frame 81 and play. Do you know where I can add the gotoAndPlay(someFrame)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines