Hey guys, I just registered here because as a self-taught actionscripter I kept coming back to these forums for advice. I’m a big novice so I appreciate the hand holding:)
(If you’re new to this post, I’ve edited it completely after fixing something)
My biggest problem is that I just don’t know how to script the following:
Essentially I have a series of video paths and a series of corresponding thumbnails. I want to be able to click on a thumbnail and the corresponding video path be loaded into my FLVplayback component. The complexity, at least from my standpoint, comes from the fact that I am trying to pass the video path from one package to another.
All this to say, I’m really stuck and I’m a big newbie, so any help would be great!
Here’s the updated, but still unsuccessful code. Compiler works, I just have to figure out how to tell flvplayer to load and play the right movie on CLICK.
Note: ThirdParty Class feeds into SecondParty Class which feeds into Main Class.
-------------------------------------------------------
//Main.as
-------------------------------------------------------
package
{
import com.actionscriptnotes.containers.SecondParty;
import flash.display.*;
public class Main extends MovieClip
{
public var New_SecondParty:SecondParty = new SecondParty();
public function Main()
{
trace("reading Main");
addChild(New_SecondParty);
}
}
}
------------------------------------------------------
//SecondParty.as
------------------------------------------------------
package com.actionscriptnotes.containers
{
import com.actionscriptnotes.containers.ThirdParty;
import fl.video.FLVPlayback;
import flash.display.*;
public class SecondParty extends MovieClip
{
public var temp:String;
public var flvPlayer:FLVPlayback;
//--QUESTION--//
//"SPS_StringInsertion_01.flv" is temporarily in this spot, but
//what should I do here to receive the correct videopath for my flvplayer.source?
//I've tried putting the passed variable "temp" it into another variable and
//setting flvplayer.source equal to that new variable, but flvplayer is blank
//and no video is loaded on CLICK. Is that close to what I'm suppose to do?[/color]
public var myThirdParty:ThirdParty = new ThirdParty("SPS_StringInsertion_01.flv");
//FLVPLAYBACK INSTANCE AND LOCATION OF flvplayer.source
public function FLVp():void
{
flvPlayer = new FLVPlayback();
addChild(flvPlayer);
flvPlayer.skin = "./com/video/SkinUnderAllNoFullScreen.swf"
flvPlayer.autoPlay = false;
flvPlayer.scaleX = 2;
flvPlayer.scaleY = 2;
flvPlayer.x = 20;
flvPlayer.y = 160;
flvPlayer.skinBackgroundColor = 0x333333;
flvPlayer.skinBackgroundAlpha = 0.5;
trace("reading SecondParty_2")
//This loads and plays "SPS_StringInsertion_01.flv", but is not set up to load on CLICK.
flvPlayer.source = myThirdParty.temp;
trace("reading SecondParty_3 : " + myThirdParty.temp);
}
//SECONDPARTY CLASS FUNCTION
public function SecondParty()
{
addChild(myThirdParty);
trace("reading SecondParty_1");
FLVp();//Computer reads this function now.
}
}
}
-------------------------------------------------------------
ThirdParty.as
-------------------------------------------------------------
package com.actionscriptnotes.containers
{
import flash.display.*;
import flash.events.*;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.utils.getDefinitionByName;
public class ThirdParty extends MovieClip
{
public var myText:TextField;
public var txt_format:TextFormat;
public var temp:String;
public var thumb_spacing:Number=60;
public var thumb_size:Number = 100;
private var myWidth:Number;
public var base_container:Array = new Array();
//This is an Associative Array because it using string keys to identify elements.
private var thumbsArray:Object;
//GETTER/SETTER THAT RETURN VALUE OF temp
public function get letter():String
{
return temp;
}
public function set letter(videopath:String):void
{
temp = videopath;
}
//GETTER THAT RETURNS thumbsArray
public function get _thumbsArray():Object
{
return thumbsArray;
}
//TEXT TO APPEAR ON CLICK EVENT
public function setText():void
{
myText = new TextField();
myText.autoSize = TextFieldAutoSize.LEFT;
txt_format = new TextFormat();
txt_format.font = "bankgothic lt bt";
txt_format.size = 12;
txt_format.color = 0xFFCC66;
txt_format.bold = false;
myText.defaultTextFormat = txt_format;
addChild(myText);
trace("reading ThirdParty_2:setText called");
}
//CREATES A SERIES OF CONTAINERS FOR MY THUMBNAILS
public function createThumbs():void
{
trace("reading ThirdParty_3:createThumbs called and eventListener will be applied");
var i:uint;
var totalThumbs:Number = 2;
//myWidth declares the length in pixels of all the thumbnails + spacing
//(10 elements in the thumbsArray - 1 because of the number of spaces between the thumbnails)
//*20 px that was declared above) + (10*100 px of each thumb) = 180 + 1000 = 1180 pixels wide
this.myWidth = (this.thumbsArray.length - 1) * this.thumb_spacing + this.thumbsArray.length * 100;
for(i=0; i<totalThumbs; i++)
{
//Create a new movie clip to each hold a thumbnail
var thumb_container:MovieClip = new MovieClip();
//The name property specifies the instance name of the DisplayObject. It sets up an
//an instance name to later be traced.
thumb_container.name = String(i);
thumb_container.x = 20;
thumb_container.y = 20;
base_container.push(thumb_container);
//The following adds the thumb_container MovieClip to the Stage.
addChild(thumb_container);
//The following 4 lines converts Library symbols into Display Objects
var ClassReference:Class = getDefinitionByName(thumbsArray*.id) as Class;
var _thumb:Object = new ClassReference();
base_container*.addChild(DisplayObject(_thumb));
base_container*.addEventListener(MouseEvent.CLICK, clickAction);
_thumb.y = 30;
//these X and Y position values alter both the thumbs and the mask
base_container*.x = base_container*.initialX = i * (100 + this.thumb_spacing) + this.thumb_spacing/2;
base_container*.y = 0;
base_container*.useHandCursor = false;
}
}
//EVENT HANDLER
public function clickAction(event:MouseEvent):void
{
myText.text = "You have clicked on " +thumbsArray[event.target.parent.name].id;
myText.setTextFormat(txt_format);
if(_thumbsArray[event.target.parent.name].id == "thumb0")
{
trace(thumbsArray[event.target.parent.name].action);
//Output reads "SPS_StringInsertion_01.flv"
}
else if(_thumbsArray[event.target.parent.name].id == "thumb1")
{
trace(thumbsArray[event.target.parent.name].action);
//Output reads "SPS_SettingProcess_01.flv"
}
}
//THIRDPARTY CLASS FUNCTION
public function ThirdParty(videopath:String)
{
thumbsArray =
[{ id: 'thumb0', action: 'SPS_StringInsertion_01.flv' },
{ id: 'thumb1', action: 'SPS_SettingProcess_01.flv' }];
trace("reading ThirdParty_1");
setText();
createThumbs();
//drawButtons();
trace("reading ThirdParty_4");
temp = videopath;
trace("reading ThirdParty_5");
}
}
}
----------------------------------------------------------
Sorry for the length, but thanks so much for the help!
Deb