Dynamic text return
When I'm coding AS to add text to a dynamic text field, how
do I indicate that I want a line return (like, start a new line of
text)? I know there's a "break code" or something, but I can't
remember what it is. Thanks!...
"\r" or "\n"
Similar Messages
-
Linking a class to a dynamic text field to load XML data.
Hi,
I'm quite new to ActionScript and would be grateful for any help here.
I want to load text into a dynamic text field (called 'about_tab') using a class depending on the language selected (by clicking on a flag icon) by the user.
I managed to get this to work when the ActionScript was written directly in the timeline, but am having problems with doing the same thing via a class.
This is my class file:
package
import flash.display.SimpleButton;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.Event;
public class ChangeLang extends SimpleButton
public function ChangeLang()
addEventListener(MouseEvent.CLICK, switchLang);
trace("ChangeLang class working");
public function switchLang(event:MouseEvent):void
var lang = event.target.name;
var req:URLRequest = new URLRequest("languages/"+lang+".xml");
var loader:URLLoader = new URLLoader();
var substance:XML;
function xmlLoaded(event:Event):void
trace("function xmlLoaded is running");
substance = new XML(loader.data);
about_tab.text = substance.about_lbl;
loader.addEventListener(Event.COMPLETE, xmlLoaded);
loader.load(req);
Here's one of my XML files (the other is the same except "About" is written in German):
<substance>
<about_lbl>About</about_lbl>
</substance>
When I run it, it returns my trace statements that the class ChangeLang and the function xmlLoaded are running, but no text appears in the dynamic text field (I should/want to see the word 'About'). I get this error message:
1120: Access of undefined property about_tab
The problem, I'm guessing, is in the part in red in my code. I think I need to target the text field in the display list by creating a reference to it. If so, could someonw point out how I do this, or perhaps a tutorial that would help. I've tried adding the word stage (i.e.,stage.about_tab.text = substance.about_lbl; ) but it still doesn't connect. I guess there's something really simple I'm missing, so I apologize if this comes across as a stupid question
Thanks for any help.Hello flashrocket!
I'm also new to AS3 and I've just started using external classes and I think I know what you should do to put your code to work.
Instead of using the text field you created inside your flash file, why don't you use the "TextField" class to create an instance of this object? It's the exact same thing as when you create and instantiate a new text field inside Flash.
First, import flash.text.*; (includes classes like TextField, TextFieldAutoSize, TextFormat, TextFormatAlign, etc)
Than you just have to create a var like
public var about_tab : TextField;
or
public var about_tab : TextField = new TextField();
then, to adjust the properties of this tab you use dotsyntax as if it where on your stage like:
about_tab.x = 50; about_tab.alpha = .5; etc...
you can even create a function to "config your textField"
private function createAndConfigTextField() : void {
about_tab = new TextField(); //you only need this line if you
// only typed something like "public var about_tab:TextField;
// if instead you used "public var about_tab:TextField = new TextField(); outside
// this function, just skip this first line because you already have an instance of
// text field named "about_tab"...
about_tab.autoSize = TextFieldAutoSize.CENTER;
about_tab.background = true;
about_tab.border = true;
var aboutTextFormat : TextFormat = new TextFormat();
format.font = "Arial";
format.color = 0x000000;
format.size = 11;
format.bold = true;
format.align = TextFormatAlign.CENTER;
about_tab.defaultTextFormat = aboutTextFormat;
addChild(about_tab);
This is just an example of what you can do... I hope you get it... let me know if you have any doubt... -
Compiler errors when using dynamic text in a class
I have created a MovieClip with a custom class that has a dynamic text field (called "textArea"), which I want to modify by the Component Inspector, as well as via a custom method using:
textArea.text = newText;
It works fine in all cases and there are no problems, but the compiler still wants to give me the error:
1120: Access of undefined property textArea.
The error doesn't appear when I remove the component parameters (so that it's just a normal MovieClip). It still works, even with the error, so I'm not sure why it wants to complain. Am I doing something wrong or is it just being bitchy?By defining them in the class and using the class name under component definition:
[Inspectable(name="Text", type=String, defaultValue="")]
public function set text(setText:String)
textArea.text = setText;
public function get text():String
return textArea.text;
A problem I run into is that the compiler errors prevent the parameters from being defined so I comment out every line that has to do with textArea, define the component, then uncomment them so that it'll work when it runs. -
Linking Dynamic text boxes?
Hi there,
This might be straight forward, but I would like to know how could one link dynamic text boxes so that the information would flow? In a way, the information would flow from:
(XML) Input A into BOXA00, BOXA01, BOXA02, BOXA03, etc.
(XML) Input B into BOXB00, BOXB01, BOXB02, BOXB03, etc.
(XML) Input C into BOXC00, BOXC01, BOXC02, , BOXC03, etc.
Any takers?Hi i recently have made a function that can calculate the amount of text that will fit into a specified text box. See my attached file. Notice that the box will only accommodate the text in red since that is the maximum it can display.
"This here one is a very very very long long long text that cannot really fit completely into this box so we will have to cut it at some index point"
My function getTextExtent will return an object with properties
nIndex -> which determines the index at which the text will be delimited
fExceeded -> is true if the text is longer than the allocated height of the text field. -
Dynamic text wont show up in movie - as2
basically i have dynamic text fields that i have been trying to parse to an xml file. when i test the movie it does not work, all the fields are blank. but the info DOES show up in the output tab, so i know that it is making the connection.... it just doesnt show up in the movie. weird.
here is my actionscript:
var xml:XML=new XML();
xml.ignoreWhite=true;
xml.onLoad=parseXML;
xml.load("popup.xml");
function parseXML(){
trace(this);
if (success)
var diagramNode=this.firstChild;
var infoNode=diagramNode.childNodes[0];
var nameNode=infoNode.childNodes[1];
var ssnumberNode=infoNode.childNodes[2];
var descriptionNode=infoNode.childNodes[3];
var stockNode=infoNode.childNodes[4];
var priceNode=infoNode.childNodes[5];
var typeNode=infoNode.childNodes[6];
var qtyNode=infoNode.childNodes[7];
else {
content="oops, this stuff is confusing";
and here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<diagram>
<config>
</config>
<info>
<name>
Pedal Set With Toe Cage and Straps
</name>
<ssnumber>
P01LEM14139
</ssnumber>
<description>
Pedal set comes complete with both left and right pedals, toe cages and straps. Pedals have 9/16” shaft diameter where pedal threads into the crank arm.
</description>
<stock>
Item is in stock
</stock>
<price>
$15.95
</price>
<type>
EA
</type>
<qty>
1
</qty>
</items>
</diagram>
thanks, -mitchellok, i must have been doing it wrong. i ended up following a different tutorial and i rewrote it this way and it works great now!
function processXMLData(success)
if (success)
var rootNode=this.firstChild;
var nameNode=findNode(rootNode, "name");
name=getValue(nameNode);
var ssnumberNode=findNode(rootNode, "ssnumber");
ssnumber=getValue(ssnumberNode);
var descriptionNode=findNode(rootNode, "description");
description=getValue(descriptionNode);
var stockNode=findNode(rootNode, "stock");
stock=getValue(stockNode);
var priceNode=findNode(rootNode, "price");
price=getValue(priceNode);
var typeNode=findNode(rootNode, "type");
type=getValue(typeNode);
var qtyNode=findNode(rootNode, "qty");
qty=getValue(qtyNode);
else
content="oops, this is hard";
function getValue(node)
if (node && node.firstChild)
return node.firstChild.nodeValue;
return "";
function findNode(node, nodeName)
if (node.nodeName==nodeName)
return node;
for (var i=0; node.childNodes && i<node.childNodes.length; i++)
var foundNode=findNode(node.childNodes[i], nodeName);
if (foundNode!=null)
return foundNode;
return null;
var xmlData=new XML();
xmlData.ignoreWhite=true;
xmlData.onLoad=processXMLData;
xmlData.load("popup.xml");
stop(); -
I have a dynamic text box call "color.txt" at the root and
two Movie clip buttons one called Red and one called Yellow.
When I press the button the name of the button is passed to
the text box. When I press the second button the
name is not replaced. Do I have to create a seperate function
to do this or is there another way?
Thanks,
_root.red.onPress = function(){
_root.colorTxt.text = "Red";
_root.yellow.onPress = function(){
_root.colorTxt.text = "Yellow";
}I got it working like this.
var colors:Array = ["red", "yellow"];
var currentColor:Number;
function changeButton(newColor:Number) {
currentColor = newColor;
_root.colorTxt.text = updateText();
_root.red.onPress = function(){
changeButton(0);
_root.yellow.onPress = function(){
changeButton(1);
function updateText():String {
var newText:String;
newText = colors[currentColor];
return newText;
} -
Dynamic Text Feild with Dynamic Scroll Bar
I have a Dynamic Text Feild with a dynamic Scroll bar.
It loads a simple ASCI text file with some html formating.
but I still can not manage to get the text to format.
The biggest problem with the format is a big space between
paragraphs.
I am not sure why but I think the Frame must need a var to
render to html.
Can anybody help please?My text had the following, similar but no parsing string.
I guess
yourstring.split("\n\r").join("\r").split("\r\n").join("\r");
takes out the carrage returns or <br>?
I notice the one I had just say's String.
I assume that would be the text that is the string?
Thank you for sharing your knowledge of this.
var my_lv:LoadVars = new LoadVars();
my_lv.onData = function(src:String) {
if (src != undefined) {
myTxtFeild.text = src;
} else {
myTxtFile.text = "Error loading text.";
my_lv.load("CadnetPage1_html.txt"); -
Dynamic text box and minus variable?
I have a text box with dynamic text set to display p variable but when the variable goes < 0 it only displays a '-'.
im using:
onClipEvent (enterFrame) {
p = my_object._x;
How can I correct this? Also another question with 'my_object._x' it returns the x coord relative to the movie clip it is in. How do I get the position relative to the 0,0 (top left corner)?
I've been learning Flash for 2 days so sorry if the questions sound simple. I have tried googling these.for the textfield question....
I'm not too sure about that... it could be related to the width of the textfield, or maybe a maxChars setting on the textfield....not really sure sorry. Someone else may have an answer....
for the other question...
getRect() gives you the bounding box (without stroke width, use getBounds() if you want bounds outside the stroke width)
try
var geometricBounds = my_object.getRect();
trace(geometricBounds.xMin+","+geometricBounds.yMin) -
I am looking to create a good dynamic text scroller like the
one that
is a component. Any one have information on how to make one
it is
really appreciated.
Thanks
RandyIn your program and dynamic actions use structure RP50D for return dates (RP50D-DATE1 and RP50D-DATE2 to retrun values)
0000 06 75 I INS,0041,,,(RP50D-DATE1),(RP50D-DATE2)/D
0000 06 76 W P0041-DAR01='01'
0000 06 77 W P0041-DAT01=RP50D-DATE1
PROGRAM ZHPADYN.
TABLES : RP50D,
P0000,
P0041.
*& Form GET_DATE
* text
FORM GET_DATE .
DATA : I0041 LIKE P0041,
L_DAT LIKE P0041-DAT01,
L_DAR LIKE P0041-DAR01.
PERFORM READ_INFOTYPE(SAPFP50P) USING P0000-PERNR
'0041'
P0000-BEGDA
P0000-ENDDA
'1'
'NOP'
I0041.
DO 12 TIMES
VARYING L_DAR FROM I0041-DAR01 NEXT I0041-DAR02
VARYING L_DAT FROM I0041-DAT01 NEXT I0041-DAT02.
IF L_DAR = 'HR'.
RP50D-DATE1 = L_DAT.
ENDIF.
IF L_DAR = 'PE'.
RP50D-DATE2 = L_DAT.
ENDIF.
ENDDO.
ENDFORM. "GET_DATE
Hope this helps,
Puneet -
I'm having a small problem in my dynamic text box. For some
reason numbers are not being displayed correctly. I am working with
the Render Text as HTML box checked and am trying to get this
result :
01/15/09: No Meeting
01/15/09: Camping Trip
simple enough, however this is what i am ending up with:
1/1/: No Meeting
1/1/: Camping Trip
Here is the code i am using which returns the above result:
main_info.htmlText ="<p>01/15/09: No
Meeting</p>01/15/09: Camping Trip";
For whatever reason its not liking my numbers, is there
something that i am supposed to put in front of a set of numbers so
it displays it without thinking it is html code ?
Thanks for any help you can offer.I use this piece of code:
//Load Text
Stage.scaleMode = "noScale";
articleData = new LoadVars();
articleData.onLoad = function() {
box.htmlText = this.job1;
title.htmlText = this.title;
And its works fine on my computer(local), but when i upload
the files the text
dont appear.
I have tried to do another swf to test and the problem still
and i try to use
http://....same problem -
I am using Dreamweaver MX and ASP.Net to create a data driven
website. I have created a database connection and set-up a dataset
with the relevant query, which returns a table of information. I
now want to simply insert some dynamic text that references
specific data items on different rows.
By inserting Dynamic Text through Dreamweaver I can only seem
to return the information in row 1 of a specific column (i.e. the
first data item). How do I specify which row the data should be
taken from? The code I have at the moment for inserting the dynamic
text is shown below:
<%# dsCampaigns.FieldValue("CampaignName", Container)%>
This returns the first item in the CampaignName column of the
dsCampaigns dataset. How do I return the item on row 3?
Thanks for your help.hi Ned,
you've helped me again. Thanks.
Putting stop in the first frame makes it now work. I don't
really understand why, though.
I had a 'stop' in frame 2 of my actions layer. so, when i ran
what I started out with, with 'stop' in frame 2, when the playhead
reaches frame one why can't I assign a value to the dynamic text
instance?
thanks. -
Adding a progress loader to a dynamic text field / scrollPane
I have a dynamic text field which is loading images from an external html. This text is named scrollPaneImage and is a child of a movieClip called scrollPaneContent. I then load scrollPaneContent into a scroll pane named scrollPane
When the user interacts with my swf different images are loaded into scrollPaneImage. Since some of the images take a few seconds to load, I'd like there to be a progress loader displayed in the scrollpane.
I have tried adding the progress event listner to the dynamic text, the movie clip and the scrollpane and cannot get it to respond or track the loading.
scrollPaneContent.addEventListener(ProgressEvent.PROGRESS,reportProgress);
function reportProgress(e:ProgressEvent):void {
trace(e.bytesLoaded + " loaded out of " + e.bytesTotal);
trace("LOADED");
Can anyone suggest what I might be doing wrong or of another approach?
thanks in advance,
JoshHi KGLAD. Thanks for the response. Yes my code is a little messy. Here I have included everything and tried to do a little cleaning. Is there enough code here for you to get an idea of how/when things are firing?
import com.google.maps.LatLng;
import com.google.maps.Map;
import com.google.maps.MapEvent;
import com.google.maps.MapType;
import com.distriqt.gmaps.kml.utils.*;
import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.TweenLite;
import flash.geom.Point;
import com.greensock.plugins.*;
TweenPlugin.activate([AutoAlphaPlugin]);
import com.google.maps.controls.NavigationControl;
import com.google.maps.controls.MapTypeControl;
import com.google.maps.controls.OverviewMapControl;
import com.google.maps.overlays.GroundOverlay;
import com.google.maps.overlays.GroundOverlayOptions;
import com.google.maps.LatLng;
import com.google.maps.LatLngBounds;
import com.google.maps.MapMouseEvent;
import com.google.maps.controls.*;
import com.google.maps.overlays.Marker;
import com.google.maps.InfoWindowOptions;
import com.google.maps.overlays.MarkerOptions;
import com.anttikupila.utils.JPGSizeExtractor;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.net.URLLoader;
import fl.controls.UIScrollBar;
import flash.events.Event;
import fl.events.ScrollEvent;
import flash.sampler.NewObjectSample;
[Embed(source="ICONS/PHOTO_BLACK.png")]var photoIcon:Class;
[Embed(source="ICONS/BLOG_BLACK.png")]var blogIcon:Class;
scrollPane
// GMAP PARAMETERS
var map:Map = new Map();
map.key = "map key";
//map.key = "api key";
//define the size of the map extent....
map.sensor = "false";
map.setSize(new Point(stage.stageWidth, stage.stageHeight));
map.addEventListener(MapEvent.MAP_READY, onMapReady);
map.addEventListener(MapEvent.MAP_READY, createmarkers);
map.addEventListener(MapEvent.MAP_READY, createMarkerArrays);
map.addEventListener(MapEvent.MAP_READY, createPhotoPingers);
this.addChild(map);
map.setSize(new Point(stage.stageWidth, stage.stageHeight));
//on map ready params
function onMapReady(event:Event):void
map.setCenter(new LatLng(48,-113.5), 8, MapType.PHYSICAL_MAP_TYPE);
map.enableScrollWheelZoom();
map.disableContinuousZoom();
//Marker options for a photo piece
var photoMarkerOptions:MarkerOptions = new MarkerOptions();
photoMarkerOptions.icon = new photoIcon();
photoMarkerOptions.hasShadow=false;
//Marker options for a blog piece
var blogMarkerOptions:MarkerOptions = new MarkerOptions();
blogMarkerOptions.icon = new photoIcon();
blogMarkerOptions.hasShadow=false;
//load xml tester
var pntloader:URLLoader = new URLLoader();
var pntxml:XML = new XML();
pntloader.addEventListener(Event.COMPLETE, loadpntXML);
pntloader.load(new URLRequest("map_feed.xml"));
// create an array of jpgs to index
var JPGIndexArray:Array = new Array();
//Create array that will be populated with points
var pointsArray:Array = new Array();
//Load the XML
function loadpntXML(e:Event):void {
pntxml=new XML(e.target.data);
pntxml.ignoreWhite = true;
for (var i:int = 0; i< pntxml.row.length(); i++){
pointsArray[i]="mrk"+i;
JPGIndexArray[i]="JPG"+i;
//trace(pntxml);
//Create the markers and add them to the map
function createmarkers(event:Event):void
for (var i:Number = 0; i < pntxml.row.length(); i++) {
var markerOptions:MarkerOptions = new MarkerOptions();
if (pntxml.row[i].TYPE=="PHOTO")
markerOptions.icon = new photoIcon();
markerOptions.tooltip = "Photo";
markerOptions.hasShadow=false;
else if(pntxml.row[i].TYPE=="BLOG")
markerOptions.icon = new blogIcon();
markerOptions.tooltip = "Blog Entry";
markerOptions.hasShadow=false;
else
null
pointsArray[i] = new Marker(new LatLng(pntxml.row[i].LAT,pntxml.row[i].LONG),markerOptions);
markerA.push(pointsArray[i]);
map.addOverlay(pointsArray[i]);
pointsArray[i].addEventListener(MapMouseEvent.CLICK,indexCalledMarkerRecord);
pointsArray[i].addEventListener(MapMouseEvent.CLICK,scrollPanePopulate);
// PING PHOTO DIMENSIONS BEFORE LOADING //
var je : JPGSizeExtractor = new JPGSizeExtractor( );
je.addEventListener( JPGSizeExtractor.PARSE_COMPLETE, jeLoadHandler );
je.addEventListener( JPGSizeExtractor.PARSE_FAILED, jeParseFailed );
function createPhotoPingers(event:Event):void{
for (var k:Number=0; k <pntxml.row.length(); k++){
JPGIndexArray[k]=new JPGSizeExtractor();
JPGIndexArray[k].debug = false;
JPGIndexArray[k].addEventListener(JPGSizeExtractor.PARSE_COMPLETE, jeLoadHandler );
trace("madeit");
pingPhotoUrls();
function pingPhotoUrls():void
for (var i:Number = 0; i < pntxml.row.length(); i++) {
var calledMarkerUrl=pntxml.row[i].URL_OF_CONTENT;
JPGIndexArray[i].extractSize(calledMarkerUrl);
var JPG1=null;
function jeLoadHandler(e:Event) : void {
trace(e.currentTarget.width + "x" + e.currentTarget.height );
imageWidths.push(e.currentTarget.width);
function jeParseFailed( event : Event ) : void {
trace( "Parse failed" );
var imageWidths = new Array;
// FUNCTIONS FOR INDEXING CALLED MARKERS//
//Create blank array for use in indexing
var markerA:Array=[];
//VAR FOR USE IN INDEXING CALLED MARKER
var pointindex=null;
//INDEX CALLED MARKER POINT XML RECORD
function indexCalledMarkerRecord(e:MapMouseEvent):void{
pointindex=genIndexPos(markerA,Marker(e.currentTarget));
//trace(pntxml.row[pointindex].DESC);
//FUNCTION FOR INDEXING CALLED MARKER
function genIndexPos(a:Array,e:Marker):uint{
for(var i:uint=0;i<a.length;i++){
if(a[i]==e){
return i;
return null;
// SCROLLPANE FUNCTIONS //
this.addChild(scrollPane);
scrollPane.setSize(255,300);
scrollPane.x=-200;
scrollPane.y=-200;
scrollPane.alpha=0;
scrollPaneContent.mouseEnabled=false;
spHeader.closeBox.addEventListener(MouseEvent.CLICK, function(eMouseEvent):void
TweenLite.to(scrollPane, .5,{autoAlpha:0,overwrite:true});
spHeader.forDrag.addEventListener(MouseEvent.MOUSE_DOWN, function (e:MouseEvent):void
scrollPane.startDrag();
spHeader.forDrag.addEventListener(MouseEvent.MOUSE_UP, function (e:MouseEvent):void
scrollPane.stopDrag();
spHeader.forDrag.buttonMode=true;
spHeader.forDrag.useHandCursor=true;
spHeader.width=300;
scrollPane.source = scrollPaneContent;
scrollPaneContent.scrollPaneText.autoSize='left';
scrollPaneContent.scrollPaneImage.autoSize='center';
scrollPaneContent.scrollPaneImage.autoSize=TextFieldAutoSize.CENTER;
scrollPaneContent.mouseEnabled=false;
scrollPaneContent.scrollPaneText.condenseWhite = true;
// Add listener.
scrollPane.addEventListener(Event.COMPLETE, completeListener);
scrollPaneContent.addEventListener(ProgressEvent.PROGRESS,reportProgress);
function completeListener(event:Event):void {
trace('Scrollpane content loaded');
function reportProgress(e:ProgressEvent):void {
trace(e.bytesLoaded + " loaded out of " + e.bytesTotal);
trace("LOADED");
function scrollPanePopulate(event:Event){
//show scroll pane
scrollPane.x=33;
scrollPane.y=33;
TweenLite.to(scrollPane, .5,{autoAlpha:1,overwrite:true});
TweenLite.to(spHeader, .5,{autoAlpha:1,overwrite:true});
//create the temp variables
var calledMarkerIndex=pntxml.row[pointindex].ID;
var calledMarkerDate=pntxml.row[pointindex].DATE;
var calledMarkerDescription=pntxml.row[pointindex].DESC;
var calledMarkerContent=pntxml.row[pointindex].URL_OF_CONTENT;
var imgWidth=JPGIndexArray[pointindex].width;
var imgHeight=JPGIndexArray[pointindex].height;
scrollPaneContent.scrollPaneText.htmlText="<font size='12' color='#000000'>"+calledMarkerDescription;
var imgBoxHeight=scrollPaneContent.scrollPaneImage.height;
var txtHeight=scrollPaneContent.scrollPaneText.height;
var contentHeight=(imgBoxHeight+txtHeight);
scrollPane.setSize(300,(contentHeight+15));
//size the text box
scrollPaneContent.scrollPaneText.width=270;
//if image is wide or tall, scale accordingly and create a string that will be used
if(imgWidth>=imgHeight){
var imgSource:String = "<img src="+"'"+calledMarkerContent+"'"+"width='"+250+"'"+"height='"+150+"'"+"/>";
var calledImgHgh=160;
else
var imgSource:String = "<img src="+"'"+calledMarkerContent+"'"+"width='"+110+"'"+"height='"+167+"'"+"/>";
var calledImgHgh=177;
//fill in the text
scrollPaneContent.scrollPaneImage.htmlText=imgSource;
//scrollPaneContent.scrollPaneText.htmlText="<font size='12' color='#000000'>"+calledMarkerDescription;
//pan the map to the called position
map.panTo(pointsArray[calledMarkerIndex-1].getLatLng())
//add the header to the SP and scale accordingly
scrollPane.addChild(spHeader);
spHeader.x=-1;
spHeader.y=1;
spHeader.width=299;
if (txtHeight>=250){
scrollPane.setSize(300,275);
scrollPaneContent.scrollPaneText.htmlText="<font size='12' color='#000000'>"+calledMarkerDescription+"<br><br>";
if (txtHeight<=5){
scrollPane.setSize(300,200);
scrollPaneContent.scrollPaneText.htmlText="<font size='12' color='#000000'>"+calledMarkerDescription;
if (txtHeight>=5){
scrollPane.setSize(300,275);
scrollPaneContent.scrollPaneText.htmlText="<font size='12' color='#000000'>"+calledMarkerDescription+"<br><br>";
// CREATE TEMP VARIABLES FOR POSITIONING AND PLACE DYNAMIC TEXT
var scTextY=scrollPaneContent.scrollPaneText.y;
var scImageY=scrollPaneContent.scrollPaneImage.y;
var scTextHeight=scrollPaneContent.scrollPaneText.height;
scrollPaneContent.scrollPaneText.y=scImageY+calledImgHgh;
//update the scrollpane and reset the scrollbar
scrollPane.update();
scrollPane.verticalScrollPosition=(0);
scrollPane.verticalScrollBar.height=270;
scrollPane.verticalScrollBar.x=281;
scrollPane.verticalScrollBar.y=3;
spHeader.alpha=0;
this.addChild(spHeader);
var photoMarkersArray=new Array();
var photoMarkersIndexArray=new Array();
//CREATE ARRAY OF PHOTO MARKERS
function createMarkerArrays(e:Event):void{
for (var j:int=0; j<pntxml.row.(TYPE=="PHOTO").ID.length(); j++){
var tempMarkerIndex=pntxml.row.(TYPE=="PHOTO").ID[j];
var tempMarkerRef="mrk"+tempMarkerIndex;
photoMarkersArray.push(tempMarkerRef);
photoMarkersIndexArray.push(tempMarkerIndex); -
How to load dynamic text inside a movie clip?
hello all - i have a main stage where on the first frame my
"home" movie clip displays. i did this by dragging/dropping, and
then i put a stop action. all works fine.
inside this home movie clip on the main stage, there are
links to other movie clips. for example, to get to my faq's page -
you click that button, then it takes you to frame 4 on my main
stage, where my faq's movie clip (followed by stop action) has been
dragged/dropped and displays properly.
within the faq's movie clip this process is repeated, with
buttons taking to you various pages (different frames where
different movie clips play - all works fine).
so now i want to add a dynamic text field within my faq's
movie clip. i have read numerous tutorials where i have created the
text file but i have not been able to display it with success
within my faqs movie clip.
here is some code that my dvd tutorial instructs me to place
on main stage as i practice getting this to work:
var myMCL:MovieClipLoader = new MovieClipLoader ();
var myListener:Object = new Object();
myMCL.addListener(myListener);
var myLV:LoadVars = new LoadVars();
myLV.onLoad = function (success:Boolean) {
if (success) {
_level5.loadedInfo.htmlText = myLV.info;
} else {
_level5.loadedInfo.text = "There has been an error loading
the requested information. Please contact the webmaster.";
and here is some code that i place on the faqs button within
my main movie clip that takes me back to main stage and plays faq
movie clip all successfully:
on (release) {
//Movieclip GotoAndPlay Behavior
_root.gotoAndPlay("4");
//End Behavior
and finally, here is some code that i place within my faqs
movie clip in an attempt to display my dynamic text within the faqs
movie clip - so far unsuccessful:
_level0.myLV.load("vars/faqs.txt");
NOTE:
i have published this to view - not working.
i have my faqs text file starting as info=
i have eliminated white space within my text file
i am using flash 8 pro
can anyone offer some sugestions? thanks!hmmmmm lemme double check as i seem to be a bit lost now.
// this is my actions layer code on frame 4 of main timeline:
stop();
var myLV:LoadVars = new LoadVars();
myLV.onLoad = function (success:Boolean) {
if (success) {
_level5.loadedInfo.htmlText = myLV.info;
} else {
_level5.loadedInfo.text = "There has been an error loading
the requested information. Please contact the webmaster.";
myLV.load("vars/faqs.txt");
1. fyi - at frame 4 on main timeline, one layer beneath the
actions layer where i dragged/dropped my faqs movie clip i gave my
faqs movie clip an instance name of "mainfaqs" - although nowhere
do i refer to this specific mc within my code.
2. where would i replace/insert the following code?
_level0.faq_mc.loadedInfo.text = myLV.info;
3. i didn't know about embedding font but i saw the option
and embedded it - still no results.
4. i'm not sure how to do the following:
_level5.loadedInfo.text ='test'; //although I would still
change the path as above
To see if your getting a return from the load call adn text
file, use a trace statment before the success condition and see
what it returns:
trace(myLV);
sorry to be such a pain - i really have looked around for
answers through previous postings and i googled it and i've been
taking instruction through lynda.com and dvds but i seem to be
stuck here.... as always - thanks for your time -
Iterate through all dynamic text variables
Hello,
I'd like to be able to iterate through all of the dynamic
text variables in my flash movie, and I'd like it so that if I add
new text to this movie, it will show up in the iteration.
Essentially, I want to do something like this:
for (i in _root) {
trace(i);
While this seems to print out all the variables in root, it
prints more than just the dynamic text variables, and also doesn't
iterate down through various objects to find the dynamic text
variable.
Is there any way I can accomplish this in action script?
Thanks!Great! That code helps me a lot.
There are still two weird issues.
1) the test for tl[obj].text seems to always turn out to be
false. However, if I trace the value of text, I'll see the text.
Example:
trace(tl[obj].text); // This will display the value in the
text field
if (tl[obj].text) // This is always returning false.
Any ideas?
The 2nd issue might be more difficult - some of my text
objects don't appear until later in the movie (i.e. frame 10). It
sort of looks like this looping doesn't see objects that appear in
the future. Do I need to advance the frame 1 by 1 and repeat this
looping process until the text appears? Maybe instead I can always
have the text in the first frame, but have it be invisible or
something? -
I am designing my first flash site, and created a Dynamic
text field called header_txt. I want the content inside this field
changed based on which page the user navigates to. I have used an
"IF" statement inside a Declared Function , but wonder if that is
the best option, also, my IF statement is no working. Here it is:
function headingChange() {
if (_root._currentframe == "contact") {
header_txt.text = "Contact Us";
} else if (_root._currentframe == "about") {
header_txt.text = "About Us";
headingChange();
var header_txt:String = "";
Why is this not working, and what would be a better way of
changing this field?
Thanks for the help!
Chuck_currentframe only returns a number. You can't access the
frame's label with actionscript, except to specify it as a
parameter in the gotoAndPlay() method.
I would assume that you are calling the headingChange()
function at each labeled frame. If you are, then just change the
function call to this:
At frame labeled "contact": headingChange("contact");
At frame laveled "about": headingChange("about");
Change your function to read as follows:
function headingChange(s:String) {
if (s== "contact") {
header_txt.text = "Contact Us";
} else if (s== "about") {
header_txt.text = "About Us";
Or, you could just access your dynamic textfield directly
everytime you get to a new frame with a label by executing the
following code in a frame:
At the frame labeled "about": header_txt.text = "About Us";
Either way would work. Though I like keeping stuff like this
in a function. It makes it easier to update so that it does more in
the future.
Tim
Maybe you are looking for
-
Edit or deleting text in a pdf document.
I'm trying to edit text in a pdf file, If i delete a line the the document backs up and i end up with text over the top of text....can anyone tell me how to edit or delete text in a document without everything around it moving up or down?
-
Multiple video formats in one feed?
My podcast (http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=348713189) has videos formatted for Apple TV, but that means subscribers can't load it on their iPods. Is there a way to host multiple video formats in one feed? Feed url =
-
What algorithm is used to Sort Photos?
I've read a LOT of posts asking about the sorting order for photos within an album. No one has yet to provide an accurate answer about the sorting algorithm/method used. Some people say to use iPhoto (I have a PC so I can't) which isn't an answer. Ot
-
How the hell do I report Firefox 4.0 hanging?
I installed Firefox 4.0 but, when using Gmail (I don't know if the hang is specific to Gmail) Firefox would suddenly close and the whole Windows 7 system would hang and I can only shut the PC off using the Power button on the PC. Even Ctrl+Alt+Delete
-
Content code for new OS redemption
I recieved the content code from Apple to download the new OS for free. I tried imputing it into the App Store but it will not work. I clicked on 'redeem' under Quick Links and put the content code in, but it says that the code doesnt exist.